且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将图像中的图片框从C#中的byte []

更新时间: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