From bbdf0cfd41c8ec46a7ebfe2d22668c45976b3a39 Mon Sep 17 00:00:00 2001 From: cristy Date: Thu, 12 Jul 2012 11:57:42 +0000 Subject: [PATCH] --- MagickCore/color.c | 7 ++++++- coders/gradient.c | 36 ++++++++++++------------------------ 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/MagickCore/color.c b/MagickCore/color.c index 5a566cf34..5581a07a3 100644 --- a/MagickCore/color.c +++ b/MagickCore/color.c @@ -2275,6 +2275,9 @@ MagickExport MagickBooleanType QueryColorCompliance(const char *name, char colorspace[MaxTextExtent]; + MagickBooleanType + icc_color; + /* Parse color of the form rgb(100,255,0). */ @@ -2284,6 +2287,7 @@ MagickExport MagickBooleanType QueryColorCompliance(const char *name, break; colorspace[i--]='\0'; scale=(MagickRealType) ScaleCharToQuantum(1); + icc_color=MagickFalse; if (LocaleCompare(colorspace,"icc-color") == 0) { register ssize_t @@ -2296,6 +2300,7 @@ MagickExport MagickBooleanType QueryColorCompliance(const char *name, colorspace[j--]='\0'; i+=j+3; scale=(MagickRealType) QuantumRange; + icc_color=MagickTrue; } LocaleLower(colorspace); color->matte=MagickFalse; @@ -2312,7 +2317,7 @@ MagickExport MagickBooleanType QueryColorCompliance(const char *name, return(MagickFalse); } color->colorspace=(ColorspaceType) type; - if (color->colorspace == RGBColorspace) + if ((icc_color == MagickFalse) && (color->colorspace == RGBColorspace)) color->colorspace=sRGBColorspace; /* as required by SVG standard */ SetGeometryInfo(&geometry_info); flags=ParseGeometry(name+i+1,&geometry_info); diff --git a/coders/gradient.c b/coders/gradient.c index 708556400..110de9e2c 100644 --- a/coders/gradient.c +++ b/coders/gradient.c @@ -100,6 +100,7 @@ static Image *ReadGRADIENTImage(const ImageInfo *image_info, *image; MagickBooleanType + icc_color, status; PixelInfo @@ -123,6 +124,13 @@ static Image *ReadGRADIENTImage(const ImageInfo *image_info, (void) CopyMagickString(image->filename,image_info->filename,MaxTextExtent); (void) CopyMagickString(colorname,image_info->filename,MaxTextExtent); (void) sscanf(image_info->filename,"%[^-]",colorname); + icc_color=MagickFalse; + if (LocaleCompare(colorname,"icc") == 0) + { + (void) ConcatenateMagickString(colorname,"-",MaxTextExtent); + (void) sscanf(image_info->filename,"%*[^-]-%[^-]",colorname+4); + icc_color=MagickTrue; + } status=QueryColorCompliance(colorname,AllCompliance,&start_color,exception); if (status == MagickFalse) { @@ -132,33 +140,16 @@ static Image *ReadGRADIENTImage(const ImageInfo *image_info, (void) CopyMagickString(colorname,"white",MaxTextExtent); if (GetPixelInfoIntensity(&start_color) > (Quantum) (QuantumRange/2)) (void) CopyMagickString(colorname,"black",MaxTextExtent); - (void) sscanf(image_info->filename,"%*[^-]-%s",colorname); + if (icc_color == MagickFalse) + (void) sscanf(image_info->filename,"%*[^-]-%s",colorname); + else + (void) sscanf(image_info->filename,"%*[^-]-%*[^-]-%s",colorname); status=QueryColorCompliance(colorname,AllCompliance,&stop_color,exception); if (status == MagickFalse) { image=DestroyImage(image); return((Image *) NULL); } - if (IssRGBColorspace(start_color.colorspace) != MagickFalse) - { - start_color.red=QuantumRange*DecompandsRGB(QuantumScale* - start_color.red); - start_color.green=QuantumRange*DecompandsRGB(QuantumScale* - start_color.green); - start_color.blue=QuantumRange*DecompandsRGB(QuantumScale* - start_color.blue); - start_color.colorspace=RGBColorspace; - } - if (IssRGBColorspace(stop_color.colorspace) != MagickFalse) - { - stop_color.red=QuantumRange*DecompandsRGB(QuantumScale* - stop_color.red); - stop_color.green=QuantumRange*DecompandsRGB(QuantumScale* - stop_color.green); - stop_color.blue=QuantumRange*DecompandsRGB(QuantumScale* - stop_color.blue); - stop_color.colorspace=RGBColorspace; - } status=GradientImage(image,LocaleCompare(image_info->magick,"GRADIENT") == 0 ? LinearGradient : RadialGradient,PadSpread,&start_color,&stop_color, exception); @@ -168,9 +159,6 @@ static Image *ReadGRADIENTImage(const ImageInfo *image_info, return((Image *) NULL); } (void) SetImageColorspace(image,start_color.colorspace,exception); - if ((IsPixelInfoGray(&start_color) != MagickFalse) && - (IsPixelInfoGray(&stop_color) != MagickFalse)) - (void) SetImageColorspace(image,GRAYColorspace,exception); if ((start_color.matte == MagickFalse) && (stop_color.matte == MagickFalse)) (void) SetImageAlphaChannel(image,DeactivateAlphaChannel,exception); return(GetFirstImageInList(image)); -- 2.50.1