mogrify-private.h 3.81 KB
Newer Older
cristy's avatar
cristy committed
1
/*
Cristy's avatar
Cristy committed
2
  Copyright 1999-2019 ImageMagick Studio LLC, a non-profit organization
cristy's avatar
cristy committed
3 4
  dedicated to making software imaging solutions freely available.

5
  You may not use this file except in compliance with the License.  You may
cristy's avatar
cristy committed
6 7
  obtain a copy of the License at

Cristy's avatar
Cristy committed
8
    https://imagemagick.org/script/license.php
cristy's avatar
cristy committed
9 10 11 12 13 14 15 16 17

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

  MagickWand mogrify command-line private methods.
*/
18 19
#ifndef MAGICKWAND_MOGRIFY_PRIVATE_H
#define MAGICKWAND_MOGRIFY_PRIVATE_H
cristy's avatar
cristy committed
20 21 22 23 24 25 26

#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif

#define AppendImageStack(images) \
{ \
cristy's avatar
cristy committed
27
  (void) SyncImagesSettings(image_info,images,exception); \
cristy's avatar
cristy committed
28 29 30 31 32 33 34 35 36
  AppendImageToList(&image_stack[k].image,images); \
  image=image_stack[k].image; \
}
#define DestroyImageStack() \
{ \
  while (k > 0) \
    PopImageStack(); \
  image_stack[k].image=DestroyImageList(image_stack[k].image); \
  image_stack[k].image_info=DestroyImageInfo(image_stack[k].image_info); \
cristy's avatar
cristy committed
37
  image_info=image_stack[MaxImageStackDepth].image_info; \
cristy's avatar
cristy committed
38 39 40 41
}
#define FinalizeImageSettings(image_info,image,advance) \
{ \
  FireImageStack(MagickTrue,advance,MagickTrue); \
cristy's avatar
cristy committed
42
  if (image != (Image *) NULL) \
cristy's avatar
cristy committed
43
    (void) SyncImagesSettings(image_info,image,exception); \
cristy's avatar
cristy committed
44 45
}
#define FireImageStack(postfix,advance,fire) \
cristy's avatar
cristy committed
46
  if ((j <= i) && (i < (ssize_t) argc)) \
cristy's avatar
cristy committed
47
    { \
dirk's avatar
dirk committed
48
DisableMSCWarning(4127) \
cristy's avatar
cristy committed
49 50 51 52 53 54
      if (image_stack[k].image == (Image *) NULL) \
        status&=MogrifyImageInfo(image_stack[k].image_info,(int) (i-j+1), \
          (const char **) (argv+j),exception); \
      else \
        if ((fire) != MagickFalse) \
          { \
cristy's avatar
cristy committed
55 56 57
            status&=MogrifyImages(image_stack[k].image_info,postfix,(int) \
              (i-j+1),(const char **) (argv+j),&image_stack[k].image, \
              exception); \
cristy's avatar
cristy committed
58 59 60 61 62
            image=image_stack[k].image; \
            if ((advance) != MagickFalse) \
              j=i+1; \
            pend=MagickFalse; \
          } \
dirk's avatar
dirk committed
63
RestoreMSCWarning \
cristy's avatar
cristy committed
64
    }
cristy's avatar
cristy committed
65
#define MaxImageStackDepth  128
cristy's avatar
cristy committed
66 67
#define NewImageStack() \
{ \
cristy's avatar
cristy committed
68
  image_stack[MaxImageStackDepth].image_info=image_info; \
cristy's avatar
cristy committed
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
  image_stack[0].image_info=CloneImageInfo(image_info); \
  image_stack[0].image=NewImageList(); \
  image_info=image_stack[0].image_info; \
  image=image_stack[0].image; \
}
#define PushImageStack() \
{ \
  k++; \
  image_stack[k].image_info=CloneImageInfo(image_stack[k-1].image_info); \
  image_stack[k].image=NewImageList(); \
  image_info=image_stack[k].image_info; \
  image=image_stack[k].image; \
}
#define PopImageStack() \
{ \
  if (respect_parenthesis == MagickFalse) \
    { \
      image_stack[k-1].image_info=DestroyImageInfo(image_stack[k-1].image_info); \
      image_stack[k-1].image_info=CloneImageInfo(image_stack[k].image_info); \
    } \
  image_stack[k].image_info=DestroyImageInfo(image_stack[k].image_info); \
  AppendImageToList(&image_stack[k-1].image,image_stack[k].image); \
  k--; \
  image_info=image_stack[k].image_info; \
  image=image_stack[k].image; \
}
#define QuantumTick(i,span) ((MagickBooleanType) ((((i) & ((i)-1)) == 0) || \
   (((i) & 0xfff) == 0) || \
   ((MagickOffsetType) (i) == ((MagickOffsetType) (span)-1))))
#define RemoveImageStack(images) \
{ \
  images=RemoveFirstImageFromList(&image_stack[k].image); \
  image=image_stack[k].image; \
}
#define RemoveAllImageStack() \
{ \
  if (image_stack[k].image != (Image *) NULL) \
    image_stack[k].image=DestroyImageList(image_stack[k].image); \
}
#define SetImageStack(image) \
{ \
  image_stack[k].image=(image); \
}

typedef struct _ImageStack
{
  ImageInfo
    *image_info;

  Image
    *image;
} ImageStack;

#if defined(__cplusplus) || defined(c_plusplus)
}
#endif

#endif