[OpenJDK 2D-Dev] JPEG native lib / enum / colour space long-standing bug?

Roman Kennke roman at kennke.org
Tue May 15 20:00:36 UTC 2012

Hi Damon,

> Is anyone reading this list who is in a position to tell me if I'm even wrong?  B^>

>From reading the snippets you posted here:


I think you are right, RGBA and beyond is not possible using the
jpeglib.h that is included in OpenJDK.

However, looking at the same file of the libjpeg included in my Linux
distro, I see this:

typedef enum {
        JCS_UNKNOWN,            /* error/unspecified */
        JCS_GRAYSCALE,          /* monochrome */
        JCS_RGB,                /* red/green/blue as specified by the
                                   RGB_BLUE, and RGB_PIXELSIZE macros */
        JCS_YCbCr,              /* Y/Cb/Cr (also known as YUV) */
        JCS_CMYK,               /* C/M/Y/K */
        JCS_YCCK,               /* Y/Cb/Cr/K */
        JCS_EXT_RGB,            /* red/green/blue */
        JCS_EXT_RGBX,           /* red/green/blue/x */
        JCS_EXT_BGR,            /* blue/green/red */
        JCS_EXT_BGRX,           /* blue/green/red/x */
        JCS_EXT_XBGR,           /* x/blue/green/red */
        JCS_EXT_XRGB,           /* x/red/green/blue */
        /* When out_color_space it set to JCS_EXT_RGBX, JCS_EXT_BGRX,
           JCS_EXT_XBGR, or JCS_EXT_XRGB during decompression, the X
byte is
           undefined, and in order to ensure the best performance,
           libjpeg-turbo can set that byte to whatever value it wishes.
           the following colorspace constants to ensure that the X byte
is set
           to 0xFF, so that it can be interpreted as an opaque alpha
           channel. */
        JCS_EXT_RGBA,           /* red/green/blue/alpha */
        JCS_EXT_BGRA,           /* blue/green/red/alpha */
        JCS_EXT_ABGR,           /* alpha/blue/green/red */
        JCS_EXT_ARGB            /* alpha/red/green/blue */

It looks like a lot of color spaces have been added in the meantime. :-)
I believe the problems you mention should be possible to resolve by
upgrading the shipped libjpeg. (Or, even better, use the system
installed libjpeg as IcedTea does, and fix the colorspace verification
code to include the extended color spaces.)


More information about the 2d-dev mailing list