IMAGES: Added comments describing use case for CMYK color space format

This commit is contained in:
Paweł Kołodziejski
2022-07-05 21:33:03 +02:00
committed by Eugene Sandulenko
parent 078199cd69
commit de03b0de95
+10 -1
View File
@@ -271,8 +271,13 @@ bool JPEGDecoder::loadStream(Common::SeekableReadStream &stream) {
break;
}
if (cinfo.num_components == 4)
// Semi-hack:
// In case 4 components jpeglib expect CMYK or CYYK color space output.
// To avoid any color space conversion, CMYK must be used.
// HPL1 engine use it to pass RGBA jpeg bitmaps.
if (cinfo.num_components == 4) {
cinfo.out_color_space = JCS_CMYK;
}
// Actually start decompressing the image
jpeg_start_decompress(&cinfo);
@@ -297,6 +302,10 @@ bool JPEGDecoder::loadStream(Common::SeekableReadStream &stream) {
default:
break;
}
// Size of output pixel must match 4 bytes.
if (cinfo.out_color_space == JCS_CMYK) {
assert(_surface.format.bytesPerPixel == 4);
}
// Allocate buffer for one scanline
JDIMENSION pitch = cinfo.output_width * _surface.format.bytesPerPixel;