From: Dirk Lemstra Date: Sat, 23 Mar 2019 14:48:23 +0000 (+0100) Subject: Fixed settings the area that should be decoded. X-Git-Tag: 7.0.8-35~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=82d7b441bdba7d24257caa33267d51a9f279cf15;p=imagemagick Fixed settings the area that should be decoded. --- diff --git a/coders/jp2.c b/coders/jp2.c index e74db30a6..79ddec8df 100644 --- a/coders/jp2.c +++ b/coders/jp2.c @@ -347,15 +347,19 @@ static Image *ReadJP2Image(const ImageInfo *image_info,ExceptionInfo *exception) ThrowReaderException(DelegateError,"UnableToDecodeImageFile"); } jp2_status=1; - if ((image->columns != 0) && (image->rows != 0)) + if (image->ping == MagickFalse) { - /* - Extract an area from the image. - */ - jp2_status=opj_set_decode_area(jp2_codec,jp2_image, - (OPJ_INT32) image->extract_info.x,(OPJ_INT32) image->extract_info.y, - (OPJ_INT32) (image->extract_info.x+(ssize_t) image->columns), - (OPJ_INT32) (image->extract_info.y+(ssize_t) image->rows)); + if ((image->columns != 0) && (image->rows != 0)) + /* + Extract an area from the image. + */ + jp2_status=opj_set_decode_area(jp2_codec,jp2_image, + (OPJ_INT32) image->extract_info.x,(OPJ_INT32) image->extract_info.y, + (OPJ_INT32) (image->extract_info.x+(ssize_t) image->columns), + (OPJ_INT32) (image->extract_info.y+(ssize_t) image->rows)); + else + jp2_status=opj_set_decode_area(jp2_codec,jp2_image,0,0, + jp2_image->comps[0].w-1,jp2_image->comps[0].h-1); if (jp2_status == 0) { opj_stream_destroy(jp2_stream); @@ -378,8 +382,6 @@ static Image *ReadJP2Image(const ImageInfo *image_info,ExceptionInfo *exception) else if (image->ping == MagickFalse) { - jp2_status=opj_set_decode_area(jp2_codec,jp2_image,0,0, - jp2_image->comps[0].w-1,jp2_image->comps[0].h-1); if (jp2_status != 0) jp2_status=opj_decode(jp2_codec,jp2_stream,jp2_image); if (jp2_status != 0)