static void Main(string[] args) { ImagePath = args[0]; var editableImage = EditableImage.FromFilePath(ImagePath); var watermarkLocation = new WatermarkLocation { Location = Location.BottomLeft, ImageMarginPercentage = 2.5, ImageSizePercentage = 15 }; var watermarkImage = EditableImage.FromFilePath(Path.Combine(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName), "watermark-disney-white.png")); var watermarkApplier = new WatermarkApplier(watermarkLocation, watermarkImage); watermarkApplier.Apply(editableImage); foreach (var border in _borders) { var borderApplier = new PercentageBorderApplier(border.Value, border.Key); editableImage = borderApplier.Apply(editableImage); } editableImage.Save(); }
private static byte[] GetBytesInternalPng(UIElement element) { WriteableBitmap w = new WriteableBitmap(element, new TranslateTransform()); EditableImage imageData = new EditableImage(w.PixelWidth, w.PixelHeight); try { for (int y = 0; y < w.PixelHeight; ++y) { for (int x = 0; x < w.PixelWidth; ++x) { int pixel = w.Pixels[w.PixelWidth * y + x]; imageData.SetPixel(x, y, (byte)((pixel >> 16) & 0xFF), (byte)((pixel >> 8) & 0xFF), (byte)(pixel & 0xFF), (byte)((pixel >> 24) & 0xFF) ); } } } catch (System.Security.SecurityException) { MessageBox.Show("Cannot print images from other domains"); return(null); } Stream pngStream = imageData.GetStream(); StreamReader sr = new StreamReader(pngStream); byte[] binaryData = new Byte[pngStream.Length]; pngStream.Read(binaryData, 0, (int)pngStream.Length); return(binaryData); }
public void Execute(object param) { // ???????????????????????????????????????????? EditableImage image = _viewModel.Image; image.Source.Save(image.Path, image.Format); }
static void Main(string[] args) { try { ImagePath = args[0]; if (_isDebugging) { Console.WriteLine("Press key to start"); Console.ReadLine(); Console.WriteLine(ImagePath); } var editableImage = EditableImage.FromFilePath(ImagePath); if (_isDebugging) { Console.WriteLine(editableImage.Path); } var selector = new MetadataSelector(); var steps = selector.GetProcessSteps(editableImage); if (_isDebugging) { foreach (var step in steps.Steps) { Console.WriteLine(step.Id); } } foreach (var step in steps.Steps) { editableImage = step.Apply(editableImage); } if (_isDebugging) { Console.WriteLine("Ready to write"); } editableImage.Save(); if (_isDebugging) { Console.WriteLine("END"); Console.ReadLine(); } } catch (System.Exception e) { Console.WriteLine(e.StackTrace); Console.WriteLine("Please press enter to close this once you have addressed the error."); Console.ReadLine(); } }
protected void rGridTeam_UpdIns(object sender, GridCommandEventArgs e, string Action) { try { GridEditableItem eeditedItem = e.Item as GridEditableItem; TeamDomainModel TeamDM = new TeamDomainModel(); if (Action == "Update") { TeamDM.TeamID = Convert.ToInt32((eeditedItem.FindControl("lblTeamID") as Label).Text.ToString()); } TeamDM.TeamName = (eeditedItem.FindControl("rTBTeamName") as RadTextBox).Text.Trim(); TeamDM.OwnerName = (eeditedItem.FindControl("rTBOwnerName") as RadTextBox).Text.Trim(); TeamDM.OwnerUserID = new Guid((eeditedItem.FindControl("rDDUserName") as RadDropDownList).SelectedValue.ToString()); TeamDM.OwnerEmail = (eeditedItem.FindControl("rTBOwnerEmail") as RadTextBox).Text.Trim(); var aUpload = (eeditedItem.FindControl("AsyncUpload1") as RadAsyncUpload); if (aUpload.UploadedFiles.Count > 0) { EditableImage img = new EditableImage((MemoryStream)Context.Cache.Get(Session.SessionID + "UploadedFile")); MemoryStream s = new MemoryStream(); img.Image.Save(s, img.RawFormat); byte[] imgData = s.ToArray(); TeamDM.TeamImage = imgData; } else { TeamDM.TeamImage = null; } if (Action == "Update") { TeamBLL.UpdateTeam(TeamDM); } else if (Action == "Insert") { TeamBLL.InsertTeam(TeamDM); } //rGridPlayer.Rebind(); } catch (Exception ex) { StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); string errMethod = sf.GetMethod().Name.ToString(); // Get the current method name string errMsg = "600"; // Gotta pass something, we're retro-fitting an existing method Session["LastException"] = ex; // Throw the exception in the session variable, will be used in error page string url = string.Format(ConfigurationManager.AppSettings["ErrorPageURL"], errMethod, errMsg); //Set the URL Response.Redirect(url); // Go to the error page. } }
protected void RadImageEditor1_ImageLoading(object sender, ImageEditorLoadingEventArgs args) { //Handle Uploaded images if (!Object.Equals(Context.Cache.Get(Session.SessionID + "UploadedFile"), null)) { using (EditableImage image = new EditableImage((MemoryStream)Context.Cache.Get(Session.SessionID + "UploadedFile"))) { args.Image = image.Clone(); args.Cancel = true; } } }
protected void RadImageEditor1_ImageLoading(object sender, ImageEditorLoadingEventArgs args) { //Handle Uploaded images if (!Object.Equals(Context.Cache.Get(Session.SessionID + "UploadedFile"), null)) { using (EditableImage image = new EditableImage((MemoryStream)Context.Cache.Get(Session.SessionID + "UploadedFile"))) { args.Image = image.Clone(); args.Cancel = true; } } }
public void OpenImage(string path) { Image = new EditableImage(path); ResetFields(); ResetTools(); Active = true; if (ImageReady != null) { ImageReady(); } // clear command list }
static void Main(string[] args) { ImagePath = args[0]; var editableImage = EditableImage.FromFilePath(ImagePath); var borderApplier = new PercentageBorderApplier(BorderWidthPercentage, BorderColor); editableImage = borderApplier.Apply(editableImage); editableImage.Save(); }
public MainWindow() : base(Gtk.WindowType.Toplevel) { Build(); this.image = new EditableImage(); this.image.Name = "image"; this.alignment1.Add(this.image); this.hbox3.Add(this.alignment1); this.Child.ShowAll(); State = ProgramState.None; }
static void Main(string[] args) { ImagePath = args[0]; var editableImage = EditableImage.FromFilePath(ImagePath); foreach (var border in _borders) { var borderApplier = new PercentageBorderApplier(border.Value, border.Key); editableImage = borderApplier.Apply(editableImage); } editableImage.Save(); }
public void Execute(object param) { EditableImage image = _viewModel.Image; SaveFileDialog saveFileDialog = new SaveFileDialog { DefaultExt = "." + image.Format.ToString().ToLower(), Filter = Resources.filter }; if (saveFileDialog.ShowDialog() == true) { image.Source.Save(saveFileDialog.FileName, GetImageFormat(saveFileDialog.FileName)); } }
private static Stream RenderAsPNGStream(Uri logo, Color tileColor) { try { StreamResourceInfo info; info = Application.GetResourceStream(logo); // create source bitmap for Image control (image is assumed to be alread 173x173) WriteableBitmap wbmp3 = new WriteableBitmap(1, 1); try { wbmp3.SetSource(info.Stream); } catch { } WriteableBitmap wb = WriteableBitmapEx.CreateTile(wbmp3, tileColor); EditableImage edit = new EditableImage(wb.PixelWidth, wb.PixelHeight); for (int y = 0; y < wb.PixelHeight; ++y) { for (int x = 0; x < wb.PixelWidth; ++x) { try { byte[] rgba = ControlToPng.ExtractRGBAfromPremultipliedARGB(wb.Pixels[wb.PixelWidth * y + x]); edit.SetPixel(x, y, rgba[0], rgba[1], rgba[2], rgba[3]); } catch (Exception ex) { } } } return(edit.GetStream()); } catch (Exception ex) { return(null); } }
public ImagingSample() { InitializeComponent(); EditableImage img = new EditableImage(255, 255); for (int i = 0; i < img.Height; ++i) { for (int j = 0; j < img.Width; ++j) { img.SetPixel(i, j, (byte)i, 255, (byte)j, 255); } } BitmapImage bmp = new BitmapImage(); bmp.SetSource(img.GetStream()); imgTesting.Source = bmp; }
protected void RadImageEditor1_ImageLoading(object sender, ImageEditorLoadingEventArgs args) { //Handle Uploaded images MemoryStream ms = this.ImageInMemory; if (null != ms) { using (EditableImage image = new EditableImage(ms)) { args.Image = image.Clone(); args.Cancel = true; } } else { //this.Clear(); args.Image = null; args.Cancel = true; } }
public ActionResult Save(EditableImage image) { if (!EditableImageAuthorization.Authorization()) { throw new Exception("Bu işlemi yapmak için yetkiniz yok."); } EditableImage existsImage = UnigateObject.Query("EditableImage") .WhereEqualTo("Code", image.Code) .FirstOrDefault <EditableImage>(); Guid imageGuid = Guid.Empty; if (existsImage != null) { var update = UnigateObject.Update("EditableImage") .Column("Code", image.Code) .Column("ImageFile", image.ImageFile) .WhereEqualTo("ContentId", existsImage.ContentId) .Execute(); if (update.ResultCode == ResultCode.Successfull) { imageGuid = existsImage.ContentId; } } else { var insert = UnigateObject.Insert("EditableImage", image).Execute(); if (insert.ResultCode == ResultCode.Successfull) { imageGuid = Guid.Parse(insert.OutParameters.Get("ContentId")); } } return(new JsonResult() { Data = imageGuid, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
private void ShowUpdatedPreviewImage() { if (SelectedProcessFile?.Steps == null) { PreviewImage.Source = null; return; } var testImageMemoryStream = new MemoryStream(); Properties.Resources.TestImage.Save(testImageMemoryStream, ImageFormat.Jpeg); testImageMemoryStream.Seek(0, SeekOrigin.Begin); var exampleImage = new EditableImage("test.jpg", new ImageMagick.MagickImage(testImageMemoryStream)); var builder = new ApplierBuilder(); foreach (var step in SelectedProcessFile.Steps) { var applier = builder.CreateApplier(step); exampleImage = applier.Apply(exampleImage); } var memoryStream = new MemoryStream(); memoryStream.Seek(0, SeekOrigin.Begin); exampleImage.Image.Write(memoryStream, ImageMagick.MagickFormat.Jpg); memoryStream.Seek(0, SeekOrigin.Begin); var imageSource = new BitmapImage(); imageSource.BeginInit(); imageSource.StreamSource = memoryStream; imageSource.EndInit(); PreviewImage.Source = imageSource; }