【发布时间】:2015-07-24 16:41:35
【问题描述】:
我正在尝试实现一个 Windows 通用应用程序。我面临一个将图像原始数据(字节数组)转换为 BitmapImage 控件的问题。我不知道图像原始数据的类型。我使用了下面的代码,
private async Task<BitmapImage> ByteArrayToBitmapImage(byte[] byteArray)
{
var bitmapImage = new BitmapImage();
var stream = new InMemoryRandomAccessStream();
await stream.WriteAsync(byteArray.AsBuffer());
stream.Seek(0);
bitmapImage.SetSource(stream);
return bitmapImage;
}
图像不显示在窗口中。调试的时候发现bitmapImage对象的高宽都是0。
如果有人知道这个问题的解决方案,请帮助我
【问题讨论】: