更新时间:2022-11-08 21:59:40
该函数将字节数组转换为位图可以是用来设置图像的图片框的
属性。
This function converts byte array into Bitmap which can be use to set the Image
Property of the picturebox.
public static Bitmap ByteToImage(byte[] blob)
{
MemoryStream mStream = new MemoryStream();
byte[] pData = blob;
mStream.Write(pData, 0, Convert.ToInt32(pData.Length));
Bitmap bm = new Bitmap(mStream, false);
mStream.Dispose();
return bm;
}
使用范例:
pictureBox.Image = ByteToImage(byteArr); // byteArr holds byte array value