0

I am trying to convert a byte array to an image. There are many references on the web to do so such as this SO post and this emgu forum and emgu official docs.

However I am getting an error when I implement the solutions according to the SO post and the Emgu docs that reads

Cannot convert from System.Drawing.Bitmap to byte[*,*,*,*]

public Image<Bgr, Byte> CreateImageFromBytesArray(byte[] bytes)
{
    using (var ms = new MemoryStream(bytes))
    {
        Bitmap bmp = new Bitmap(ms);
        Image<Bgr, Byte> img = new Image<Bgr, Byte>(bmp); //EXCEPTION HERE
        return img;
    }
}

Any suggestions on how to make this work?

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
RyeGuy
  • 4,213
  • 10
  • 33
  • 57

1 Answers1

2
public Image<Bgr, Byte> CreateImageFromBytesArray(byte[] bytes)
{
    Image<Bgr, Byte> image = new Image<Bgr, Byte>(width, height);
    image.Bytes = bytes
    return image;
}
Nikhil Dinesh
  • 3,359
  • 2
  • 38
  • 41