22

如何将图像的 a (我使用 中的方法Stream检索到的)转换为可在我的应用程序中使用的图像?Album.GetArtMediaLibraryImage

4

4 回答 4

33

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

于 2013-08-08T19:20:43.300 回答
15

你可以从位图直接跑到图像的怀抱。

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

从那里您可以执行其他操作:

image.Save(System.IO.Path.GetPathRoot() + "\\Image.jpg", ImageFormat.Jpeg);
于 2013-08-09T00:07:24.763 回答
3

对于电话,这应该可以工作:

BitmapImage image = new BitmapImage();
image.SetSource(stream);
于 2013-08-09T00:00:19.657 回答
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.
于 2016-10-30T19:31:08.807 回答