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