I'm using the following code to save a picture of a canvas
if (!Directory.Exists(DefaultSettings.MainPath + "//Skeleton Images//"))
Directory.CreateDirectory(DefaultSettings.MainPath + "//Skeleton Images//");
System.Windows.Size size = new System.Windows.Size(canvas.Width, canvas.Height);
canvas.Measure(size);
canvas.Arrange(new System.Windows.Rect(size));
RenderTargetBitmap renderBitmap = new RenderTargetBitmap( (int)size.Width, (int)size.Height, 96d, 96d, PixelFormats.Pbgra32);
renderBitmap.Render(canvas);
using (FileStream outstream = new FileStream(DefaultSettings.MainPath + "//Skeleton Images//Kinected (" + images + ").jpg", FileMode.Create))
{
JpegBitmapEncoder cEncoder = new JpegBitmapEncoder();
cEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
cEncoder.Save(outstream);
}
However, it is only saving the top portion of the image. Although the image size is 321x240, and the canvas size is also the same size. Why is this happening? this same code used before saved the entire canvas, so why is this suddenly creating errors? Image below to illustrate the problem. Also note the canvas is placed on top of the image, as they are rendered seperately, and the canvas extends all the way down to the "Color Frame" text.