From d88838447cb1085eb0b6b78007e7d5e1ce367b51 Mon Sep 17 00:00:00 2001 From: cristy Date: Wed, 7 Apr 2010 17:42:39 +0000 Subject: [PATCH] --- magick/profile.c | 212 ++++++++++++++++++++++++++--------------------- 1 file changed, 117 insertions(+), 95 deletions(-) diff --git a/magick/profile.c b/magick/profile.c index 864ea11b2..50b53c694 100644 --- a/magick/profile.c +++ b/magick/profile.c @@ -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; -- 2.50.1