From ee0f8d709b9c794587068462fc627d6543c259ba Mon Sep 17 00:00:00 2001 From: cristy Date: Sat, 19 Sep 2009 00:58:29 +0000 Subject: [PATCH] --- PerlMagick/Magick.xs | 25 +++++++++++++++++++++++++ magick/enhance.c | 12 ++++++------ magick/enhance.h | 2 +- wand/convert.c | 2 +- wand/mogrify.c | 14 +++++++------- 5 files changed, 40 insertions(+), 15 deletions(-) diff --git a/PerlMagick/Magick.xs b/PerlMagick/Magick.xs index 779d3a45d..ca28ca675 100644 --- a/PerlMagick/Magick.xs +++ b/PerlMagick/Magick.xs @@ -516,6 +516,9 @@ static struct {"color-correction-collection", StringReference} } }, { "AutoGamma", { {"channel", MagickChannelOptions} } }, { "AutoLevel", { {"channel", MagickChannelOptions} } }, + { "LevelColors", { {"invert", MagickBooleanOptions}, + {"black-point", RealReference}, {"white-point", RealReference}, + {"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } }, }; static SplayTreeInfo @@ -6759,6 +6762,8 @@ Mogrify(ref,...) AutoGammaImage = 254 AutoLevel = 255 AutoLevelImage = 256 + LevelColors = 257 + LevelColorsImage = 258 MogrifyRegion = 666 PPCODE: { @@ -9939,6 +9944,26 @@ Mogrify(ref,...) (void) AutoLevelImageChannel(image,channel); break; } + case 129: /* LevelColors */ + { + MagickPixelPacket + black_point, + white_point; + + (void) QueryMagickColor("#000000",&black_point,exception); + (void) QueryMagickColor("#ffffff",&black_point,exception); + if (attribute_flag[1] != 0) + (void) QueryMagickColor(argument_list[1].string_reference, + &black_point,exception); + if (attribute_flag[2] != 0) + (void) QueryMagickColor(argument_list[2].string_reference, + &white_point,exception); + if (attribute_flag[3] != 0) + channel=(ChannelType) argument_list[3].long_reference; + (void) LevelImageColors(image,channel,&black_point,&white_point, + argument_list[0].long_reference != 0 ? MagickTrue : MagickFalse); + break; + } } if (next != (Image *) NULL) (void) CatchImageException(next); diff --git a/magick/enhance.c b/magick/enhance.c index 3e90c65aa..5f90e6643 100644 --- a/magick/enhance.c +++ b/magick/enhance.c @@ -2718,9 +2718,9 @@ MagickExport MagickBooleanType LevelizeImageChannel(Image *image, % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% LevelImageColor() will map the given color to "black" and "white" -% values, limearly spreading out the colors, and level values on a channel by -% channel bases, as per LevelImage(). The given colors allows you to specify +% LevelImageColor() maps the given color to "black" and "white" values, +% linearly spreading out the colors, and level values on a channel by channel +% bases, as per LevelImage(). The given colors allows you to specify % different level ranges for each of the color channels seperatally. % % If the boolean 'invert' is set true the image values will modifyed in the @@ -2731,9 +2731,9 @@ MagickExport MagickBooleanType LevelizeImageChannel(Image *image, % % The format of the LevelImageColors method is: % -% MagickBooleanType LevelImageColors(Image *image,const ChannelType channel, -% const MagickPixelPacket *black_color,const MagickPixelPacket *white_color, -% const MagickBooleanType invert) +% MagickBooleanType LevelImageColors(Image *image,const ChannelType channel, +% const MagickPixelPacket *black_color, +% const MagickPixelPacket *white_color,const MagickBooleanType invert) % % A description of each parameter follows: % diff --git a/magick/enhance.h b/magick/enhance.h index a2ca92ec2..f2759e829 100644 --- a/magick/enhance.h +++ b/magick/enhance.h @@ -46,7 +46,7 @@ extern MagickExport MagickBooleanType LevelizeImageChannel(Image *,const ChannelType,const double,const double, const double), LevelImageColors(Image *,const ChannelType,const MagickPixelPacket *, - const MagickPixelPacket *, const MagickBooleanType), + const MagickPixelPacket *,const MagickBooleanType), LinearStretchImage(Image *,const double,const double), ModulateImage(Image *,const char *), NegateImage(Image *,const MagickBooleanType), diff --git a/wand/convert.c b/wand/convert.c index f6332628d..aad7de920 100644 --- a/wand/convert.c +++ b/wand/convert.c @@ -208,7 +208,7 @@ static MagickBooleanType ConvertUsage(void) "-layers method optimize, merge, or compare image layers", "-level value adjust the level of image contrast", "-level-colors color,color", - " level image using given colors", + " level image with the given colors", "-linear-stretch geometry", " improve contrast by `stretching with saturation'", "-liquid-rescale geometry", diff --git a/wand/mogrify.c b/wand/mogrify.c index 0a39345fd..c12bf9c44 100644 --- a/wand/mogrify.c +++ b/wand/mogrify.c @@ -1860,25 +1860,25 @@ WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, p=(const char *) argv[i+1]; GetMagickToken(p,&p,token); /* get black point color */ - if (isalpha((int) token[0]) || (token[0] == '#')) + if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) (void) QueryMagickColor(token,&black_point,exception); else - (void) QueryMagickColor("black",&black_point,exception); + (void) QueryMagickColor("#000000",&black_point,exception); if (isalpha((int) token[0]) || (token[0] == '#')) GetMagickToken(p,&p,token); - if (token[0] == '\0') + if (*token == '\0') white_point=black_point; /* set everything to that color */ else { /* Get white point color. */ - if (!(isalpha((int) token[0]) || (token[0] == '#'))) + if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) GetMagickToken(p,&p,token); - if ((isalpha((int) token[0]) || (token[0] == '#'))) + if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) (void) QueryMagickColor(token,&white_point,exception); else - (void) QueryMagickColor("white",&white_point,exception); + (void) QueryMagickColor("#ffffff",&white_point,exception); } (void) LevelImageColors(*image,channel,&black_point,&white_point, *option == '+' ? MagickTrue : MagickFalse); @@ -3496,7 +3496,7 @@ static MagickBooleanType MogrifyUsage(void) "-layers method optimize, merge, or compare image layers", "-level value adjust the level of image contrast", "-level-colors color,color", - " level image using given colors", + " level image with the given colors", "-linear-stretch geometry", " improve contrast by `stretching with saturation'", "-liquid-rescale geometry", -- 2.40.0