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?
How to convert System.IO.Stream into an Image?
Asked Answered
Easy... var img = Bitmap.FromStream(stream);
You can also use var image=System.Net.Mime.MediaTypeNames.Image.FromStream(stream); –
Nicknickel
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);
For phone this should work:
BitmapImage image = new BitmapImage();
image.SetSource(stream);
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.
© 2022 - 2024 — McMap. All rights reserved.
Bitmap
doesn't seem to be a valid type? is there a reference & using I should add? (im using Windos phone 7 by the way) – Garrettgarrick