From: cristy Date: Wed, 7 Mar 2012 00:27:29 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~6068 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5f257b2f02bdd982d9bbfe612f5bb1711608590c;p=imagemagick --- diff --git a/MagickCore/channel.c b/MagickCore/channel.c index c0a244836..7fd7cd69a 100644 --- a/MagickCore/channel.c +++ b/MagickCore/channel.c @@ -57,15 +57,15 @@ % % % % % % -% C h a n n e l O p e r a t i o n I m a g e % +% C h a n n e l F x I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% ChannelOperationImage() applies a channel expression to the specified image. -% The expression consists of one or more channels, either mnemonic or numeric -% (e.g. red, 1), separated by certain operation symbols as follows: +% ChannelFxImage() applies a channel expression to the specified image. The +% expression consists of one or more channels, either mnemonic or numeric (e.g. +% red, 1), separated by actions as follows: % % <=> exchange two channels (e.g. red<=>blue) % => transfer a channel to another (e.g. red=>green) @@ -76,12 +76,12 @@ % A channel without a operation symbol implies extract. For example, to create % 3 grayscale images from the red, green, and blue channels of an image, use: % -% -channel-ops "red; green; blue" +% -channel-fx "red; green; blue" % -% The format of the ChannelOperationImage method is: +% The format of the ChannelFxImage method is: % -% Image *ChannelOperationImage(const Image *image, -% const char *expression,ExceptionInfo *exception) +% Image *ChannelFxImage(const Image *image,const char *expression, +% ExceptionInfo *exception) % % A description of each parameter follows: % @@ -98,7 +98,7 @@ typedef enum ExtractChannelOp, ExchangeChannelOp, TransferChannelOp -} ChannelOperation; +} ChannelFx; static inline size_t MagickMin(const size_t x,const size_t y) { @@ -108,7 +108,7 @@ static inline size_t MagickMin(const size_t x,const size_t y) } static MagickBooleanType ChannelImage(Image *destination_image, - const Image *source_image,const ChannelOperation channel_op, + const Image *source_image,const ChannelFx channel_op, const PixelChannel source_channel,const PixelChannel destination_channel, ExceptionInfo *exception) { @@ -186,15 +186,15 @@ static MagickBooleanType ChannelImage(Image *destination_image, return(status); } -MagickExport Image *ChannelOperationImage(const Image *image, - const char *expression,ExceptionInfo *exception) +MagickExport Image *ChannelFxImage(const Image *image,const char *expression, + ExceptionInfo *exception) { -#define ChannelOperationImageTag "ChannelOperation/Image" +#define ChannelFxImageTag "ChannelFx/Image" char token[MaxTextExtent]; - ChannelOperation + ChannelFx channel_op; const char @@ -328,7 +328,7 @@ MagickExport Image *ChannelOperationImage(const Image *image, break; } channels++; - status=SetImageProgress(source_image,ChannelOperationImageTag,p-expression, + status=SetImageProgress(source_image,ChannelFxImageTag,p-expression, strlen(expression)); if (status == MagickFalse) break; diff --git a/MagickCore/channel.h b/MagickCore/channel.h index bb3e89dde..46cb11b88 100644 --- a/MagickCore/channel.h +++ b/MagickCore/channel.h @@ -23,7 +23,7 @@ extern "C" { #endif extern MagickExport Image - *ChannelOperationImage(const Image *,const char *,ExceptionInfo *), + *ChannelFxImage(const Image *,const char *,ExceptionInfo *), *CombineImages(const Image *,ExceptionInfo *), *SeparateImage(const Image *,const ChannelType,ExceptionInfo *), *SeparateImages(const Image *,ExceptionInfo *); diff --git a/MagickCore/option.c b/MagickCore/option.c index 2cf9a915b..449818d58 100644 --- a/MagickCore/option.c +++ b/MagickCore/option.c @@ -241,8 +241,8 @@ static const OptionInfo { "-cdl", 1L, SimpleOperatorOptionFlag, MagickFalse }, { "+channel", 0L, ImageInfoOptionFlag | SimpleOperatorOptionFlag, MagickFalse }, { "-channel", 1L, ImageInfoOptionFlag | SimpleOperatorOptionFlag, MagickFalse }, - { "+channel-ops", 0L, ListOperatorOptionFlag | FireOptionFlag, MagickFalse }, - { "-channel-ops", 0L, ListOperatorOptionFlag | FireOptionFlag, MagickFalse }, + { "+channel-fx", 0L, ListOperatorOptionFlag | FireOptionFlag, MagickFalse }, + { "-channel-fx", 0L, ListOperatorOptionFlag | FireOptionFlag, MagickFalse }, { "+charcoal", 0L, DeprecateOptionFlag, MagickTrue }, { "-charcoal", 0L, SimpleOperatorOptionFlag, MagickFalse }, { "+chop", 1L, DeprecateOptionFlag, MagickTrue }, diff --git a/MagickCore/xwindow.c b/MagickCore/xwindow.c index 99bad6718..fdde2b5f7 100644 --- a/MagickCore/xwindow.c +++ b/MagickCore/xwindow.c @@ -4542,6 +4542,7 @@ static Image *XGetWindowImage(Display *display,const Window window, y_offset=0; (void) CompositeImage(image,CopyCompositeOp,composite_image,(ssize_t) x_offset,(ssize_t) y_offset,exception); + composite_image=DestroyImage(composite_image); } /* Relinquish resources. diff --git a/MagickWand/convert.c b/MagickWand/convert.c index a4df5c7cd..fdb6e3398 100644 --- a/MagickWand/convert.c +++ b/MagickWand/convert.c @@ -137,7 +137,7 @@ static MagickBooleanType ConvertUsage(void) static const char *channel_operators[]= { - "-channel-ops expression", + "-channel-fx expression", " exchange, extract, or transfer one or more image channels", (char *) NULL }, @@ -885,7 +885,7 @@ WandExport MagickBooleanType ConvertImageCommand(ImageInfo *image_info, argv[i]); break; } - if (LocaleCompare("channel-ops",option+1) == 0) + if (LocaleCompare("channel-fx",option+1) == 0) { ssize_t channel; diff --git a/MagickWand/magick-image.c b/MagickWand/magick-image.c index ef258a3e1..3a0fb6842 100644 --- a/MagickWand/magick-image.c +++ b/MagickWand/magick-image.c @@ -1059,6 +1059,61 @@ WandExport MagickBooleanType MagickBrightnessContrastImage( % % % % % % +% M a g i c k C h a n n e l F x I m a g e % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% MagickChannelFxImage() applies a channel expression to the specified image. +% The expression consists of one or more channels, either mnemonic or numeric +% (e.g. red, 1), separated by actions as follows: +% +% <=> exchange two channels (e.g. red<=>blue) +% => transfer a channel to another (e.g. red=>green) +% , separate channel operations (e.g. red, green) +% | read channels from next input image (e.g. red | green) +% ; write channels to next output image (e.g. red; green; blue) +% +% A channel without a operation symbol implies extract. For example, to create +% 3 grayscale images from the red, green, and blue channels of an image, use: +% +% -channel-fx "red; green; blue" +% +% The format of the MagickChannelFxImage method is: +% +% MagickWand *MagickChannelFxImage(MagickWand *wand,const char *expression) +% +% A description of each parameter follows: +% +% o wand: the magick wand. +% +% o expression: the expression. +% +*/ +WandExport MagickWand *MagickChannelFxImage(MagickWand *wand, + const char *expression) +{ + Image + *fx_image; + + assert(wand != (MagickWand *) NULL); + assert(wand->signature == WandSignature); + if (wand->debug != MagickFalse) + (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); + if (wand->images == (Image *) NULL) + return((MagickWand *) NULL); + fx_image=ChannelFxImage(wand->images,expression,wand->exception); + if (fx_image == (Image *) NULL) + return((MagickWand *) NULL); + return(CloneMagickWandFromImages(wand,fx_image)); +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % % M a g i c k C h a r c o a l I m a g e % % % % % diff --git a/MagickWand/magick-image.h b/MagickWand/magick-image.h index 3a1ea38a1..23e699bdf 100644 --- a/MagickWand/magick-image.h +++ b/MagickWand/magick-image.h @@ -321,6 +321,7 @@ WandExport MagickProgressMonitor extern WandExport MagickWand *MagickAppendImages(MagickWand *,const MagickBooleanType), + *MagickChannelFxImage(MagickWand *,const char *), *MagickCoalesceImages(MagickWand *), *MagickCombineImages(MagickWand *), *MagickCompareImages(MagickWand *,const MagickWand *,const MetricType, diff --git a/MagickWand/mogrify.c b/MagickWand/mogrify.c index 2ffbc07ac..9f8fb40cd 100644 --- a/MagickWand/mogrify.c +++ b/MagickWand/mogrify.c @@ -3257,7 +3257,7 @@ static MagickBooleanType MogrifyUsage(void) static const char *channel_operators[]= { - "-channel-ops expression", + "-channel-fx expression", " exchange, extract, or transfer one or more image channels", (char *) NULL }, @@ -4033,7 +4033,7 @@ WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, argv[i]); break; } - if (LocaleCompare("channel-ops",option+1) == 0) + if (LocaleCompare("channel-fx",option+1) == 0) { ssize_t channel; @@ -7343,13 +7343,13 @@ WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, } case 'c': { - if (LocaleCompare("channel-ops",option+1) == 0) + if (LocaleCompare("channel-fx",option+1) == 0) { Image *channel_image; (void) SyncImagesSettings(mogrify_info,*images,exception); - channel_image=ChannelOperationImage(*images,argv[i+1],exception); + channel_image=ChannelFxImage(*images,argv[i+1],exception); if (channel_image == (Image *) NULL) { status=MagickFalse; diff --git a/MagickWand/operation.c b/MagickWand/operation.c index aa4188888..4a30a5081 100644 --- a/MagickWand/operation.c +++ b/MagickWand/operation.c @@ -3535,9 +3535,9 @@ WandExport void CLIListOperatorImages(MagickCLI *cli_wand, } case 'c': { - if (LocaleCompare("channel-ops",option+1) == 0) + if (LocaleCompare("channel-fx",option+1) == 0) { - new_images=ChannelOperationImage(images,arg1,exception); + new_images=ChannelFxImage(images,arg1,exception); break; } if (LocaleCompare("clut",option+1) == 0) diff --git a/PerlMagick/Magick.xs b/PerlMagick/Magick.xs index 8b52cfca4..4fcdd6f35 100644 --- a/PerlMagick/Magick.xs +++ b/PerlMagick/Magick.xs @@ -2849,6 +2849,169 @@ BlobToImage(ref,...) # # # # # # +# C h a n n e l F x # +# # +# # +# # +############################################################################### +# +# +void +ChannelFx(ref,...) + Image::Magick ref=NO_INIT + ALIAS: + ChannelFxImage = 1 + channelfx = 2 + channelfximage = 3 + PPCODE: + { + AV + *av; + + char + *attribute, + expression[MaxTextExtent]; + + ChannelType + channel, + channel_mask; + + ExceptionInfo + *exception; + + HV + *hv; + + Image + *image; + + register ssize_t + i; + + struct PackageInfo + *info; + + SV + *av_reference, + *perl_exception, + *reference, + *rv, + *sv; + + PERL_UNUSED_VAR(ref); + PERL_UNUSED_VAR(ix); + exception=AcquireExceptionInfo(); + perl_exception=newSVpv("",0); + sv=NULL; + attribute=NULL; + av=NULL; + if (sv_isobject(ST(0)) == 0) + { + ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", + PackageName); + goto PerlException; + } + reference=SvRV(ST(0)); + hv=SvSTASH(reference); + av=newAV(); + av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv)); + SvREFCNT_dec(av); + image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); + if (image == (Image *) NULL) + { + ThrowPerlException(exception,OptionError,"NoImagesDefined", + PackageName); + goto PerlException; + } + info=GetPackageInfo(aTHX_ (void *) av,info,exception); + /* + Get options. + */ + channel=DefaultChannels; + (void) CopyMagickString(expression,"u",MaxTextExtent); + if (items == 2) + (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent); + else + for (i=2; i < items; i+=2) + { + attribute=(char *) SvPV(ST(i-1),na); + switch (*attribute) + { + case 'C': + case 'c': + { + if (LocaleCompare(attribute,"channel") == 0) + { + ssize_t + option; + + option=ParseChannelOption(SvPV(ST(i),na)); + if (option < 0) + { + ThrowPerlException(exception,OptionError, + "UnrecognizedType",SvPV(ST(i),na)); + return; + } + channel=(ChannelType) option; + break; + } + ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", + attribute); + break; + } + case 'E': + case 'e': + { + if (LocaleCompare(attribute,"expression") == 0) + { + (void) CopyMagickString(expression,SvPV(ST(i),na), + MaxTextExtent); + break; + } + ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", + attribute); + break; + } + default: + { + ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", + attribute); + break; + } + } + } + channel_mask=SetPixelChannelMask(image,channel); + image=ChannelFxImage(image,expression,exception); + if (image != (Image *) NULL) + (void) SetPixelChannelMask(image,channel_mask); + if (image == (Image *) NULL) + goto PerlException; + for ( ; image; image=image->next) + { + AddImageToRegistry(sv,image); + rv=newRV(sv); + av_push(av,sv_bless(rv,hv)); + SvREFCNT_dec(sv); + } + exception=DestroyExceptionInfo(exception); + ST(0)=av_reference; + SvREFCNT_dec(perl_exception); /* can't return warning messages */ + XSRETURN(1); + + PerlException: + InheritPerlException(exception,perl_exception); + exception=DestroyExceptionInfo(exception); + sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0); + SvPOK_on(perl_exception); + ST(0)=sv_2mortal(perl_exception); + XSRETURN(1); + } + +# +############################################################################### +# # +# # +# # # C l o n e # # # # #