]> granicus.if.org Git - imagemagick/commitdiff
Add MagickCompositeLayers() to MagickWand
authoranthony <anthony@git.imagemagick.org>
Sat, 17 Mar 2012 12:22:34 +0000 (12:22 +0000)
committeranthony <anthony@git.imagemagick.org>
Sat, 17 Mar 2012 12:22:34 +0000 (12:22 +0000)
MagickCore/layer.c
MagickWand/magick-image.c
MagickWand/magick-image.h

index 946309ffee953a14dcc3293e9602f77bbe50b2b4..8386273b4cf0f186afcc588980f4633f44b46008 100644 (file)
@@ -1706,34 +1706,38 @@ MagickExport void RemoveZeroDelayLayers(Image **images,
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  CompositeLayers() compose first image sequence (source) over the second
-%  image sequence (destination), using the given compose method and offsets.
+%  CompositeLayers() compose the source image sequence over the destination
+%  image sequence, starting with the current image in both lists.
 %
-%  The pointers to the image list does not have to be the start of that image
-%  list, but may start somewhere in the middle.  Each layer from the two image
-%  lists are composted together until the end of one of the image lists is
-%  reached.  The offset of each composition is also adjusted to match the
-%  virtual canvas offsets of each layer. As such the given offset is relative
-%  to the virtual canvas, and not the actual image.
+%  Each layer from the two image lists are composted together until the end of
+%  one of the image lists is reached.  The offset of each composition is also
+%  adjusted to match the virtual canvas offsets of each layer. As such the
+%  given offset is relative to the virtual canvas, and not the actual image.
 %
-%  No GIF disposal handling is performed, so GIF animations should be
-%  coalesced before use.  However this not a requirement, and individual
-%  layer images may have any size or offset, for special compositions.
+%  Composition uses given x and y offsets, as the 'origin' location of the
+%  source images virtual canvas (not the real image) allowing you to compose a
+%  list of 'layer images' into the destiantioni images.  This makes it well
+%  sutiable for directly composing 'Clears Frame Animations' or 'Coaleased
+%  Animations' onto a static or other 'Coaleased Animation' destination image
+%  list.  GIF disposal handling is not looked at.
 %
-%  Special case:- If one of the image sequences is just a single image that
-%  image is repeatally composed with all the images in the other image list.
-%  Either the source or destination lists may be the single image, for this
-%  situation.
+%  Special case:- If one of the image sequences is the last image (just a
+%  single image remaining), that image is repeatally composed with all the
+%  images in the other image list.  Either the source or destination lists may
+%  be the single image, for this situation.
+%
+%  In the case of a single destination image (or last image given), that image
+%  will ve cloned to match the number of images remaining in the source image
+%  list.
+%
+%  This is equivelent to the "-layer Composite" Shell API operator.
 %
-%  The destination list will be expanded as needed to match number of source
-%  image overlaid (from current position to end of list).
 %
 %  The format of the CompositeLayers method is:
 %
-%      void CompositeLayers(Image *destination,
-%          const CompositeOperator compose, Image *source,
-%          const ssize_t x_offset, const ssize_t y_offset,
-%          ExceptionInfo *exception);
+%      void CompositeLayers(Image *destination, const CompositeOperator
+%      compose, Image *source, const ssize_t x_offset, const ssize_t y_offset,
+%      ExceptionInfo *exception);
 %
 %  A description of each parameter follows:
 %
@@ -1774,7 +1778,7 @@ MagickExport void CompositeLayers(Image *destination,
   /*
     Overlay single source image over destation image/list
   */
-  if ( source->previous == (Image *) NULL && source->next == (Image *) NULL )
+  if ( source->next == (Image *) NULL )
     while ( destination != (Image *) NULL )
     {
       CompositeCanvas(destination, compose, source, x_offset, y_offset,
@@ -1783,14 +1787,13 @@ MagickExport void CompositeLayers(Image *destination,
     }
 
   /*
-    Overlay source image list over single destination
-    Generating multiple clones of destination image to match source list.
+    Overlay source image list over single destination.
+    Multiple clones of destination image are created to match source list.
     Original Destination image becomes first image of generated list.
     As such the image list pointer does not require any change in caller.
     Some animation attributes however also needs coping in this case.
   */
-  else if ( destination->previous == (Image *) NULL &&
-            destination->next == (Image *) NULL )
+  else if ( destination->next == (Image *) NULL )
   {
     Image *dest = CloneImage(destination,0,0,MagickTrue,exception);
 
index d51c003f26105c457a212b7f788923d23a062881..ccfc24aa21cfd80e40b09c5c790429630fb8a575 100644 (file)
@@ -1803,17 +1803,18 @@ WandExport MagickWand *MagickCompareImages(MagickWand *wand,
 %  The format of the MagickCompositeImage method is:
 %
 %      MagickBooleanType MagickCompositeImage(MagickWand *wand,
-%        const MagickWand *composite_wand,const CompositeOperator compose,
+%        const MagickWand *source_wand,const CompositeOperator compose,
 %        const ssize_t x,const ssize_t y)
 %
 %  A description of each parameter follows:
 %
-%    o wand: the magick wand.
+%    o wand: the magick wand holding the destination images
 %
-%    o composite_image: the composite image.
+%    o source_image: the magick wand holding source image.
 %
 %    o compose: This operator affects how the composite is applied to the
-%      image.  The default is Over.  Choose from these operators:
+%      image.  The default is Over.  These are some of the compose methods
+%      availble.
 %
 %        OverCompositeOp       InCompositeOp         OutCompositeOp
 %        AtopCompositeOp       XorCompositeOp        PlusCompositeOp
@@ -1827,7 +1828,7 @@ WandExport MagickWand *MagickCompareImages(MagickWand *wand,
 %
 */
 WandExport MagickBooleanType MagickCompositeImage(MagickWand *wand,
-  const MagickWand *composite_wand,const CompositeOperator compose,
+  const MagickWand *source_wand,const CompositeOperator compose,
   const ssize_t x,const ssize_t y)
 {
   MagickBooleanType
@@ -1838,9 +1839,9 @@ WandExport MagickBooleanType MagickCompositeImage(MagickWand *wand,
   if (wand->debug != MagickFalse)
     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
   if ((wand->images == (Image *) NULL) ||
-      (composite_wand->images == (Image *) NULL))
+      (source_wand->images == (Image *) NULL))
     ThrowWandException(WandError,"ContainsNoImages",wand->name);
-  status=CompositeImage(wand->images,compose,composite_wand->images,x,y,
+  status=CompositeImage(wand->images,compose,source_wand->images,x,y,
     wand->exception);
   return(status);
 }
@@ -1850,6 +1851,79 @@ WandExport MagickBooleanType MagickCompositeImage(MagickWand *wand,
 %                                                                             %
 %                                                                             %
 %                                                                             %
+%   M a g i c k C o m p o s i t e L a y e r s                                 %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  MagickCompositeLayers() composite the images in the source wand over the
+%  images in the destination wand in sequence, starting with the current
+%  image in both lists.
+%
+%  Each layer from the two image lists are composted together until the end of
+%  one of the image lists is reached.  The offset of each composition is also
+%  adjusted to match the virtual canvas offsets of each layer. As such the
+%  given offset is relative to the virtual canvas, and not the actual image.
+%
+%  Composition uses given x and y offsets, as the 'origin' location of the
+%  source images virtual canvas (not the real image) allowing you to compose a
+%  list of 'layer images' into the destiantioni images.  This makes it well
+%  sutiable for directly composing 'Clears Frame Animations' or 'Coaleased
+%  Animations' onto a static or other 'Coaleased Animation' destination image
+%  list.  GIF disposal handling is not looked at.
+%
+%  Special case:- If one of the image sequences is the last image (just a
+%  single image remaining), that image is repeatally composed with all the
+%  images in the other image list.  Either the source or destination lists may
+%  be the single image, for this situation.
+%
+%  In the case of a single destination image (or last image given), that image
+%  will ve cloned to match the number of images remaining in the source image
+%  list.
+%
+%  This is equivelent to the "-layer Composite" Shell API operator.
+%
+%  The format of the MagickCompositeLayers method is:
+%
+%      MagickBooleanType MagickCompositeLayers(MagickWand *wand,
+%        const MagickWand *source_wand, const CompositeOperator compose,
+%        const ssize_t x,const ssize_t y)
+%
+%  A description of each parameter follows:
+%
+%    o wand: the magick wand holding destaintion images
+%
+%    o source_wand: the wand holding the source images
+%
+%    o compose, x, y:  composition arguments
+%
+*/
+WandExport MagickBooleanType MagickCompositeLayers(MagickWand *wand,
+  const MagickWand *source_wand,const CompositeOperator compose,
+  const ssize_t x,const ssize_t y)
+{
+  MagickBooleanType
+    status;
+
+  assert(wand != (MagickWand *) NULL);
+  assert(wand->signature == WandSignature);
+  if (wand->debug != MagickFalse)
+    (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
+  if ((wand->images == (Image *) NULL) ||
+      (source_wand->images == (Image *) NULL))
+    ThrowWandException(WandError,"ContainsNoImages",wand->name);
+  CompositeLayers(wand->images,compose,source_wand->images,x,y,
+        wand->exception);
+  status=MagickTrue;  /* FUTURE: determine status from exceptions */
+  return(status);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
 %   M a g i c k C o n t r a s t I m a g e                                     %
 %                                                                             %
 %                                                                             %
index 23e699bdfd11832daa021b76951778d7b2e17d1c..7069a62c1b7b141ce757554aad278b0938d61dad 100644 (file)
@@ -104,6 +104,8 @@ extern WandExport MagickBooleanType
   MagickCommentImage(MagickWand *,const char *),
   MagickCompositeImage(MagickWand *,const MagickWand *,const CompositeOperator,
     const ssize_t,const ssize_t),
+  MagickCompositeLayers(MagickWand *,const MagickWand *,const CompositeOperator,
+    const ssize_t,const ssize_t),
   MagickConstituteImage(MagickWand *,const size_t,const size_t,const char *,
     const StorageType,const void *),
   MagickContrastImage(MagickWand *,const MagickBooleanType),