convert binary to bitmap using memory stream

前端 未结 3 975
执念已碎
执念已碎 2020-12-10 04:19

Hi I wanna convert binary array to bitmap and show image in a picturebox. I wrote the following code but I got exception that says that the parameter is not val

3条回答
  •  情书的邮戳
    2020-12-10 05:02

    Don't dispose of the MemoryStream. It now belongs to the image object and will be disposed when you dispose the image.

    Also consider doing it like this

    var ms = new MemoryStream(blob);
    var img = Image.FromStream(ms);
    .....
    img.Dispose(); //once you are done with the image.
    

提交回复
热议问题