libsdl-org / SDL_image

Image decoding for many popular formats for Simple Directmedia Layer.
zlib License
559 stars 182 forks source link

Return CMYK JPEGs in RGBA32 surface #410

Open s09bQ5 opened 8 months ago

s09bQ5 commented 8 months ago

When libjpeg is used to decode JPEG files, every image with 4 components is decoded as CMYK data into a BGRA surface. But the de-facto standard for CMYK in JPEG is to invert the color components. So instead of C, M, Y, and K the stored values are 255-C, 255-M, 255-Y, and 255-K. Since lack of cyan is red, lack of magenta is green and lack of yellow is blue, the picture is basically RGBA over a black background. I therefore suggest to use an RGBA32 surface instead of a BGRA32 surface for 4 component JPEG images.

For testing this file can be used: https://static.universal-music.de/asset_new/6890/195/view/cascada-whatdoyouwant-cover-300cmykjpg.jpg