How can I convert a Stream
of an image (which I retrieved using the Album.GetArt
method from the MediaLibrary
) into a usable Image
in my application?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Easy... var img = Bitmap.FromStream(stream);
回答2:
You can run from Bitmaps straight into the arms of Images.
Image image = System.Drawing.Image.FromStream(stream);
From whence you can do other operations:
image.Save(System.IO.Path.GetPathRoot() + "\\Image.jpg", ImageFormat.Jpeg);
回答3:
For phone this should work:
BitmapImage image = new BitmapImage();
image.SetSource(stream);
回答4:
Great job! I tested this with:
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.