如何将System.IO.Stream转换为图像?

时间:2013-08-08 19:15:26

标签: c# image windows-phone-7 windows-phone-8 stream

如何将Stream图像(我使用Album.GetArt方法检索到的MediaLibrary)转换为应用程序中可用的Image

4 个答案:

答案 0 :(得分:24)

简单...... var img = Bitmap.FromStream(stream);

答案 1 :(得分:11)

您可以从Bitmaps直接进入图像的手臂。

Image image = System.Drawing.Image.FromStream(stream);

从那里你可以做其他的操作:

image.Save(System.IO.Path.GetPathRoot() + "\\Image.jpg", ImageFormat.Jpeg);

答案 2 :(得分:3)

对于手机,这应该有效:

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

答案 3 :(得分:2)

干得好!我测试了这个:

Stream streamF = new MemoryStream(); // stream stored in a data file ( FileDB).


Bitmap image = new Bitmap(streamF);
ConsoleWriteImage(image);

//REMEMBER = in console App you must use < using System.Drawing; >
//to handle images but you can't use Form class for present image into some Canvas.