I am trying to save an image from ink canvas however it does not create any file after saving, this is my code:
RenderTargetBitmap rtb = new RenderTargetBitmap(
(int)canvas.Width, (int)canvas.Height, 0, 0, PixelFormats.Default);
rtb.Render(this.canvas);
JpegBitmapEncoder encoder = new JpegBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(rtb));
using(var file = new FileStream(@"C:\test.jpg", FileMode.Create))
{
encoder.Save(file);
}
however it does not create any file even when I change the directory. No exceptions is invoked and no errors are shown. The code just ran normally without any problem but the file meant to be generated is not there.
Ok here is one way I did it, this way exports a "test.png" in debug folder. The way is simple, firstly create a InkCanvas I will name it
ink
for the purposes of this example. Also create a button that has a on click event handler. In that buttons on click event handler paste this.InkCanvasWindow.xaml.cs