1 /*
2   Copyright 1999-2021 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.  You may
6   obtain a copy of the License at
7 
8     https://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   MagickCore image methods.
17 */
18 #ifndef MAGICKCORE_IMAGE_H
19 #define MAGICKCORE_IMAGE_H
20 
21 #include "magick/color.h"
22 
23 #if defined(__cplusplus) || defined(c_plusplus)
24 extern "C" {
25 #endif
26 
27 #define OpaqueOpacity  ((Quantum) 0UL)
28 #define TransparentOpacity  (QuantumRange)
29 
30 typedef enum
31 {
32   UndefinedAlphaChannel,
33   ActivateAlphaChannel,
34   BackgroundAlphaChannel,
35   CopyAlphaChannel,
36   DeactivateAlphaChannel,
37   ExtractAlphaChannel,
38   OpaqueAlphaChannel,
39   ResetAlphaChannel,  /* deprecated */
40   SetAlphaChannel,
41   ShapeAlphaChannel,
42   TransparentAlphaChannel,
43   FlattenAlphaChannel,
44   RemoveAlphaChannel,
45   AssociateAlphaChannel,
46   DisassociateAlphaChannel
47 } AlphaChannelType;
48 
49 typedef enum
50 {
51   UndefinedType,
52   BilevelType,
53   GrayscaleType,
54   GrayscaleMatteType,
55   PaletteType,
56   PaletteMatteType,
57   TrueColorType,
58   TrueColorMatteType,
59   ColorSeparationType,
60   ColorSeparationMatteType,
61   OptimizeType,
62   PaletteBilevelMatteType
63 } ImageType;
64 
65 typedef enum
66 {
67   UndefinedInterlace,
68   NoInterlace,
69   LineInterlace,
70   PlaneInterlace,
71   PartitionInterlace,
72   GIFInterlace,
73   JPEGInterlace,
74   PNGInterlace
75 } InterlaceType;
76 
77 typedef enum
78 {
79   UndefinedOrientation,
80   TopLeftOrientation,
81   TopRightOrientation,
82   BottomRightOrientation,
83   BottomLeftOrientation,
84   LeftTopOrientation,
85   RightTopOrientation,
86   RightBottomOrientation,
87   LeftBottomOrientation
88 } OrientationType;
89 
90 typedef enum
91 {
92   UndefinedResolution,
93   PixelsPerInchResolution,
94   PixelsPerCentimeterResolution
95 } ResolutionType;
96 
97 typedef struct _PrimaryInfo
98 {
99   double
100     x,
101     y,
102     z;
103 } PrimaryInfo;
104 
105 typedef struct _SegmentInfo
106 {
107   double
108     x1,
109     y1,
110     x2,
111     y2;
112 } SegmentInfo;
113 
114 typedef enum
115 {
116   UndefinedTransmitType,
117   FileTransmitType,
118   BlobTransmitType,
119   StreamTransmitType,
120   ImageTransmitType
121 } TransmitType;
122 
123 typedef struct _ChromaticityInfo
124 {
125   PrimaryInfo
126     red_primary,
127     green_primary,
128     blue_primary,
129     white_point;
130 } ChromaticityInfo;
131 
132 #include "magick/blob.h"
133 #include "magick/colorspace.h"
134 #include "magick/cache-view.h"
135 #include "magick/color.h"
136 #include "magick/composite.h"
137 #include "magick/compress.h"
138 #include "magick/effect.h"
139 #include "magick/geometry.h"
140 #include "magick/layer.h"
141 #include "magick/locale_.h"
142 #include "magick/monitor.h"
143 #include "magick/pixel.h"
144 #include "magick/profile.h"
145 #include "magick/quantum.h"
146 #include "magick/resample.h"
147 #include "magick/resize.h"
148 #include "magick/semaphore.h"
149 #include "magick/stream.h"
150 #include "magick/timer.h"
151 
152 struct _Image
153 {
154   ClassType
155     storage_class;
156 
157   ColorspaceType
158     colorspace;      /* colorspace of image data */
159 
160   CompressionType
161     compression;     /* compression of image when read/write */
162 
163   size_t
164     quality;         /* compression quality setting, meaning varies */
165 
166   OrientationType
167     orientation;     /* photo orientation of image */
168 
169   MagickBooleanType
170     taint,           /* has image been modified since reading */
171     matte;           /* is transparency channel defined and active */
172 
173   size_t
174     columns,         /* physical size of image */
175     rows,
176     depth,           /* depth of image on read/write */
177     colors;          /* size of color table on read */
178 
179   PixelPacket
180     *colormap,
181     background_color, /* current background color attribute */
182     border_color,     /* current bordercolor attribute */
183     matte_color;      /* current mattecolor attribute */
184 
185   double
186     gamma;
187 
188   ChromaticityInfo
189     chromaticity;
190 
191   RenderingIntent
192     rendering_intent;
193 
194   void
195     *profiles;
196 
197   ResolutionType
198     units;          /* resolution/density  ppi or ppc */
199 
200   char
201     *montage,
202     *directory,
203     *geometry;
204 
205   ssize_t
206     offset;
207 
208   double
209     x_resolution,   /* image resolution/density */
210     y_resolution;
211 
212   RectangleInfo
213     page,           /* virtual canvas size and offset of image */
214     extract_info,
215     tile_info;      /* deprecated */
216 
217   double
218     bias,
219     blur,           /* deprecated */
220     fuzz;           /* current color fuzz attribute */
221 
222   FilterTypes
223     filter;         /* resize/distort filter to apply */
224 
225   InterlaceType
226     interlace;
227 
228   EndianType
229     endian;         /* raw data integer ordering on read/write */
230 
231   GravityType
232     gravity;        /* Gravity attribute for positioning in image */
233 
234   CompositeOperator
235     compose;        /* alpha composition method for layered images */
236 
237   DisposeType
238     dispose;        /* GIF animation disposal method */
239 
240   struct _Image
241     *clip_mask;
242 
243   size_t
244     scene,          /* index of image in multi-image file */
245     delay;          /* Animation delay time */
246 
247   ssize_t
248     ticks_per_second;  /* units for delay time, default 100 for GIF */
249 
250   size_t
251     iterations,
252     total_colors;
253 
254   ssize_t
255     start_loop;
256 
257   ErrorInfo
258     error;
259 
260   TimerInfo
261     timer;
262 
263   MagickProgressMonitor
264     progress_monitor;
265 
266   void
267     *client_data,
268     *cache,
269     *attributes;      /* deprecated */
270 
271   Ascii85Info
272     *ascii85;
273 
274   BlobInfo
275     *blob;
276 
277   char
278     filename[MaxTextExtent],         /* images input filename */
279     magick_filename[MaxTextExtent],  /* ditto with coders, and read_mods */
280     magick[MaxTextExtent];           /* Coder used to decode image */
281 
282   size_t
283     magick_columns,
284     magick_rows;
285 
286   ExceptionInfo
287     exception;        /* Error handling report */
288 
289   MagickBooleanType
290     debug;            /* debug output attribute */
291 
292   volatile ssize_t
293     reference_count;
294 
295   SemaphoreInfo
296     *semaphore;
297 
298   ProfileInfo
299     color_profile,
300     iptc_profile,
301     *generic_profile;
302 
303   size_t
304     generic_profiles;  /* this & ProfileInfo is deprecated */
305 
306   size_t
307     signature;
308 
309   struct _Image
310     *previous,         /* Image list links */
311     *list,             /* Undo/Redo image processing list (for display) */
312     *next;             /* Image list links */
313 
314   InterpolatePixelMethod
315     interpolate;       /* Interpolation of color for between pixel lookups */
316 
317   MagickBooleanType
318     black_point_compensation;
319 
320   PixelPacket
321     transparent_color; /* color for 'transparent' color index in GIF */
322 
323   struct _Image
324     *mask;
325 
326   RectangleInfo
327     tile_offset;
328 
329   void
330     *properties,       /* per image properities */
331     *artifacts;        /* per image sequence image artifacts */
332 
333   ImageType
334     type;
335 
336   MagickBooleanType
337     dither;            /* dithering method during color reduction */
338 
339   MagickSizeType
340     extent;
341 
342   MagickBooleanType
343     ping;
344 
345   size_t
346     channels;
347 
348   time_t
349     timestamp;
350 
351   PixelIntensityMethod
352     intensity;      /* method to generate an intensity value from a pixel */
353 
354   size_t
355     duration;       /* Total animation duration sum(delay*iterations) */
356 
357   long
358     tietz_offset;
359 };
360 
361 struct _ImageInfo
362 {
363   CompressionType
364     compression;
365 
366   OrientationType
367     orientation;
368 
369   MagickBooleanType
370     temporary,
371     adjoin,
372     affirm,
373     antialias;
374 
375   char
376     *size,
377     *extract,
378     *page,
379     *scenes;
380 
381   size_t
382     scene,
383     number_scenes,
384     depth;
385 
386   InterlaceType
387     interlace;
388 
389   EndianType
390     endian;
391 
392   ResolutionType
393     units;
394 
395   size_t
396     quality;
397 
398   char
399     *sampling_factor,
400     *server_name,
401     *font,
402     *texture,
403     *density;
404 
405   double
406     pointsize,
407     fuzz;
408 
409   PixelPacket
410     background_color,
411     border_color,
412     matte_color;
413 
414   MagickBooleanType
415     dither,
416     monochrome;
417 
418   size_t
419     colors;
420 
421   ColorspaceType
422     colorspace;
423 
424   ImageType
425     type;
426 
427   PreviewType
428     preview_type;
429 
430   ssize_t
431     group;
432 
433   MagickBooleanType
434     ping,
435     verbose;
436 
437   char
438     *view,
439     *authenticate;
440 
441   ChannelType
442     channel;
443 
444   Image
445     *attributes;  /* deprecated */
446 
447   void
448     *options;
449 
450   MagickProgressMonitor
451     progress_monitor;
452 
453   void
454     *client_data,
455     *cache;
456 
457   StreamHandler
458     stream;
459 
460   FILE
461     *file;
462 
463   void
464     *blob;
465 
466   size_t
467     length;
468 
469   char
470     magick[MaxTextExtent],
471     unique[MaxTextExtent],
472     zero[MaxTextExtent],
473     filename[MaxTextExtent];
474 
475   MagickBooleanType
476     debug;
477 
478   char
479     *tile;  /* deprecated */
480 
481   size_t
482     subimage,  /* deprecated */
483     subrange;  /* deprecated */
484 
485   PixelPacket
486     pen;  /* deprecated */
487 
488   size_t
489     signature;
490 
491   VirtualPixelMethod
492     virtual_pixel_method;
493 
494   PixelPacket
495     transparent_color;
496 
497   void
498     *profile;
499 
500   MagickBooleanType
501     synchronize;
502 };
503 
504 extern MagickExport ExceptionType
505   CatchImageException(Image *);
506 
507 extern MagickExport FILE
508   *GetImageInfoFile(const ImageInfo *);
509 
510 extern MagickExport Image
511   *AcquireImage(const ImageInfo *),
512   *AppendImages(const Image *,const MagickBooleanType,ExceptionInfo *),
513   *CloneImage(const Image *,const size_t,const size_t,const MagickBooleanType,
514     ExceptionInfo *),
515   *DestroyImage(Image *),
516   *GetImageClipMask(const Image *,ExceptionInfo *) magick_attribute((__pure__)),
517   *GetImageMask(const Image *,ExceptionInfo *) magick_attribute((__pure__)),
518   *NewMagickImage(const ImageInfo *,const size_t,const size_t,
519     const MagickPixelPacket *),
520   *ReferenceImage(Image *),
521   *SmushImages(const Image *,const MagickBooleanType,const ssize_t,
522     ExceptionInfo *);
523 
524 extern MagickExport ImageInfo
525   *AcquireImageInfo(void),
526   *CloneImageInfo(const ImageInfo *),
527   *DestroyImageInfo(ImageInfo *);
528 
529 extern MagickExport MagickBooleanType
530   ClipImage(Image *),
531   ClipImagePath(Image *,const char *,const MagickBooleanType),
532   CopyImagePixels(Image *,const Image *,const RectangleInfo *,
533     const OffsetInfo *,ExceptionInfo *),
534   IsTaintImage(const Image *),
535   IsMagickConflict(const char *) magick_attribute((__pure__)),
536   IsHighDynamicRangeImage(const Image *,ExceptionInfo *),
537   IsImageObject(const Image *),
538   ListMagickInfo(FILE *,ExceptionInfo *),
539   ModifyImage(Image **,ExceptionInfo *),
540   ResetImagePage(Image *,const char *),
541   ResetImagePixels(Image *,ExceptionInfo *),
542   SetImageBackgroundColor(Image *),
543   SetImageClipMask(Image *,const Image *),
544   SetImageColor(Image *,const MagickPixelPacket *),
545   SetImageExtent(Image *,const size_t,const size_t),
546   SetImageInfo(ImageInfo *,const unsigned int,ExceptionInfo *),
547   SetImageMask(Image *,const Image *),
548   SetImageOpacity(Image *,const Quantum),
549   SetImageChannels(Image *,const size_t),
550   SetImageStorageClass(Image *,const ClassType),
551   StripImage(Image *),
552   SyncImage(Image *),
553   SyncImageSettings(const ImageInfo *,Image *),
554   SyncImagesSettings(ImageInfo *,Image *);
555 
556 extern MagickExport size_t
557   InterpretImageFilename(const ImageInfo *,Image *,const char *,int,char *);
558 
559 extern MagickExport ssize_t
560   GetImageReferenceCount(Image *);
561 
562 extern MagickExport size_t
563   GetImageChannels(Image *);
564 
565 extern MagickExport VirtualPixelMethod
566   GetImageVirtualPixelMethod(const Image *),
567   SetImageVirtualPixelMethod(const Image *,const VirtualPixelMethod);
568 
569 extern MagickExport void
570   AcquireNextImage(const ImageInfo *,Image *),
571   DestroyImagePixels(Image *),
572   DisassociateImageStream(Image *),
573   GetImageException(Image *,ExceptionInfo *),
574   GetImageInfo(ImageInfo *),
575   SetImageInfoBlob(ImageInfo *,const void *,const size_t),
576   SetImageInfoFile(ImageInfo *,FILE *);
577 
578 #if defined(__cplusplus) || defined(c_plusplus)
579 }
580 #endif
581 
582 #endif
583