如何将Stream
图像(我使用Album.GetArt
方法检索到的MediaLibrary
)转换为应用程序中可用的Image
?
答案 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.