--- ImageMagick-6.1.3/coders/jp2.c_orig 2004-11-03 14:48:28.000000000 +0100 +++ ImageMagick-6.1.3/coders/jp2.c 2004-11-03 14:50:49.000000000 +0100 @@ -298,6 +298,8 @@ unsigned int channel_scale[4], + channel_step_x[4], + channel_step_y[4], maximum_component_depth; unsigned long @@ -407,18 +409,20 @@ image->rows=jas_image_height(jp2_image); for (i=0; i < (long) number_components; i++) { - if ((jas_image_cmptwidth(jp2_image,components[i]) != image->columns) || - (jas_image_cmptheight(jp2_image,components[i]) != image->rows) || + if (((jas_image_cmptwidth(jp2_image,components[i]) * + jas_image_cmpthstep(jp2_image,components[i])) != image->columns) || + ((jas_image_cmptheight(jp2_image,components[i]) * + jas_image_cmptvstep(jp2_image,components[i])) != image->rows) || (jas_image_cmpttlx(jp2_image,components[i]) != 0) || (jas_image_cmpttly(jp2_image,components[i]) != 0) || - (jas_image_cmpthstep(jp2_image,components[i]) != 1) || - (jas_image_cmptvstep(jp2_image,components[i]) != 1) || (jas_image_cmptsgnd(jp2_image,components[i]) != MagickFalse)) { (void) jas_stream_close(jp2_stream); jas_image_destroy(jp2_image); ThrowReaderException(CoderError,"IrregularChannelGeometryNotSupported"); } + channel_step_x[i] = jas_image_cmpthstep(jp2_image,components[i]); + channel_step_y[i] = jas_image_cmptvstep(jp2_image,components[i]); } /* Convert JPEG 2000 pixels. @@ -435,7 +439,7 @@ { maximum_component_depth=Max(jas_image_cmptprec(jp2_image,components[i]), maximum_component_depth); - pixels[i]=jas_matrix_create(1,(unsigned int) image->columns); + pixels[i]=jas_matrix_create(1,((unsigned int) image->columns)/channel_step_x[i]); if (pixels[i] == (jas_matrix_t *) NULL) { jas_image_destroy(jp2_image); @@ -467,7 +471,7 @@ break; for (i=0; i < (long) number_components; i++) (void) jas_image_readcmpt(jp2_image,(short) components[i],0, - (unsigned int) y,(unsigned int) image->columns,1,pixels[i]); + ((unsigned int) y)/channel_step_y[i],((unsigned int) image->columns)/channel_step_x[i],1,pixels[i]); switch (number_components) { case 1: @@ -494,7 +498,7 @@ else for (x=0; x < (long) image->columns; x++) { - index=(unsigned short) jas_matrix_getv(pixels[0],x)* + index=(unsigned short) jas_matrix_getv(pixels[0],(x/channel_step_x[0]))* channel_scale[0]; index=ConstrainColormapIndex(image,index); *indexes++=index; @@ -510,11 +514,11 @@ for (x=0; x < (long) image->columns; x++) { q->red=ScaleShortToQuantum((unsigned short) - jas_matrix_getv(pixels[0],x)*channel_scale[0]); + jas_matrix_getv(pixels[0],(x/channel_step_x[0]))*channel_scale[0]); q->green=ScaleShortToQuantum((unsigned short) - jas_matrix_getv(pixels[1],x)*channel_scale[1]); + jas_matrix_getv(pixels[1],(x/channel_step_x[1]))*channel_scale[1]); q->blue=ScaleShortToQuantum((unsigned short) - jas_matrix_getv(pixels[2],x)*channel_scale[2]); + jas_matrix_getv(pixels[2],(x/channel_step_x[2]))*channel_scale[2]); q++; } break; @@ -527,13 +531,13 @@ for (x=0; x < (long) image->columns; x++) { q->red=ScaleShortToQuantum((unsigned short) - jas_matrix_getv(pixels[0],x)*channel_scale[0]); + jas_matrix_getv(pixels[0],(x/channel_step_x[0]))*channel_scale[0]); q->green=ScaleShortToQuantum((unsigned short) - jas_matrix_getv(pixels[1],x)*channel_scale[1]); + jas_matrix_getv(pixels[1],(x/channel_step_x[1]))*channel_scale[1]); q->blue=ScaleShortToQuantum((unsigned short) - jas_matrix_getv(pixels[2],x)*channel_scale[2]); + jas_matrix_getv(pixels[2],(x/channel_step_x[2]))*channel_scale[2]); q->opacity=MaxRGB-ScaleShortToQuantum((unsigned short) - jas_matrix_getv(pixels[3],x)*channel_scale[3]); + jas_matrix_getv(pixels[3],(x/channel_step_x[3]))*channel_scale[3]); q++; } break;