% %
% %
% %
-% 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)
% 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:
%
ExtractChannelOp,
ExchangeChannelOp,
TransferChannelOp
-} ChannelOperation;
+} ChannelFx;
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)
{
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
break;
}
channels++;
- status=SetImageProgress(source_image,ChannelOperationImageTag,p-expression,
+ status=SetImageProgress(source_image,ChannelFxImageTag,p-expression,
strlen(expression));
if (status == MagickFalse)
break;
#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 *);
{ "-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 },
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.
static const char
*channel_operators[]=
{
- "-channel-ops expression",
+ "-channel-fx expression",
" exchange, extract, or transfer one or more image channels",
(char *) NULL
},
argv[i]);
break;
}
- if (LocaleCompare("channel-ops",option+1) == 0)
+ if (LocaleCompare("channel-fx",option+1) == 0)
{
ssize_t
channel;
% %
% %
% %
+% 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));
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
% M a g i c k C h a r c o a l I m a g e %
% %
% %
extern WandExport MagickWand
*MagickAppendImages(MagickWand *,const MagickBooleanType),
+ *MagickChannelFxImage(MagickWand *,const char *),
*MagickCoalesceImages(MagickWand *),
*MagickCombineImages(MagickWand *),
*MagickCompareImages(MagickWand *,const MagickWand *,const MetricType,
static const char
*channel_operators[]=
{
- "-channel-ops expression",
+ "-channel-fx expression",
" exchange, extract, or transfer one or more image channels",
(char *) NULL
},
argv[i]);
break;
}
- if (LocaleCompare("channel-ops",option+1) == 0)
+ if (LocaleCompare("channel-fx",option+1) == 0)
{
ssize_t
channel;
}
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;
}
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)
# #
# #
# #
+# 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);
+ }
+\f
+#
+###############################################################################
+# #
+# #
+# #
# C l o n e #
# #
# #