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.
try using a Save File Dialog
Here is an example code i used in my class "add signature" in vb.net
upon button click a savefile dialog box will appear, after putting a file name and pressing save, it will be save as a png image(i used pngBitmap Encoder)
This has same format with what you are using but with a save file dialog added.
btw. WPFControl.Inkcanvas1 is my inkcanvas