]> granicus.if.org Git - imagemagick/commitdiff
Add support for 'hex:' property
authorCristy <urban-warrior@imagemagick.org>
Fri, 2 Jun 2017 18:50:35 +0000 (14:50 -0400)
committerCristy <urban-warrior@imagemagick.org>
Fri, 2 Jun 2017 18:50:35 +0000 (14:50 -0400)
ChangeLog
MagickCore/color.c
MagickCore/property.c

index 6399e709f4728fcc5fdd54545daf3bd89926d226..fc7f6a220a14c05dd56e60aea9d2319ee6fe9fd4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,7 @@
     https://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=32071).
   * The +opaque option is not longer a noop (reference
     https://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=32081).
+  * Add support  for 'hex:' property.
 
 2017-05-28  7.0.5-9 Cristy  <quetzlzacatenango@image...>
   * Release ImageMagick version 7.0.5-9, GIT revision 20113:8b67333:20170528.
index 0993c6b653961bbc892ca546b975fd9503c7b46d..5f938c8ed81abb8a5b439c55ddee4c1746ddc63e 100644 (file)
@@ -1583,7 +1583,7 @@ MagickExport void GetColorTuple(const PixelInfo *pixel,
     Convert pixel to rgb() or cmyk() color.
   */
   color=(*pixel);
-  if (color.depth > 8 && IsSVGCompliant(pixel) != MagickFalse)
+  if ((color.depth > 8) && (IsSVGCompliant(pixel) != MagickFalse))
     color.depth=8;
   (void) ConcatenateMagickString(tuple,CommandOptionToMnemonic(
     MagickColorspaceOptions,(ssize_t) color.colorspace),MagickPathExtent);
index d95f214b1deffbe9c5fb7a6016c4eac158335c6d..4434c9c5ec79b383ad51dd49ee512c91c35fd03b 100644 (file)
@@ -3600,14 +3600,70 @@ RestoreMSCWarning
             }
           continue;
         }
-      if (LocaleNCompare("pixel:",pattern,6) == 0)
+      if (LocaleNCompare("hex:",pattern,4) == 0)
         {
+          double
+            value;
+
           FxInfo
             *fx_info;
 
+          MagickStatusType
+            status;
+
+          PixelInfo
+            pixel;
+
+          /*
+            Pixel - color value calculator.
+          */
+          if (image == (Image *) NULL)
+            {
+              (void) ThrowMagickException(exception,GetMagickModule(),
+                OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
+              continue; /* else no image to retrieve artifact */
+            }
+          GetPixelInfo(image,&pixel);
+          fx_info=AcquireFxInfo(image,pattern+6,exception);
+          status=FxEvaluateChannelExpression(fx_info,RedPixelChannel,0,0,
+            &value,exception);
+          pixel.red=(double) QuantumRange*value;
+          status&=FxEvaluateChannelExpression(fx_info,GreenPixelChannel,0,0,
+            &value,exception);
+          pixel.green=(double) QuantumRange*value;
+          status&=FxEvaluateChannelExpression(fx_info,BluePixelChannel,0,0,
+            &value,exception);
+          pixel.blue=(double) QuantumRange*value;
+          if (image->colorspace == CMYKColorspace)
+            {
+              status&=FxEvaluateChannelExpression(fx_info,BlackPixelChannel,0,0,
+                &value,exception);
+              pixel.black=(double) QuantumRange*value;
+            }
+          status&=FxEvaluateChannelExpression(fx_info,AlphaPixelChannel,0,0,
+            &value,exception);
+          pixel.alpha=(double) QuantumRange*value;
+          fx_info=DestroyFxInfo(fx_info);
+          if (status != MagickFalse)
+            {
+              char
+                hex[MagickPathExtent],
+                name[MagickPathExtent];
+
+              (void) QueryColorname(image,&pixel,SVGCompliance,name,exception);
+              GetColorTuple(&pixel,MagickTrue,hex);
+              AppendString2Text(hex);
+            }
+          continue;
+        }
+      if (LocaleNCompare("pixel:",pattern,6) == 0)
+        {
           double
             value;
 
+          FxInfo
+            *fx_info;
+
           MagickStatusType
             status;
 
@@ -3649,8 +3705,7 @@ RestoreMSCWarning
               char
                 name[MagickPathExtent];
 
-              (void) QueryColorname(image,&pixel,SVGCompliance,name,
-                exception);
+              (void) QueryColorname(image,&pixel,SVGCompliance,name,exception);
               AppendString2Text(name);
             }
           continue;