]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Thu, 12 Jul 2012 11:57:42 +0000 (11:57 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Thu, 12 Jul 2012 11:57:42 +0000 (11:57 +0000)
MagickCore/color.c
coders/gradient.c

index 5a566cf348e4faee04f8e43f2fbd788bf8dd76cc..5581a07a3d33c7c36dcbc2c8332dcbad6ba6b437 100644 (file)
@@ -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);
index 708556400d4628fefe8040ac6f19af4f05eb64d5..110de9e2c37daa848021bde75832b0bf0c893f11 100644 (file)
@@ -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));