The code in line 1475 of jp2.c (V2, revison 2223) simply is wrong.
'jp2->meth = 2;' is true only if an ICC profile exists:
meth = 2;
ICC profile follows
To add 'enumcs = 0;' is nonsense.
'jp2->meth = 1' is true only if NO ICC profile exists:
meth = 1;
enumcs = (OPJ_CLRSPC_SRGB | OPJ_CLRSPC_GRAY | OPJ_CLRSPC_SYCC)
If your file does not have an ICC profile, 'meth = 1;' is correct.
If you WRITE a file, you know that you want to add an ICC profile.
You set meth to 2 and add the ICC profile.
If you READ a file, you do not know that the file has an ICC profile.
The following lines are from jp2.c of openjpeg-1.5.x:
void jp2_setup_encoder()
{
jp2->meth = 1;
if (image->color_space == 1)
jp2->enumcs = 16; /* sRGB as defined by IEC 61966-2.1 */
else if (image->color_space == 2)
jp2->enumcs = 17; /* greyscale */
else if (image->color_space == 3)
jp2->enumcs = 18;
}
winfried
----- Original Nachricht ----
Von: Will K <
willk...@gmail.com>
An:
open...@googlegroups.com
Datum: 18.11.2012 17:57
Betreff: Re: [OpenJPEG] Writing JP2 openjpegv2, Colour specification box, ICC
profile issue with greater than 3 bands
> Sorry I gave the wrong line number. The line is 2161. It code looks like
> this:
>
> if ((image->numcomps == 1 || image->numcomps == 3) && (jp2->bpc != 255)) {
> jp2->meth = 1; /* METH: Enumerated colourspace */
> } else {
> jp2->meth = 2; /* METH: Restricted ICC profile */
> }
> if (jp2->meth == 1) {
> if (image->color_space == 1)
> jp2->enumcs = 16; /* sRGB as defined by IEC 61966?2?1 */
> else if (image->color_space == 2)
> jp2->enumcs = 17; /* greyscale */
> else if (image->color_space == 3)
> jp2->enumcs = 18; /* YUV */
> } else {
> jp2->enumcs = 0; /* PROFILE (??) */
> }
>
> Anyway, when numComps is greater than 3 jp2->meth gets set to 2. Later in
>
> the code the Meth 2 should write an ICC Profile, but it writes out a 0
> instead. I think it is best to not set meth 2 unless a real ICC profile is
>
> going to actually be written. I don't now the actual requirement about 4
> band imagery, but the ECW and Photoshop JP2 readers do not seem to care if
> the ICC profile is there.
>
> On Friday, November 16, 2012 8:48:26 PM UTC-6,
szuk...@arcor.de wrote:
>
> > I downloaded the latest OpenJPEG v2 revision 2223 and did not find 'meth'
>
> > in the lines
> > given.
> >
> > winfried