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