如何在c#windows 8中将简单流(http webresponse)转换为bitmapimage?

前端之家收集整理的这篇文章主要介绍了如何在c#windows 8中将简单流(http webresponse)转换为bitmapimage?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我尝试了1000次,将一个简单的流(http webresponse)转换为bitmapimage,但没有一个教程在c# windows 8中工作.

例:

BitmapImage image = new BitmapImage();
image.SetSource(stream);
image1.Source = image;

感谢所有回复.

InMemoryRandomAccessStream randomAccessStream = new InMemoryRandomAccessStream();
DataWriter writer = new DataWriter(randomAccessStream.GetOutputStreamAt(0));
writer.WriteBytes((byte[])command);
await writer.StoreAsync();
BitmapImage image = new BitmapImage();
image.SetSource(randomAccessStream);

解决方法

你试过这个吗?
InMemoryRandomAccessStream randomAccessStream = new InMemoryRandomAccessStream();
DataWriter writer = new DataWriter(randomAccessStream.GetOutputStreamAt(0));
writer.WriteBytes(response.Content.ReadAsByteArray());
BitmapImage image = new BitmapImage();
image.SetSource(randomAccessStream);
原文链接:https://www.f2er.com/csharp/244345.html

猜你在找的C#相关文章