• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2   Copyright 1999-2016 ImageMagick Studio LLC, a non-profit organization
3   dedicated to making software imaging solutions freely available.
4 
5   You may not use this file except in compliance with the License.
6   obtain a copy of the License at
7 
8     http://www.imagemagick.org/script/license.php
9 
10   Unless required by applicable law or agreed to in writing, software
11   distributed under the License is distributed on an "AS IS" BASIS,
12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   See the License for the specific language governing permissions and
14   limitations under the License.
15 
16   MagickWand mogrify command-line private methods.
17 */
18 #ifndef MAGICKWAND_MOGRIFY_PRIVATE_H
19 #define MAGICKWAND_MOGRIFY_PRIVATE_H
20 
21 #if defined(__cplusplus) || defined(c_plusplus)
22 extern "C" {
23 #endif
24 
25 #define AppendImageStack(images) \
26 { \
27   (void) SyncImagesSettings(image_info,images,exception); \
28   AppendImageToList(&image_stack[k].image,images); \
29   image=image_stack[k].image; \
30 }
31 #define DestroyImageStack() \
32 { \
33   while (k > 0) \
34     PopImageStack(); \
35   image_stack[k].image=DestroyImageList(image_stack[k].image); \
36   image_stack[k].image_info=DestroyImageInfo(image_stack[k].image_info); \
37   image_info=image_stack[MaxImageStackDepth].image_info; \
38 }
39 #define FinalizeImageSettings(image_info,image,advance) \
40 { \
41   FireImageStack(MagickTrue,advance,MagickTrue); \
42   if (image != (Image *) NULL) \
43     (void) SyncImagesSettings(image_info,image,exception); \
44 }
45 #define FireImageStack(postfix,advance,fire) \
46   if ((j <= i) && (i < (ssize_t) argc)) \
47     { \
48 DisableMSCWarning(4127) \
49       if (image_stack[k].image == (Image *) NULL) \
50         status&=MogrifyImageInfo(image_stack[k].image_info,(int) (i-j+1), \
51           (const char **) (argv+j),exception); \
52       else \
53         if ((fire) != MagickFalse) \
54           { \
55             status&=MogrifyImages(image_stack[k].image_info,postfix,(int) \
56               (i-j+1),(const char **) (argv+j),&image_stack[k].image, \
57               exception); \
58             image=image_stack[k].image; \
59             if ((advance) != MagickFalse) \
60               j=i+1; \
61             pend=MagickFalse; \
62           } \
63 RestoreMSCWarning \
64     }
65 #define MaxImageStackDepth  128
66 #define NewImageStack() \
67 { \
68   image_stack[MaxImageStackDepth].image_info=image_info; \
69   image_stack[0].image_info=CloneImageInfo(image_info); \
70   image_stack[0].image=NewImageList(); \
71   image_info=image_stack[0].image_info; \
72   image=image_stack[0].image; \
73 }
74 #define PushImageStack() \
75 { \
76   k++; \
77   image_stack[k].image_info=CloneImageInfo(image_stack[k-1].image_info); \
78   image_stack[k].image=NewImageList(); \
79   image_info=image_stack[k].image_info; \
80   image=image_stack[k].image; \
81 }
82 #define PopImageStack() \
83 { \
84   if (respect_parenthesis == MagickFalse) \
85     { \
86       image_stack[k-1].image_info=DestroyImageInfo(image_stack[k-1].image_info); \
87       image_stack[k-1].image_info=CloneImageInfo(image_stack[k].image_info); \
88     } \
89   image_stack[k].image_info=DestroyImageInfo(image_stack[k].image_info); \
90   AppendImageToList(&image_stack[k-1].image,image_stack[k].image); \
91   k--; \
92   image_info=image_stack[k].image_info; \
93   image=image_stack[k].image; \
94 }
95 #define QuantumTick(i,span) ((MagickBooleanType) ((((i) & ((i)-1)) == 0) || \
96    (((i) & 0xfff) == 0) || \
97    ((MagickOffsetType) (i) == ((MagickOffsetType) (span)-1))))
98 #define RemoveImageStack(images) \
99 { \
100   images=RemoveFirstImageFromList(&image_stack[k].image); \
101   image=image_stack[k].image; \
102 }
103 #define RemoveAllImageStack() \
104 { \
105   if (image_stack[k].image != (Image *) NULL) \
106     image_stack[k].image=DestroyImageList(image_stack[k].image); \
107 }
108 #define SetImageStack(image) \
109 { \
110   image_stack[k].image=(image); \
111 }
112 
113 typedef struct _ImageStack
114 {
115   ImageInfo
116     *image_info;
117 
118   Image
119     *image;
120 } ImageStack;
121 
122 #if defined(__cplusplus) || defined(c_plusplus)
123 }
124 #endif
125 
126 #endif
127