//code pris de: https://stackoverflow.com/questions/8881865/saving-a-wpf-canvas-as-an-image private void Button_Click_1(object sender, RoutedEventArgs e) { PART_Image.Source = RenderVisualService.RenderToPNGImageSource(PART_Canvas); SaveFileDialog saveFileDialog = new SaveFileDialog(); //saveFileDialog.FileName = txtEditor.Text; saveFileDialog.FileName = "My_drawing"; saveFileDialog.Filter = "Png Image (.png)|*.png|JPG Image (.jpg)|*.jpg|Bitmap Image (.bmp)|*.bmp"; if (saveFileDialog.ShowDialog() == true) { RenderVisualService.RenderToPNGFile(PART_Canvas, saveFileDialog.FileName); } }
public static bool SaveImage(UIElement Source, string FileName = null) { Nullable <bool> result = true; if (String.IsNullOrEmpty(FileName)) { SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = "Image files (*.png;*.jpeg)|*.png;*.jpeg|All files (*.*)|*.*"; // Show save file dialog box result = dlg.ShowDialog(); FileName = dlg.FileName; } // Process save file dialog box results if (result == true) { if (RenderVisualService.RenderToPNGFile(Source, FileName)) { return(true); } } return(false); }
private void Button_Click(object sender, RoutedEventArgs e) { PART_Image.Source = RenderVisualService.RenderToPNGImageSource(PART_Canvas); }
private void Button_Click_1(object sender, RoutedEventArgs e) { RenderVisualService.RenderToPNGFile(PART_Canvas, "myawesomeimage.png"); }