如何将流转换为位图 [英] How to convert stream to bitmap
本文介绍了如何将流转换为位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试过转换但我不能......
我尝试过的事情:
Stream stream = new MemoryStream();
myImage.Save(stream,ImageFormat.Bmp);
result = stream;
解决方案
您的代码以位图格式将图像保存到流中。
要将包含支持的图像类型的流转换为位图,请使用 Image.FromStream方法(System.Drawing) [ ^ ]:
使用(图片图片= Image.FromStream(流))
{
// 成功后图像包含位图
// 并且可以保存到文件中:
image.Save(fileName);
}
给出的解决方案是在VB中。请使用C#等价物。
位图到内存流和反之亦然 [ ^ ]
i have tried to convert but i cant...
What I have tried:
Stream stream = new MemoryStream(); myImage.Save(stream, ImageFormat.Bmp); result = stream;
解决方案
Your code saves an image to a stream in bitmap format.
To convert a stream containing a supported image type to a bitmap, use the Image.FromStream Method (System.Drawing)[^]:
using (Image image = Image.FromStream(stream)) { // Upon success image contains the bitmap // and can be saved to a file: image.Save(fileName); }
The solution given is in VB.Please use C# equivalent.
Bitmap to Memory Stream and Vice Versa[^]
这篇关于如何将流转换为位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文