【发布时间】:2017-08-30 01:05:49
【问题描述】:
我正在尝试使用以下代码将 MemoryStream 转换为 Image。
Stream stream = new MemoryStream(bytes);
BitmapImage bitmapImage = new BitmapImage();
await bitmapImage.SetSourceAsync(stream.AsRandomAccessStream());
但它在SetSourceAsync方法中抛出异常,异常是
System.Exception 未被用户代码处理 H结果=-2003292336 Message=找不到组件。 (HRESULT 的例外情况: 0x88982F50) 源=mscorlib 堆栈跟踪: 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务 任务) 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotificat 离子(任务任务) 在 System.Runtime.CompilerServices.TaskAwaiter.GetResult() 在 ImageEditor_UWP.MainPage.d__1.MoveNext() InnerException:
如何将流转换为图像?
【问题讨论】:
-
使用 Try/Catch 块
-
你能分享你的源代码吗?我复制了你的代码,它运行良好github.com/haison8x/sample-uwp-bitmapimage
标签: c# uwp bitmapimage