]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Thu, 24 May 2012 18:14:16 +0000 (18:14 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Thu, 24 May 2012 18:14:16 +0000 (18:14 +0000)
coders/jp2.c

index ddd231ff959a27a3340faf4123f3107be0119e58..47a9fbaf66a2430da4c8f1a50aceb63a88fbcfc5 100644 (file)
@@ -402,10 +402,14 @@ static Image *ReadJP2Image(const ImageInfo *image_info,ExceptionInfo *exception)
       (void) jas_stream_close(jp2_stream);
       ThrowReaderException(DelegateError,"UnableToDecodeImageFile");
     }
+  image->columns=jas_image_width(jp2_image);
+  image->rows=jas_image_height(jp2_image);
+  image->compression=JPEG2000Compression;
   switch (jas_clrspc_fam(jas_image_clrspc(jp2_image)))
   {
     case JAS_CLRSPC_FAM_RGB:
     {
+      SetImageColorspace(image,RGBColorspace,exception);
       components[0]=jas_image_getcmptbytype(jp2_image,JAS_IMAGE_CT_RGB_R);
       components[1]=jas_image_getcmptbytype(jp2_image,JAS_IMAGE_CT_RGB_G);
       components[2]=jas_image_getcmptbytype(jp2_image,JAS_IMAGE_CT_RGB_B);
@@ -426,6 +430,7 @@ static Image *ReadJP2Image(const ImageInfo *image_info,ExceptionInfo *exception)
     }
     case JAS_CLRSPC_FAM_GRAY:
     {
+      SetImageColorspace(image,GRAYColorspace,exception);
       components[0]=jas_image_getcmptbytype(jp2_image,JAS_IMAGE_CT_GRAY_Y);
       if (components[0] < 0)
         {
@@ -438,6 +443,7 @@ static Image *ReadJP2Image(const ImageInfo *image_info,ExceptionInfo *exception)
     }
     case JAS_CLRSPC_FAM_YCBCR:
     {
+      SetImageColorspace(image,YCbCrColorspace,exception);
       components[0]=jas_image_getcmptbytype(jp2_image,JAS_IMAGE_CT_YCBCR_Y);
       components[1]=jas_image_getcmptbytype(jp2_image,JAS_IMAGE_CT_YCBCR_CB);
       components[2]=jas_image_getcmptbytype(jp2_image,JAS_IMAGE_CT_YCBCR_CR);
@@ -454,7 +460,6 @@ static Image *ReadJP2Image(const ImageInfo *image_info,ExceptionInfo *exception)
           image->matte=MagickTrue;
           number_components++;
         }
-      SetImageColorspace(image,YCbCrColorspace,exception);
       break;
     }
     default:
@@ -464,11 +469,6 @@ static Image *ReadJP2Image(const ImageInfo *image_info,ExceptionInfo *exception)
       ThrowReaderException(CoderError,"ColorspaceModelIsNotSupported");
     }
   }
-  image->columns=jas_image_width(jp2_image);
-  image->rows=jas_image_height(jp2_image);
-  image->compression=JPEG2000Compression;
-  if (number_components == 1)
-    SetImageColorspace(image,GRAYColorspace,exception);
   for (i=0; i < (ssize_t) number_components; i++)
   {
     size_t