From: Cristy Date: Fri, 2 Jun 2017 18:50:35 +0000 (-0400) Subject: Add support for 'hex:' property X-Git-Tag: 7.0.5-10~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=38ebc02e617e66d460a522266dcb662a44c665d2;p=imagemagick Add support for 'hex:' property --- diff --git a/ChangeLog b/ChangeLog index 6399e709f..fc7f6a220 100644 --- 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 * Release ImageMagick version 7.0.5-9, GIT revision 20113:8b67333:20170528. diff --git a/MagickCore/color.c b/MagickCore/color.c index 0993c6b65..5f938c8ed 100644 --- a/MagickCore/color.c +++ b/MagickCore/color.c @@ -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); diff --git a/MagickCore/property.c b/MagickCore/property.c index d95f214b1..4434c9c5e 100644 --- a/MagickCore/property.c +++ b/MagickCore/property.c @@ -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;