]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Wed, 7 Mar 2012 00:27:29 +0000 (00:27 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Wed, 7 Mar 2012 00:27:29 +0000 (00:27 +0000)
MagickCore/channel.c
MagickCore/channel.h
MagickCore/option.c
MagickCore/xwindow.c
MagickWand/convert.c
MagickWand/magick-image.c
MagickWand/magick-image.h
MagickWand/mogrify.c
MagickWand/operation.c
PerlMagick/Magick.xs

index c0a244836f6b130bc76bd4d7a45d3deee3cccdb2..7fd7cd69a172a210f915a22718c907eaaf0b433c 100644 (file)
 %                                                                             %
 %                                                                             %
 %                                                                             %
-%     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:
 %
@@ -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;
index bb3e89dded8144ae3edb1168dd3cd5bf69c9cae5..46cb11b885b27c30530f62380548dae25c6c313e 100644 (file)
@@ -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 *);
index 2cf9a915bea89440fc90595a2e00ea237c8feff0..449818d58677a221634cfd45d4be3bb8e2b9d4c5 100644 (file)
@@ -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 },
index 99bad6718778e5754f0012b11d6c2e210e009f49..fdde2b5f76d337f7715ab9b609c5d629761de73d 100644 (file)
@@ -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.
index a4df5c7cd2d21dfdd80f265e673420258d298e07..fdb6e33982b36509b2185aac70730376d7590f93 100644 (file)
@@ -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;
index ef258a3e178bb42904984a48bfea81ff480e0f65..3a0fb6842fb00bf008adda036f154ed64230c2f2 100644 (file)
@@ -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));
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
 %   M a g i c k C h a r c o a l I m a g e                                     %
 %                                                                             %
 %                                                                             %
index 3a1ea38a127e3e553d45ae366cf078d0e6da3607..23e699bdfd11832daa021b76951778d7b2e17d1c 100644 (file)
@@ -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,
index 2ffbc07ac8f6fa16011d5c38ad762508916ed8d9..9f8fb40cd769e1759819bec683ef003254758110 100644 (file)
@@ -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;
index aa41888887d949c95e5c29fba6d9473966decdc8..4a30a5081592d2ab77b89dea401deccee201ddb2 100644 (file)
@@ -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)
index 8b52cfca450c07945e81a3ae25459cda66dc1c6a..4fcdd6f350994a63f9f67a94f75c962bdb0fea09 100644 (file)
@@ -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);
+  }
+\f
+#
+###############################################################################
+#                                                                             #
+#                                                                             #
+#                                                                             #
 #   C l o n e                                                                 #
 #                                                                             #
 #                                                                             #