C# 墨水画布字节数组图像绑定
我有一个墨水画布,用户可以在上面画画,我将其作为字节数组保存到数据库中作为图像:C# 墨水画布字节数组图像绑定,c#,wpf,C#,Wpf,我有一个墨水画布,用户可以在上面画画,我将其作为字节数组保存到数据库中作为图像: using (MemoryStream ms = new MemoryStream()) { if (icPad.Strokes.Count > 0) { icPad.Strokes.Save(ms, true); picture = ms.ToArray(); 如何将字节数组绑定到映像中 编辑: 我使用以下代码转换为BitmapImage: if (
using (MemoryStream ms = new MemoryStream())
{
if (icPad.Strokes.Count > 0)
{
icPad.Strokes.Save(ms, true);
picture = ms.ToArray();
如何将字节数组绑定到映像中
编辑:
我使用以下代码转换为BitmapImage:
if (imageData == null || imageData.Length == 0) return null;
var image = new BitmapImage();
try
{
using (var mem = new MemoryStream(imageData))
{
mem.Position = 0;
image.BeginInit();
image.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
image.CacheOption = BitmapCacheOption.OnLoad;
image.UriSource = null;
image.StreamSource = mem;
image.EndInit();
}
image.Freeze();
}
catch (Exception ex)
{
}
return image;
}
我得到一个错误:
未找到适合完成此操作的成像组件
您正在保存的是一个图像,而不是一个图像。请参阅该方法的备注部分:“Save方法将StrokeCollection保存为Ink序列化格式(ISF)”。Will Ink.Save(PersistenceFormat.Gif);另存为图像?什么是ink.save(PersistenceFormat.Gif)
?你必须说出你所指的方法(类)。