]> granicus.if.org Git - imagemagick/blobdiff - coders/gradient.c
(no commit message)
[imagemagick] / coders / gradient.c
index 2dcfdb97e8e59e1538f457f695b3f6cda29f68b4..03c927b41011fb79d197c587cb7fe4c41aaae013 100644 (file)
@@ -17,7 +17,7 @@
 %                                 July 1992                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization      %
 %  dedicated to making software imaging solutions freely available.           %
 %                                                                             %
 %  You may not use this file except in compliance with the License.  You may  %
 /*
   Include declarations.
 */
-#include "magick/studio.h"
-#include "magick/blob.h"
-#include "magick/blob-private.h"
-#include "magick/color.h"
-#include "magick/color-private.h"
-#include "magick/draw.h"
-#include "magick/exception.h"
-#include "magick/exception-private.h"
-#include "magick/image.h"
-#include "magick/image-private.h"
-#include "magick/list.h"
-#include "magick/magick.h"
-#include "magick/memory_.h"
-#include "magick/paint.h"
-#include "magick/pixel-private.h"
-#include "magick/quantum-private.h"
-#include "magick/static.h"
-#include "magick/string_.h"
-#include "magick/module.h"
-#include "magick/studio.h"
+#include "MagickCore/studio.h"
+#include "MagickCore/blob.h"
+#include "MagickCore/blob-private.h"
+#include "MagickCore/color.h"
+#include "MagickCore/color-private.h"
+#include "MagickCore/colorspace-private.h"
+#include "MagickCore/draw.h"
+#include "MagickCore/exception.h"
+#include "MagickCore/exception-private.h"
+#include "MagickCore/image.h"
+#include "MagickCore/image-private.h"
+#include "MagickCore/list.h"
+#include "MagickCore/magick.h"
+#include "MagickCore/memory_.h"
+#include "MagickCore/paint.h"
+#include "MagickCore/pixel-accessor.h"
+#include "MagickCore/quantum-private.h"
+#include "MagickCore/static.h"
+#include "MagickCore/string_.h"
+#include "MagickCore/module.h"
+#include "MagickCore/studio.h"
 \f
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -94,13 +95,16 @@ static Image *ReadGRADIENTImage(const ImageInfo *image_info,
   char
     colorname[MaxTextExtent];
 
-  PixelPacket
-    start_color,
-    stop_color;
-
   Image
     *image;
 
+  MagickBooleanType
+    status;
+
+  PixelInfo
+    start_color,
+    stop_color;
+
   /*
     Initialize Image structure.
   */
@@ -111,29 +115,63 @@ static Image *ReadGRADIENTImage(const ImageInfo *image_info,
       image_info->filename);
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
-  image=AcquireImage(image_info);
+  image=AcquireImage(image_info,exception);
   if ((image->columns == 0) || (image->rows == 0))
     ThrowReaderException(OptionError,"MustSpecifyImageSize");
-  (void) SetImageOpacity(image,(Quantum) TransparentOpacity);
+  (void) SetImageAlpha(image,(Quantum) TransparentAlpha,exception);
   (void) CopyMagickString(image->filename,image_info->filename,MaxTextExtent);
   (void) CopyMagickString(colorname,image_info->filename,MaxTextExtent);
   (void) sscanf(image_info->filename,"%[^-]",colorname);
-  if (QueryColorDatabase(colorname,&start_color,exception) == MagickFalse)
+  status=QueryColorCompliance(colorname,AllCompliance,&start_color,exception);
+  if (status == MagickFalse)
     {
       image=DestroyImage(image);
       return((Image *) NULL);
     }
   (void) CopyMagickString(colorname,"white",MaxTextExtent);
-  if (PixelIntensityToQuantum(&start_color) > (Quantum) (QuantumRange/2))
+  if (GetPixelInfoIntensity(&start_color) > (Quantum) (QuantumRange/2))
     (void) CopyMagickString(colorname,"black",MaxTextExtent);
   (void) sscanf(image_info->filename,"%*[^-]-%s",colorname);
-  if (QueryColorDatabase(colorname,&stop_color,exception) == MagickFalse)
+  status=QueryColorCompliance(colorname,AllCompliance,&stop_color,exception);
+  if (status == MagickFalse)
     {
       image=DestroyImage(image);
       return((Image *) NULL);
     }
-  (void) GradientImage(image,LocaleCompare(image_info->magick,"GRADIENT") == 0 ?
-    LinearGradient : RadialGradient,PadSpread,&start_color,&stop_color);
+  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);
+  if (status == MagickFalse)
+    {
+      image=DestroyImageList(image);
+      return((Image *) NULL);
+    }
+  (void) SetImageColorspace(image,start_color.colorspace,exception);
+  if ((start_color.matte == MagickFalse) && (stop_color.matte == MagickFalse))
+    (void) SetImageAlphaChannel(image,DeactivateAlphaChannel,exception);
+  if (IssRGBColorspace(start_color.colorspace) != MagickFalse)
+    {
+      (void) SetImageColorspace(image,RGBColorspace,exception);
+      (void) TransformImageColorspace(image,sRGBColorspace,exception);
+    }
   return(GetFirstImageInList(image));
 }
 \f