从字节创建位图[] [英] Creating a bitmap from a byte[]
本文介绍了从字节创建位图[]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个字节[]
从我需要创建一个流创建一个位图图片
I have a byte[]
which create from a stream which i need to create a Bitmap image
我试图
MemoryStream ms = new MemoryStream(btarr);
Bitmap img = new Bitmap();
img=img.FromStream(ms);
即时确认 btarr
充满流的字节和有效的位图的内容,但是这始终提供IMG为空
..任何想法?
im sure that btarr
is filled with stream bytes and valid bitmap content , but this always provide the img as null
.. any idea?
推荐答案
这个方法将做的工作:
public static Bitmap BytesToBitmap(byte[] byteArray)
{
using (MemoryStream ms = new MemoryStream(byteArray))
{
Bitmap img = (Bitmap)Image.FromStream(ms);
return img;
}
}
这篇关于从字节创建位图[]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文