我有一个绑定到MVVM模型中的StrokeCollection的InkPresenter,我正在使用它作为一个签名面板。在我将数据发送回服务器之前,我想将StrokeCollection转换为PNG数据,下面是我所拥有的(我使用的是ImageTools库):
// Signature is a StrokesCollection
var bounds = Signature.GetBounds();
var inkSignature = new InkPresenter {Height = bounds.Height, Width = bounds.Width, Strokes = Signature};
var wbBitmap = new WriteableBitmap(inkSignature, null);
var myImage = wbBitmap.ToImage();
byte[] by = null;
MemoryStream stream = null;
using (stream = new MemoryStream())
{
PngEncoder png = new PngEncoder();
png.Encode(myImage, stream);
}
流总是充满了0,我觉得我错过了一些我没有想到的非常简单的东西。有什么想法吗?
发布于 2011-07-12 10:21:57
我认为问题在于渲染器在你抓取之前没有时间更新UI。尝试将位图创建包装为Dispatcher.BeginInvoke调用。
https://stackoverflow.com/questions/6510461
复制相似问题