]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Wed, 7 Apr 2010 17:42:39 +0000 (17:42 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Wed, 7 Apr 2010 17:42:39 +0000 (17:42 +0000)
magick/profile.c

index 864ea11b224d0f59929617aa24f1b2bb45b22cfb..50b53c6948938f3241bcb70a6695e07dbefe3571 100644 (file)
@@ -929,7 +929,8 @@ MagickExport MagickBooleanType ProfileImage(Image *image,const char *name,
         MissingDelegateWarning,"DelegateLibrarySupportNotBuiltIn","`%s' (LCMS)",
         image->filename);
 #else
-      if (icc_profile != (StringInfo *) NULL)
+      if ((icc_profile != (StringInfo *) NULL) ||
+          (cmsGetDeviceClass(profile) == cmsSigLinkClass))
         {
           CacheView
             *image_view;
@@ -975,6 +976,7 @@ MagickExport MagickBooleanType ProfileImage(Image *image,const char *name,
           /*
             Transform pixel colors as defined by the color profiles.
           */
+          exception=(&image->exception);
 #if defined(LCMS_VERSION) && (LCMS_VERSION >= 2000)
           cmsSetLogErrorHandler(LCMSErrorHandler);
 #endif
@@ -985,14 +987,29 @@ MagickExport MagickBooleanType ProfileImage(Image *image,const char *name,
           (void) cmsErrorAction(LCMS_ERROR_SHOW);
 #endif
 #endif
-          source_profile=cmsOpenProfileFromMem(GetStringInfoDatum(icc_profile),
-            (cmsUInt32Number) GetStringInfoLength(icc_profile));
-          target_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
-            (cmsUInt32Number) GetStringInfoLength(profile));
-          if ((source_profile == (cmsHPROFILE) NULL) ||
-              (target_profile == (cmsHPROFILE) NULL))
-            ThrowBinaryException(ResourceLimitError,
-              "ColorspaceColorProfileMismatch",name);
+          if (icc_profile == (StringInfo *) NULL)
+            {
+              /*
+                Device link profile, embeds source and target transforms.
+              */
+              source_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
+                (cmsUInt32Number) GetStringInfoLength(profile));
+              if (source_profile == (cmsHPROFILE) NULL)
+                ThrowBinaryException(ResourceLimitError,
+                  "ColorspaceColorProfileMismatch",name);
+            }
+          else
+            {
+              source_profile=cmsOpenProfileFromMem(
+                GetStringInfoDatum(icc_profile),(cmsUInt32Number)
+                GetStringInfoLength(icc_profile));
+              target_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
+                (cmsUInt32Number) GetStringInfoLength(profile));
+              if ((source_profile == (cmsHPROFILE) NULL) ||
+                  (target_profile == (cmsHPROFILE) NULL))
+                ThrowBinaryException(ResourceLimitError,
+                  "ColorspaceColorProfileMismatch",name);
+            }
           switch (cmsGetColorSpace(source_profile))
           {
             case cmsSigCmykData:
@@ -1052,94 +1069,99 @@ MagickExport MagickBooleanType ProfileImage(Image *image,const char *name,
               break;
             }
           }
-          switch (cmsGetColorSpace(target_profile))
-          {
-            case cmsSigCmykData:
-            {
-              target_colorspace=CMYKColorspace;
-              target_type=(cmsUInt32Number) TYPE_CMYK_16;
-              target_channels=4;
-              break;
-            }
-            case cmsSigLabData:
-            {
-              target_colorspace=LabColorspace;
-              target_type=(cmsUInt32Number) TYPE_Lab_16;
-              target_channels=3;
-              break;
-            }
-            case cmsSigGrayData:
-            {
-              target_colorspace=GRAYColorspace;
-              target_type=(cmsUInt32Number) TYPE_GRAY_16;
-              target_channels=1;
-              break;
-            }
-            case cmsSigLuvData:
-            {
-              target_colorspace=YUVColorspace;
-              target_type=(cmsUInt32Number) TYPE_YUV_16;
-              target_channels=3;
-              break;
-            }
-            case cmsSigRgbData:
-            {
-              target_colorspace=RGBColorspace;
-              target_type=(cmsUInt32Number) TYPE_RGB_16;
-              target_channels=3;
-              break;
-            }
-            case cmsSigXYZData:
-            {
-              target_colorspace=XYZColorspace;
-              target_type=(cmsUInt32Number) TYPE_XYZ_16;
-              target_channels=3;
-              break;
-            }
-            case cmsSigYCbCrData:
+          target_colorspace=source_colorspace;
+          target_type=source_type;
+          target_channels=source_channels;
+          if (target_profile != (cmsHPROFILE) NULL)
             {
-              target_colorspace=YCbCrColorspace;
-              target_type=(cmsUInt32Number) TYPE_YCbCr_16;
-              target_channels=3;
-              break;
-            }
-            default:
-            {
-              target_colorspace=UndefinedColorspace;
-              target_type=(cmsUInt32Number) TYPE_RGB_16;
-              target_channels=3;
-              break;
+              switch (cmsGetColorSpace(target_profile))
+              {
+                case cmsSigCmykData:
+                {
+                  target_colorspace=CMYKColorspace;
+                  target_type=(cmsUInt32Number) TYPE_CMYK_16;
+                  target_channels=4;
+                  break;
+                }
+                case cmsSigLabData:
+                {
+                  target_colorspace=LabColorspace;
+                  target_type=(cmsUInt32Number) TYPE_Lab_16;
+                  target_channels=3;
+                  break;
+                }
+                case cmsSigGrayData:
+                {
+                  target_colorspace=GRAYColorspace;
+                  target_type=(cmsUInt32Number) TYPE_GRAY_16;
+                  target_channels=1;
+                  break;
+                }
+                case cmsSigLuvData:
+                {
+                  target_colorspace=YUVColorspace;
+                  target_type=(cmsUInt32Number) TYPE_YUV_16;
+                  target_channels=3;
+                  break;
+                }
+                case cmsSigRgbData:
+                {
+                  target_colorspace=RGBColorspace;
+                  target_type=(cmsUInt32Number) TYPE_RGB_16;
+                  target_channels=3;
+                  break;
+                }
+                case cmsSigXYZData:
+                {
+                  target_colorspace=XYZColorspace;
+                  target_type=(cmsUInt32Number) TYPE_XYZ_16;
+                  target_channels=3;
+                  break;
+                }
+                case cmsSigYCbCrData:
+                {
+                  target_colorspace=YCbCrColorspace;
+                  target_type=(cmsUInt32Number) TYPE_YCbCr_16;
+                  target_channels=3;
+                  break;
+                }
+                default:
+                {
+                  target_colorspace=UndefinedColorspace;
+                  target_type=(cmsUInt32Number) TYPE_RGB_16;
+                  target_channels=3;
+                  break;
+                }
+              }
+              if ((source_colorspace == UndefinedColorspace) ||
+                  (target_colorspace == UndefinedColorspace))
+                ThrowProfileException(ImageError,
+                  "ColorspaceColorProfileMismatch",name);
+               if ((source_colorspace == GRAYColorspace) &&
+                   (IsGrayImage(image,exception) == MagickFalse))
+                ThrowProfileException(ImageError,
+                  "ColorspaceColorProfileMismatch",name);
+               if ((source_colorspace == CMYKColorspace) &&
+                   (image->colorspace != CMYKColorspace))
+                ThrowProfileException(ImageError,
+                  "ColorspaceColorProfileMismatch",name);
+               if ((source_colorspace == XYZColorspace) &&
+                   (image->colorspace != XYZColorspace))
+                ThrowProfileException(ImageError,
+                  "ColorspaceColorProfileMismatch",name);
+               if ((source_colorspace == YCbCrColorspace) &&
+                   (image->colorspace != YCbCrColorspace))
+                ThrowProfileException(ImageError,
+                  "ColorspaceColorProfileMismatch",name);
+               if ((source_colorspace != CMYKColorspace) &&
+                   (source_colorspace != GRAYColorspace) &&
+                   (source_colorspace != LabColorspace) &&
+                   (source_colorspace != XYZColorspace) &&
+                   (source_colorspace != YCbCrColorspace) &&
+                   (image->colorspace != RGBColorspace))
+                ThrowProfileException(ImageError,
+                  "ColorspaceColorProfileMismatch",name);
             }
-          }
-          exception=(&image->exception);
-          if ((source_colorspace == UndefinedColorspace) ||
-              (target_colorspace == UndefinedColorspace))
-            ThrowProfileException(ImageError,"ColorspaceColorProfileMismatch",
-              name);
-           if ((source_colorspace == GRAYColorspace) &&
-               (IsGrayImage(image,exception) == MagickFalse))
-            ThrowProfileException(ImageError,"ColorspaceColorProfileMismatch",
-              name);
-           if ((source_colorspace == CMYKColorspace) &&
-               (image->colorspace != CMYKColorspace))
-            ThrowProfileException(ImageError,"ColorspaceColorProfileMismatch",
-              name);
-           if ((source_colorspace == XYZColorspace) &&
-               (image->colorspace != XYZColorspace))
-            ThrowProfileException(ImageError,"ColorspaceColorProfileMismatch",
-              name);
-           if ((source_colorspace == YCbCrColorspace) &&
-               (image->colorspace != YCbCrColorspace))
-            ThrowProfileException(ImageError,"ColorspaceColorProfileMismatch",
-              name);
-           if ((source_colorspace != CMYKColorspace) &&
-               (source_colorspace != GRAYColorspace) &&
-               (source_colorspace != LabColorspace) &&
-               (source_colorspace != XYZColorspace) &&
-               (source_colorspace != YCbCrColorspace) &&
-               (image->colorspace != RGBColorspace))
-            ThrowProfileException(ImageError,"ColorspaceColorProfileMismatch",
-              name);
           switch (image->rendering_intent)
           {
             case AbsoluteIntent: intent=INTENT_ABSOLUTE_COLORIMETRIC; break;