將canvas保存到BMP文件(或任何其他類型)時遇到問題。InkCanvas到BitMap
我想救我InkCanvas這樣的:
int margin = (int)canvas.Margin.Left;
int width = (int)canvas.ActualWidth -margin;
int height = (int)canvas.ActualHeight -margin;
//render ink to bitmap
RenderTargetBitmap renderBitmap =
new RenderTargetBitmap(width, height, 96d, 96d, PixelFormats.Default);
renderBitmap.Render(canvas);
//save the ink to a memory stream
BitmapEncoder encoder;
encoder = new BmpBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(renderBitmap));
encoder.Save(myStream);
但我總是得到的圖像從左側和頂部,大小相等我窗口的黑色邊框從點(0,0)我的畫布。我做錯了什麼?