static void Main(string[] args) { var iconInput = new IconInput() { Icon = new Icon("Darth-Vader.ico"), XCoordinate = 1300, YCoordinate = 600 }; var ellipseCropInput = new EllipseCropInput() { HeightOffset = 10, WidthOffset = 10 }; var rectangleCropInput = new RectangleCropInput() { DecreasePercentage = 25 }; EllipseImageEditor ellipseImageEditor = new EllipseImageEditor("ewelina.jpg"); ellipseImageEditor.CropImage(ellipseCropInput); ellipseImageEditor.AddIcon(iconInput); ellipseImageEditor.SaveTargetImage("ewelina-ellipse.png"); RectangleImageEditor rectangleImageEditor = new RectangleImageEditor("ewelina.jpg"); rectangleImageEditor.CropImage(rectangleCropInput); rectangleImageEditor.AddIcon(iconInput); rectangleImageEditor.SaveTargetImage("ewelina-rectangle.png"); }
public ActionResult EditIcon(long?id) { var data = new IconInput(); ViewData["IconType"] = _iconAppService.GetIconType(); if (id != null) { data = _iconAppService.Get(id.Value); } return(View("Easyman.FwWeb.Views.Admin.EditIcon", data)); }
public virtual void AddIcon(IconInput input) { if (input.XCoordinate >= _targetImage.Width || input.YCoordinate >= _targetImage.Height) { throw new ArgumentException("Image's area must contain Icons coordinates"); } using (Graphics gg = Graphics.FromImage(_targetImage)) { gg.DrawIcon(input.Icon, input.XCoordinate, input.YCoordinate); } }
public override void AddIcon(IconInput input) { Color upperLeftPixel = _targetImage.GetPixel(input.XCoordinate, input.YCoordinate); Color upperRightPixel = _targetImage.GetPixel(input.XCoordinate + input.Icon.Width, input.YCoordinate); Color bottomLeftPixel = _targetImage.GetPixel(input.XCoordinate, input.YCoordinate - input.Icon.Height); Color bottomRightPixel = _targetImage.GetPixel(input.XCoordinate + input.Icon.Width, input.YCoordinate - input.Icon.Height); if (upperLeftPixel.A == 0 || upperRightPixel.A == 0 || bottomLeftPixel.A == 0 || bottomRightPixel.A == 0) { throw new ArgumentException("You cannot add icon at transparent place! Please, try again."); } base.AddIcon(input); }
/// <summary> /// 新增数据 /// </summary> /// <param name="input">输入的实体</param> public void AddOrUpdate(IconInput input) { var data = input.MapTo <Icon>(); _iconRepository.InsertOrUpdate(data); }