case VERSION_2_24_BIT:
// no compression
bdata = new byte[width * height * 3];
read24Bit(bdata);
return new ImgRaw(width, height, 3, 8, bdata);
case VERSION_3_1_BIT:
// 1-bit images cannot be compressed.
return read1Bit(4);
case VERSION_3_4_BIT:
switch((int)compression) {
case BI_RGB:
return read4Bit(4);
case BI_RLE4:
return readRLE4();
default:
throw new
RuntimeException("Invalid compression specified for BMP file.");
}
case VERSION_3_8_BIT:
switch((int)compression) {
case BI_RGB:
return read8Bit(4);
case BI_RLE8:
return readRLE8();
default:
throw new
RuntimeException("Invalid compression specified for BMP file.");
}
case VERSION_3_24_BIT:
// 24-bit images are not compressed
bdata = new byte[width * height * 3];
read24Bit(bdata);
return new ImgRaw(width, height, 3, 8, bdata);
case VERSION_3_NT_16_BIT:
return read1632Bit(false);
case VERSION_3_NT_32_BIT:
return read1632Bit(true);
case VERSION_4_1_BIT:
return read1Bit(4);
case VERSION_4_4_BIT:
switch((int)compression) {
case BI_RGB:
return read4Bit(4);
case BI_RLE4:
return readRLE4();
default:
throw new
RuntimeException("Invalid compression specified for BMP file.");
}
case VERSION_4_8_BIT:
switch((int)compression) {
case BI_RGB:
return read8Bit(4);
case BI_RLE8:
return readRLE8();
default:
throw new
RuntimeException("Invalid compression specified for BMP file.");
}
case VERSION_4_16_BIT:
return read1632Bit(false);
case VERSION_4_24_BIT:
bdata = new byte[width * height * 3];
read24Bit(bdata);
return new ImgRaw(width, height, 3, 8, bdata);
case VERSION_4_32_BIT:
return read1632Bit(true);
}
return null;