How do you convert a byte array to a Bitmap instance (.NET)?

前端 未结 3 804
隐瞒了意图╮
隐瞒了意图╮ 2021-01-04 02:14

I am working with cameras (in this case monochrome) in VB.NET. The API of the cameras is in C++ and the manufacturer provides wrappers. As is typical in these cases, the ima

3条回答
  •  心在旅途
    2021-01-04 02:59

    Create a valid bitmap header, and preappend it to the byte array. You'll only need to manually create 56-128 bytes of data.

    Second, create a stream from a byte array.

    Next, create an image or bitmap class by using Image.FromStream()/Bitmap.FromStream()

    I wouldn't imagine that there is any sort of raw imaging features in .Net. There is so much needed information for an image, it would be an extremely lengthy parameter list for a method to accept raw bytes and create an imagine (is it a bitmap, jpeg, gif, png, etc, and all the additional data each of those requires to create a valid image) it wouldn't make sense.

提交回复
热议问题