From a5b77cb053298b1858d15725d23f348498c6baf6 Mon Sep 17 00:00:00 2001 From: cristy Date: Fri, 7 May 2010 19:34:48 +0000 Subject: [PATCH] --- ChangeLog | 1 + PerlMagick/Magick.xs | 15 ++++++++ magick/image.c | 87 ++++++++++++++++++++++++++++++++++++++++++++ magick/image.h | 1 + wand/magick-image.c | 45 +++++++++++++++++++++++ wand/magick-image.h | 1 + 6 files changed, 150 insertions(+) diff --git a/ChangeLog b/ChangeLog index f52c46f53..756182714 100644 --- a/ChangeLog +++ b/ChangeLog @@ -55,6 +55,7 @@ Anthony). * Register / unregister CALS format in static.c (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=16103). + * Add SetImageColor() method. 2010-04-17 6.6.1-5 Cristy * Only write one ICC profile to PSD image. diff --git a/PerlMagick/Magick.xs b/PerlMagick/Magick.xs index cd378e247..b3f7f419f 100644 --- a/PerlMagick/Magick.xs +++ b/PerlMagick/Magick.xs @@ -531,6 +531,7 @@ static struct {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions}, {"iterations", IntegerReference} } }, { "ColorMatrix", { {"matrix", ArrayReference} } }, + { "Color", { {"color", StringReference} } } }; static SplayTreeInfo @@ -7187,6 +7188,8 @@ Mogrify(ref,...) MorphologyImage = 266 ColorMatrix = 267 ColorMatrixImage = 268 + Color = 269 + ColorImage = 270 MogrifyRegion = 666 PPCODE: { @@ -10503,6 +10506,18 @@ Mogrify(ref,...) color_matrix=(double *) RelinquishMagickMemory(color_matrix); break; } + case 135: /* Color */ + { + MagickPixelPacket + color; + + (void) QueryMagickColor("none",&color,exception); + if (attribute_flag[0] != 0) + (void) QueryMagickColor(argument_list[0].string_reference, + &color,exception); + (void) SetImageColor(image,&color); + break; + } } if (next != (Image *) NULL) (void) CatchImageException(next); diff --git a/magick/image.c b/magick/image.c index 4a1876b94..393834759 100644 --- a/magick/image.c +++ b/magick/image.c @@ -2792,6 +2792,93 @@ MagickExport MagickBooleanType SetImageBackgroundColor(Image *image) % % % % % % +% S e t I m a g e C o l o r % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% SetImageColor() set the entire image canvas to the specified color. +% +% The format of the SetImageColor method is: +% +% MagickBooleanType SetImageColor(Image *image, +% const MagickPixelPacket *color) +% +% A description of each parameter follows: +% +% o image: the image. +% +% o background: the image color. +% +*/ +MagickExport MagickBooleanType SetImageColor(Image *image, + const MagickPixelPacket *color) +{ + CacheView + *image_view; + + ExceptionInfo + *exception; + + long + y; + + MagickBooleanType + status; + + assert(image != (Image *) NULL); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); + assert(image->signature == MagickSignature); + assert(color != (const MagickPixelPacket *) NULL); + image->colorspace=color->colorspace; + image->matte=color->matte; + image->fuzz=color->fuzz; + image->depth=color->depth; + status=MagickTrue; + exception=(&image->exception); + image_view=AcquireCacheView(image); +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp parallel for schedule(dynamic,4) shared(status) +#endif + for (y=0; y < (long) image->rows; y++) + { + register IndexPacket + *restrict indexes; + + register long + x; + + register PixelPacket + *restrict q; + + if (status == MagickFalse) + continue; + q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception); + if (q == (PixelPacket *) NULL) + { + status=MagickFalse; + continue; + } + indexes=GetCacheViewAuthenticIndexQueue(image_view); + for (x=0; x < (long) image->columns; x++) + { + SetPixelPacket(image,color,q,indexes+x); + q++; + } + if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) + status=MagickFalse; + } + image_view=DestroyCacheView(image_view); + return(status); +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % % S e t I m a g e S t o r a g e C l a s s % % % % % diff --git a/magick/image.h b/magick/image.h index 414334666..d373149cd 100644 --- a/magick/image.h +++ b/magick/image.h @@ -524,6 +524,7 @@ extern MagickExport MagickBooleanType SetImageAlphaChannel(Image *,const AlphaChannelType), SetImageBackgroundColor(Image *), SetImageClipMask(Image *,const Image *), + SetImageColor(Image *,const MagickPixelPacket *), SetImageExtent(Image *,const unsigned long,const unsigned long), SetImageInfo(ImageInfo *,const unsigned int,ExceptionInfo *), SetImageMask(Image *,const Image *), diff --git a/wand/magick-image.c b/wand/magick-image.c index 3851da041..eccbb51ae 100644 --- a/wand/magick-image.c +++ b/wand/magick-image.c @@ -9651,6 +9651,51 @@ WandExport MagickBooleanType MagickSetImageClipMask(MagickWand *wand, % % % % % % +% M a g i c k S e t I m a g e C o l o r % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% MagickSetImageColor() set the entire wand canvas to the specified color. +% +% The format of the MagickSetImageColor method is: +% +% MagickBooleanType MagickSetImageColor(MagickWand *wand, +% const PixelWand *color) +% +% A description of each parameter follows: +% +% o wand: the magick wand. +% +% o background: the image color. +% +*/ +WandExport MagickBooleanType MagickSetImageColor(MagickWand *wand, + const PixelWand *color) +{ + MagickBooleanType + status; + + MagickPixelPacket + pixel; + + assert(wand != (MagickWand *) NULL); + assert(wand->signature == WandSignature); + if (wand->debug != MagickFalse) + (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); + PixelGetMagickColor(color,&pixel); + status=SetImageColor(wand->images,&pixel); + if (status == MagickFalse) + InheritException(wand->exception,&wand->images->exception); + return(status); +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % % M a g i c k S e t I m a g e C o l o r m a p C o l o r % % % % % diff --git a/wand/magick-image.h b/wand/magick-image.h index 833279c29..207f7500f 100644 --- a/wand/magick-image.h +++ b/wand/magick-image.h @@ -288,6 +288,7 @@ extern WandExport MagickBooleanType MagickSetImageChannelDepth(MagickWand *,const ChannelType, const unsigned long), MagickSetImageClipMask(MagickWand *,const MagickWand *), + MagickSetImageColor(MagickWand *,const PixelWand *), MagickSetImageColormapColor(MagickWand *,const unsigned long, const PixelWand *), MagickSetImageColorspace(MagickWand *,const ColorspaceType), -- 2.40.0