我尝试了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);