Hey everyone,
I'm using canvas named "Can" in my program and I needed to save it as .png or .jpg, so I went here and found this code:
RenderTargetBitmap rtb = new RenderTargetBitmap( (int)Can.ActualWidth, (int)Can.ActualHeight, 96, 96, PixelFormats.Pbgra32); rtb.Render(Can); PngBitmapEncoder enc = new PngBitmapEncoder(); enc.Frames.Add(System.Windows.Media.Imaging.BitmapFrame.Create(rtb)); using (var stm = System.IO.File.Create(@"D:\image.png")) { enc.Save(stm); }
And I get the .png, but it's not the whole picture! Half an inch at the bottom is cut off. I make a rectangle on the edge of the canvas, and I cannot see the bottom line of the rectangle. Am I using the height/width of the canvas wrong?
And one more question, what is the difference between canvas.Width and canvas.ActualWidth in this case?
Thank you!
Knowledge: C, C++, C#, Java, Pawn