I want to save my canvas to bitmap. I found some examples in internet, but all of those saves only black image (with size of my canvas). What can I do with this?
Co
PAY ATTENTION
if your render is a black image it is because of your incorrect sizing.
this is a good example for you:
RenderTargetBitmap rtb = new RenderTargetBitmap(width, height, mXdpi, mYdpi, System.Windows.Media.PixelFormats.Default);
rtb.Render(my_canvas);
BitmapEncoder pngEncoder = new PngBitmapEncoder();
pngEncoder.Frames.Add(BitmapFrame.Create(rtb));
using (var fs = System.IO.File.OpenWrite("test.png"))
{
pngEncoder.Save(fs);
}
this code saves a png image from your bitmap that rendered from your canvas.
Hope helps you.