EmguCV从字节数组读取8位图像

时间:2019-02-12 00:08:24

标签: c# opencv emgucv binary-data color-palette

我有一个字节数组,其中包含PNG8的数据(调色板和颜色索引)。我需要从我的字节数组创建Image(或至少是Bitmap)。我对PNG24或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;
    default:
        return new Bitmap(width, height);
}

但是如何读取PNG8数据?如果我执行类似的操作,则会出错。我知道,如何在没有 EmguCV的情况下执行此操作,但是我想知道,我可以在 EmpguCV的情况下执行此操作吗?预先感谢。

0 个答案:

没有答案