]> granicus.if.org Git - imagemagick/blobdiff - coders/gradient.c
Check for sampling-factor option only if sampling-factor image property is NULL.
[imagemagick] / coders / gradient.c
index 814341891dc93c396ae59863425619a704ca3359..3104ae62381288be0c465e2b313f49039fa92a35 100644 (file)
@@ -40,6 +40,7 @@
   Include declarations.
 */
 #include "MagickCore/studio.h"
+#include "MagickCore/attribute.h"
 #include "MagickCore/blob.h"
 #include "MagickCore/blob-private.h"
 #include "MagickCore/color.h"
@@ -99,6 +100,7 @@ static Image *ReadGRADIENTImage(const ImageInfo *image_info,
     *image;
 
   MagickBooleanType
+    icc_color,
     status;
 
   PixelInfo
@@ -122,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)
     {
@@ -131,31 +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);
-    }
-  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);
-    }
   status=GradientImage(image,LocaleCompare(image_info->magick,"GRADIENT") == 0 ?
     LinearGradient : RadialGradient,PadSpread,&start_color,&stop_color,
     exception);
@@ -164,10 +158,7 @@ static Image *ReadGRADIENTImage(const ImageInfo *image_info,
       image=DestroyImageList(image);
       return((Image *) NULL);
     }
-  (void) SetImageColorspace(image,start_color.colorspace,exception);
-  if (IssRGBColorspace(start_color.colorspace) != MagickFalse)
-    (void) SetImageColorspace(image,RGBColorspace,exception);
-  if ((start_color.matte == MagickFalse) && (stop_color.matte == MagickFalse))
+  if ((start_color.alpha_trait != BlendPixelTrait) && (stop_color.alpha_trait != BlendPixelTrait))
     (void) SetImageAlphaChannel(image,DeactivateAlphaChannel,exception);
   return(GetFirstImageInList(image));
 }