EmguCV read 8 bit image from byte array


February 2019


13 time


I have a byte array which contains the data of PNG8 (Color palette and indexes of colors). I need to create Image (or at least simply Bitmap) from my byte array. I haven't problems with PNG24 or PNG32:

byte type;
int height, width;
byte[] data;

// Initializing type, height, width and data with BinaryReader

switch (type)
    case 24:
        Image<Rgb, byte> image24 = new Image<Rgb, byte>(width, height)
            Bytes = data
        return image24.Bitmap;
    case 32:
        Image<Rgba, byte> image32 = new Image<Rgba, byte>(width, height)
            Bytes = data
        return image32.Bitmap;
        return new Bitmap(width, height);

But how can I read PNG8 data? If I make similar actions, I get an errors. I know, how can I doing this without EmguCV, but I would like to know, can I doing this with EmguCV? Thanks in advance.

0 answers