v7 JPEG 2K generation problem
Posted: 2014-01-12T07:38:38-07:00
I think there is an error in JPEG 2K generation in current trunk version. Generated image is without colors and only one third of it is displayed
The problem is in generation of component data in WriteJP2Image function. After each pixel is generated pointer to next pixel is incremented by one,
but this will bring in only to next Quantum of already processed Pixel. I think this pointer has to be incremented by number of channels in image. Something like this gives me correct results:
But I do not know if this is correct solution.
The problem is in generation of component data in WriteJP2Image function. After each pixel is generated pointer to next pixel is incremented by one,
Code: Select all
for (x=0; x < (ssize_t) image->columns; x++)
{
for (i=0; i < (ssize_t) channels; i++)
{
double
scale;
register int
*q;
scale=(double) ((1UL << jp2_image->comps[i].prec)-1)/QuantumRange;
q=jp2_image->comps[i].data+(y/jp2_image->comps[i].dy*
image->columns/jp2_image->comps[i].dx+x/jp2_image->comps[i].dx);
switch (i)
{
case 0:
{
if (jp2_colorspace == OPJ_CLRSPC_GRAY)
{
*q=(int) (scale*GetPixelLuma(image,p));
break;
}
*q=(int) (scale*GetPixelRed(image,p));
break;
}
case 1:
{
if (jp2_colorspace == OPJ_CLRSPC_GRAY)
{
*q=(int) (scale*GetPixelAlpha(image,p));
break;
}
*q=(int) (scale*GetPixelGreen(image,p));
break;
}
case 2:
{
*q=(int) (scale*GetPixelBlue(image,p));
break;
}
case 3:
{
*q=(int) (scale*GetPixelAlpha(image,p));
break;
}
}
}
p++;
}
Code: Select all
for (x=0; x < (ssize_t) image->columns; x++)
{
for (i=0; i < (ssize_t) channels; i++)
{
double
scale;
register int
*q;
scale=(double) ((1UL << jp2_image->comps[i].prec)-1)/QuantumRange;
q=jp2_image->comps[i].data+(y/jp2_image->comps[i].dy*
image->columns/jp2_image->comps[i].dx+x/jp2_image->comps[i].dx);
switch (i)
{
case 0:
{
if (jp2_colorspace == OPJ_CLRSPC_GRAY)
{
*q=(int) (scale*GetPixelLuma(image,p));
break;
}
*q=(int) (scale*GetPixelRed(image,p));
break;
}
case 1:
{
if (jp2_colorspace == OPJ_CLRSPC_GRAY)
{
*q=(int) (scale*GetPixelAlpha(image,p));
break;
}
*q=(int) (scale*GetPixelGreen(image,p));
break;
}
case 2:
{
*q=(int) (scale*GetPixelBlue(image,p));
break;
}
case 3:
{
*q=(int) (scale*GetPixelAlpha(image,p));
break;
}
}
}
p += channels;
}