1
我必须将我的FrameworkElement保存为非常大的光栅图像。现在我用的是RenderTargetBitmap类和BitmapEncoder,以这样的方式如何将FrameworkElement保存为非常大的栅格图像?
RenderTargetBitmap bmp = new RenderTargetBitmap(ElementWidth, ElementHeight,
90, 96, PixelFormats.Default);
bmp.Render(MyElement); // OutOfMemoryException here
PngBitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bmp));
using (var stream = File.Create(filePath))
{ encoder.Save(stream); }
凡ElementWidth和ElementHeight是大量(约10000x6000)。但有了这个解决方案,当我尝试Render我的元素时出现OutOfMemoryException。
还有其他方法可以做我所需要的(不会导致OutOfMemoryException)? 谢谢。