0

so i have a wpf app, there i have DrawingVisual object, let's call it "visual", also there is RenderTargetBitmap object, let's call it "target". I have some strings of code below.

DrawingVisual visual = new DrawingVisual();
RenderTargetBitmap target = new RenderTargetBitmap(certBg.PixelWidth, certBg.PixelHeight, 96, 96, PixelFormats.Default);
target.Render(visual);
Image img = new Image();
img.Source = target;

How can i save that picture? I thought to use img.Save, but it doesn't work in WPF. I've tried to use BitmapEncoder but it was unsuccsessful. How shall i save on the disk that picture?

1gentlemann
  • 164
  • 1
  • 3
  • 14
  • 1
    What is it you want to achieve? The System.Drawing.Bitmap component in WPF has a Save functionality. Try using that instead of the Image control. – Lupu Silviu Aug 18 '17 at 13:41
  • Eventually https://stackoverflow.com/questions/4161359/save-bitmapimage-to-file can help you. – CWBudde Aug 18 '17 at 13:42
  • Does [this answer](https://stackoverflow.com/a/10471181/23074) help you? – Eric Olsson Aug 18 '17 at 15:38
  • @Lupu "System.Drawing.Bitmap component in WPF" doesn't make sense. System.Drawing.Bitmap is WinForms, not WPF. In WPF you would use a BitmapEncoder. – Clemens Aug 18 '17 at 17:03

0 Answers0