如何在应用程序中将图像的Stream
(使用Album.GetArt
方法从MediaLibrary
检索到)转换为可用的Image
?
简单。。。var img = Bitmap.FromStream(stream);
您可以从位图直接运行到Images的怀抱中。
Image image = System.Drawing.Image.FromStream(stream);
从那里你可以进行其他操作:
image.Save(System.IO.Path.GetPathRoot() + "\Image.jpg", ImageFormat.Jpeg);
对于手机来说,这应该是有效的:
BitmapImage image = new BitmapImage();
image.SetSource(stream);
干得好!我用测试了这个
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.