% of images in list are ignored.
%
% If the referenced images are in the reverse order, that range will be
-% completely ignored. Unlike CloneImages().
+% completely ignored, unlike CloneImages().
%
% The format of the DeleteImages method is:
%
*/
for (p=(char *) scenes; *p != '\0';)
{
- while ((isspace((int)*p) != 0) || (*p == ','))
+ while ((isspace((int) *p) != 0) || (*p == ','))
p++;
first=strtol(p,&p,10);
if (first < 0)
% %
% %
% %
+% D u p l i c a t e I m a g e s %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% DuplicateImages() duplicates one or more images from an image sequence,
+% using a count and a comma separated list of image numbers or ranges.
+%
+% The numbers start at 0 for the first image, while negative numbers refer to
+% images starting counting from the end of the range. Images may be refered to
+% multiple times without problems. Image refered beyond the available number
+% of images in list are ignored.
+%
+% The format of the DuplicateImages method is:
+%
+% Image *DuplicateImages(Image *images,const size_t number_duplicates,
+% const char *scenes,ExceptionInfo *exception)
+%
+% A description of each parameter follows:
+%
+% o images: the image sequence.
+%
+% o number_duplicates: duplicate the image sequence this number of times.
+%
+% o scenes: This character string specifies which scenes to duplicate (e.g.
+% 1,3-5,-2-6,2).
+%
+% o exception: return any errors or warnings in this structure.
+%
+*/
+MagickExport Image *DuplicateImages(Image *images,
+ const size_t number_duplicates,const char *scenes,ExceptionInfo *exception)
+{
+ Image
+ *clone_images,
+ *duplicate_images;
+
+ register ssize_t
+ i;
+
+ /*
+ Duplicate images.
+ */
+ assert(images != (Image *) NULL);
+ assert(images->signature == MagickSignature);
+ assert(scenes != (char *) NULL);
+ if (images->debug != MagickFalse)
+ (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
+ assert(exception != (ExceptionInfo *) NULL);
+ assert(exception->signature == MagickSignature);
+ duplicate_images=NewImageList();
+ for (i=0; i < (ssize_t) number_duplicates; i++)
+ {
+ clone_images=CloneImages(images,scenes,exception);
+ AppendImageToList(&duplicate_images,clone_images);
+ }
+ return(duplicate_images);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
% G e t F i r s t I m a g e I n L i s t %
% %
% %
% %
% %
% %
-+ P a g e I n d e x I m a g e L i s t %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% PageIndexImageList() synchronizes the page_index and page_total values
-% in the image list.
-%
-% These values are used by InterpretImageProperties() to set %p and %n
-% percent escapes. The value is preserved, even if the image is later removed
-% from the list using RemoveFirstImageFromList() for individual image
-% processing.
-%
-% The format of the PageIndexImageList method is:
-%
-% void PageIndexImageList(Image *images)
-%
-% A description of each parameter follows:
-%
-% o images: the image list.
-%
-*/
-MagickExport void PageIndexImageList(Image *images)
-{
- register ssize_t
- p,n;
-
- if (images == (Image *) NULL)
- return;
- assert(images->signature == MagickSignature);
- if (images->debug != MagickFalse)
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
-
- /* find start for image counting */
- while (images->previous != (Image *) NULL)
- images=images->previous;
-
- /* count up images - find end */
- n=1;
- while (images->next != (Image *) NULL)
- images=images->next, n++;
-
- /* set page_index and page_total attributes */
- p=n-1;
- for (; images != (Image *) NULL; images=images->previous)
- images->page_index=p--, images->page_total=n;
-}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
% P r e p e n d I m a g e T o L i s t %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% ReplaceImageInList() replaces an image in the list. Old image is destroyed.
-% The given image list pointer is set to point to the just inserted image.
+% ReplaceImageInList() replaces an image in the list with the given image, or
+% list of images. Old image is destroyed. The image list pointer is set to
+% point to the first image of the inserted list of images.
%
% The format of the ReplaceImageInList method is:
%
%
% A description of each parameter follows:
%
-% o images: the image list.
+% o images: the list and pointer to image to replace
%
-% o image: the image.
+% o image: the image or image list replacing the original
%
*/
MagickExport void ReplaceImageInList(Image **images,Image *image)
if ((*images) == (Image *) NULL)
return;
assert((*images)->signature == MagickSignature);
- for ( ; image->next != (Image *) NULL; image=image->next) ;
+
+ /* link next pointer */
+ image=GetLastImageInList(image);
image->next=(*images)->next;
if (image->next != (Image *) NULL)
image->next->previous=image;
- for ( ; image->previous != (Image *) NULL; image=image->previous) ;
+
+ /* link previous pointer - set image position to first replacement image */
+ image=GetFirstImageInList(image);
image->previous=(*images)->previous;
if (image->previous != (Image *) NULL)
image->previous->next=image;
+
+ /* destroy replaced image */
+ (void) DestroyImage(*images);
+ (*images)=image;
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% R e p l a c e I m a g e I n L i s t R e t u r n L a s t %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% ReplaceImageInListReturnLast() is exactly as ReplaceImageInList() except
+% the image pointer is set to the last image in the list.
+%
+% This allows you to simply use 'next' to go to the image that follows the
+% just replaced image.
+%
+% The format of the ReplaceImageInList method is:
+%
+% ReplaceImageInListReturnLast(Image **images,Image *image)
+%
+% A description of each parameter follows:
+%
+% o images: the list and pointer to image to replace
+%
+% o image: the image or image list replacing the original
+%
+*/
+MagickExport void ReplaceImageInListReturnLast(Image **images,Image *image)
+{
+ assert(images != (Image **) NULL);
+ assert(image != (Image *) NULL);
+ assert(image->signature == MagickSignature);
+ if (image->debug != MagickFalse)
+ (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
+ if ((*images) == (Image *) NULL)
+ return;
+ assert((*images)->signature == MagickSignature);
+
+ /* link previous pointer */
+ image=GetFirstImageInList(image);
+ image->previous=(*images)->previous;
+ if (image->previous != (Image *) NULL)
+ image->previous->next=image;
+
+ /* link next pointer - set image position to last replacement image */
+ image=GetLastImageInList(image);
+ image->next=(*images)->next;
+ if (image->next != (Image *) NULL)
+ image->next->previous=image;
+
+ /* destroy replaced image */
(void) DestroyImage(*images);
(*images)=image;
}