mansoor-ahmed / openjpeg

Automatically exported from code.google.com/p/openjpeg
Other
0 stars 0 forks source link

JP2 Color Space modification by Matteo Italia #13

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello all,

I propose a small improvement for the /OPJ_COLOR_SPACE/ enum: when
reading a jp2 file, the /color_space/ member of the /opj_image/
structure is correctly set to one of the supported color spaces or
/CLRSPC_UNKNOWN/ if it's one of the color modes that is not supported by
the library.
On the other hand, when reading a j2k file (which, as far as I know,
doesn't contain any color space information), the /color_space/ field is
set to 0 as a consequence of the initial zeroing that happens when the
/opj_image/ object is allocated, since, after that moment, that field is
left untouched by the j2k decoder.
What I propose is to make official this behavior, and add to the
/COLOR_SPACE/ enum the member /CLRSPC_UNSPECIFIED = 0/. In this way a
library user that use common code to decode j2k and jp2 files can
reliably distinguish if the color space is not specified by the file (so
guessing is ok, since there is no other option) or if it is unsupported
by the library: when absolute fidelity to the original file is required,
in this last case failing may be a better choice than guessing.
The modify is really simple: just change the enum (file openjpeg.h, line
147) in this way:

/**

Supported image color spaces

*/

typedef enum COLOR_SPACE {

    CLRSPC_UNKNOWN = -1,    /**< not supported by the library */

    CLRSPC_UNSPECIFIED = 0,        /** < not specified in the file */

    CLRSPC_SRGB = 1,        /**< sRGB */

    CLRSPC_GRAY = 2,        /**< grayscale */

    CLRSPC_SYCC = 3            /**< YUV */

} OPJ_COLOR_SPACE;

By the way, is OpenJPEG supposed to support also the ICC mode of jp2 in
the near future?

Regards,
Matteo Italia 

Original issue reported on code.google.com by fodev...@gmail.com on 20 Jan 2010 at 3:04

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Issue solved with revisions 542 and 543
http://code.google.com/p/openjpeg/source/detail?r=542
http://code.google.com/p/openjpeg/source/detail?r=543

Original comment by fodev...@gmail.com on 20 Jan 2010 at 3:49