Rendering end exporting image from InkCanvas control

I’ve started to create graphics editor that can save and reopen painted images. But I faced a problem with rendering image for its opening in Win file explorer (with photo viewer, paint, etc.). The following code is about that:

 myfileStream = new FileStream(saveFileDialog1.FileName, FileMode.Create); RenderTargetBitmap rtb = new RenderTargetBitmap((int)inkCanvas1.ActualWidth, (int)inkCanvas1.ActualHeight, 96d, 96d, PixelFormats.Default); rtb.Render(inkCanvas1); //This encoding makes unavaliable to open image in inkCanvas1 PngBitmapEncoder pngEnc = new PngBitmapEncoder(); pngEnc.Frames.Add(BitmapFrame.Create(rtb)); pngEnc.Save(myfileStream); MessageBox.Show("Picture was successfully exported!"); 

Full project repository is here:

I also tried this: inkCanvas1.Strokes.Save(myfileStream);
but that way it’s impossible to open final image beyond of the app.

submitted by /u/nick_aviator
[link] [comments]

Leave a Reply