Home | History | Annotate | Download | only in MagickCore
      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   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)
     25 extern "C" {
     26 #endif
     27 
     28 #define OpaqueAlpha  ((Quantum) QuantumRange)
     29 #define TransparentAlpha  ((Quantum) 0)
     30 
     31 typedef 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 
     51 typedef 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 
     67 typedef enum
     68 {
     69   UndefinedInterlace,
     70   NoInterlace,
     71   LineInterlace,
     72   PlaneInterlace,
     73   PartitionInterlace,
     74   GIFInterlace,
     75   JPEGInterlace,
     76   PNGInterlace
     77 } InterlaceType;
     78 
     79 typedef enum
     80 {
     81   UndefinedOrientation,
     82   TopLeftOrientation,
     83   TopRightOrientation,
     84   BottomRightOrientation,
     85   BottomLeftOrientation,
     86   LeftTopOrientation,
     87   RightTopOrientation,
     88   RightBottomOrientation,
     89   LeftBottomOrientation
     90 } OrientationType;
     91 
     92 typedef enum
     93 {
     94   UndefinedResolution,
     95   PixelsPerInchResolution,
     96   PixelsPerCentimeterResolution
     97 } ResolutionType;
     98 
     99 typedef struct _PrimaryInfo
    100 {
    101   double
    102     x,
    103     y,
    104     z;
    105 } PrimaryInfo;
    106 
    107 typedef struct _SegmentInfo
    108 {
    109   double
    110     x1,
    111     y1,
    112     x2,
    113     y2;
    114 } SegmentInfo;
    115 
    116 typedef enum
    117 {
    118   UndefinedTransmitType,
    119   FileTransmitType,
    120   BlobTransmitType,
    121   StreamTransmitType,
    122   ImageTransmitType
    123 } TransmitType;
    124 
    125 typedef 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 
    154 struct _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     alpha_color,        /* current alphacolor attribute */
    184     background_color,   /* current background color attribute */
    185     border_color,       /* current bordercolor 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   FilterType
    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   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                         */
    350 
    351   struct _Image
    352     *list,             /* Undo/Redo image processing list (for display) */
    353     *previous,         /* Image list links */
    354     *next;
    355 
    356   size_t
    357     signature;
    358 };
    359 
    360 /*
    361   ImageInfo structure:
    362     Stores an image list, as well as all global settings used by all images
    363     held, -- unless overridden for that specific image.  See SyncImagesettings()
    364     which maps any global setting that always overrides specific image settings.
    365 */
    366 struct _ImageInfo
    367 {
    368   CompressionType
    369     compression;        /* compression method when reading/saving image */
    370 
    371   OrientationType
    372     orientation;        /* orientation setting */
    373 
    374   MagickBooleanType
    375     temporary,          /* image file to be deleted after read "empemeral:" */
    376     adjoin,             /* save images to separate scene files */
    377     affirm,
    378     antialias;
    379 
    380   char
    381     *size,              /* image generation size */
    382     *extract,           /* crop/resize string on image read */
    383     *page,
    384     *scenes;            /* scene numbers that is to be read in */
    385 
    386   size_t
    387     scene,              /* starting value for image save numbering */
    388     number_scenes,      /* total number of images in list - for escapes */
    389     depth;              /* current read/save depth of images */
    390 
    391   InterlaceType
    392     interlace;          /* interlace for image write */
    393 
    394   EndianType
    395     endian;             /* integer endian order for raw image data */
    396 
    397   ResolutionType
    398     units;              /* denisty pixels/inch or pixel/cm */
    399 
    400   size_t
    401     quality;            /* compression quality */
    402 
    403   char
    404     *sampling_factor,   /* JPEG write sampling factor */
    405     *server_name,       /* X windows server name - display/animate */
    406     *font,              /* DUP for draw_info */
    407     *texture,           /* montage/display background tile */
    408     *density;           /* DUP for image and draw_info */
    409 
    410   double
    411     pointsize,
    412     fuzz;               /* current color fuzz attribute */
    413 
    414   PixelInfo
    415     alpha_color,        /* alpha (frame) color */
    416     background_color,   /* user set background color */
    417     border_color,       /* user set border color */
    418     transparent_color;  /* color for transparent index in color tables */
    419                         /* NB: fill color is only needed in draw_info! */
    420                         /* the same for undercolor (for font drawing) */
    421 
    422   MagickBooleanType
    423     dither,             /* dither enable-disable */
    424     monochrome;         /* read/write pcl,pdf,ps,xps as monocrome image */
    425 
    426   ColorspaceType
    427     colorspace;
    428 
    429   CompositeOperator
    430     compose;
    431 
    432   ImageType
    433     type;
    434 
    435   MagickBooleanType
    436     ping,                    /* fast read image attributes, not image data */
    437     verbose;                 /* verbose output enable/disable */
    438 
    439   ChannelType
    440     channel;
    441 
    442   void
    443     *options;                /* splay tree of global options */
    444 
    445   void
    446     *profile;
    447 
    448   MagickBooleanType
    449     synchronize;
    450 
    451   MagickProgressMonitor
    452     progress_monitor;
    453 
    454   void
    455     *client_data,
    456     *cache;
    457 
    458   StreamHandler
    459     stream;
    460 
    461   FILE
    462     *file;
    463 
    464   void
    465     *blob;
    466 
    467   size_t
    468     length;
    469 
    470   char
    471     magick[MagickPathExtent],    /* image file format (file magick) */
    472     unique[MagickPathExtent],    /* unique tempory filename - delegates */
    473     filename[MagickPathExtent];  /* filename when reading/writing image */
    474 
    475   MagickBooleanType
    476     debug;
    477 
    478   size_t
    479     signature;
    480 };
    481 
    482 extern MagickExport ChannelType
    483   SetImageChannelMask(Image *,const ChannelType);
    484 
    485 extern MagickExport const char
    486   DefaultTileGeometry[],
    487   DefaultTileLabel[],
    488   LoadImageTag[],
    489   LoadImagesTag[],
    490   PSDensityGeometry[],
    491   PSPageGeometry[],
    492   SaveImageTag[],
    493   SaveImagesTag[];
    494 
    495 extern MagickExport const double
    496   DefaultResolution;
    497 
    498 extern MagickExport ExceptionType
    499   CatchImageException(Image *);
    500 
    501 extern MagickExport FILE
    502   *GetImageInfoFile(const ImageInfo *);
    503 
    504 extern MagickExport Image
    505   *AcquireImage(const ImageInfo *,ExceptionInfo *),
    506   *AppendImages(const Image *,const MagickBooleanType,ExceptionInfo *),
    507   *CloneImage(const Image *,const size_t,const size_t,const MagickBooleanType,
    508     ExceptionInfo *),
    509   *DestroyImage(Image *),
    510   *GetImageMask(const Image *,const PixelMask,ExceptionInfo *),
    511   *NewMagickImage(const ImageInfo *,const size_t,const size_t,const PixelInfo *,
    512     ExceptionInfo *),
    513   *ReferenceImage(Image *),
    514   *SmushImages(const Image *,const MagickBooleanType,const ssize_t,
    515     ExceptionInfo *);
    516 
    517 extern MagickExport ImageInfo
    518   *AcquireImageInfo(void),
    519   *CloneImageInfo(const ImageInfo *),
    520   *DestroyImageInfo(ImageInfo *);
    521 
    522 extern MagickExport MagickBooleanType
    523   ClipImage(Image *,ExceptionInfo *),
    524   ClipImagePath(Image *,const char *,const MagickBooleanType,ExceptionInfo *),
    525   CopyImagePixels(Image *,const Image *,const RectangleInfo *,
    526     const OffsetInfo *,ExceptionInfo *),
    527   IsTaintImage(const Image *),
    528   IsHighDynamicRangeImage(const Image *,ExceptionInfo *),
    529   IsImageObject(const Image *),
    530   ListMagickInfo(FILE *,ExceptionInfo *),
    531   ModifyImage(Image **,ExceptionInfo *),
    532   ResetImagePage(Image *,const char *),
    533   SetImageAlpha(Image *,const Quantum,ExceptionInfo *),
    534   SetImageBackgroundColor(Image *,ExceptionInfo *),
    535   SetImageColor(Image *,const PixelInfo *,ExceptionInfo *),
    536   SetImageExtent(Image *,const size_t,const size_t,ExceptionInfo *),
    537   SetImageInfo(ImageInfo *,const unsigned int,ExceptionInfo *),
    538   SetImageMask(Image *,const PixelMask type,const Image *,ExceptionInfo *),
    539   SetImageStorageClass(Image *,const ClassType,ExceptionInfo *),
    540   StripImage(Image *,ExceptionInfo *),
    541   SyncImage(Image *,ExceptionInfo *),
    542   SyncImageSettings(const ImageInfo *,Image *,ExceptionInfo *),
    543   SyncImagesSettings(ImageInfo *,Image *,ExceptionInfo *);
    544 
    545 extern MagickExport size_t
    546   InterpretImageFilename(const ImageInfo *,Image *,const char *,int,char *,
    547     ExceptionInfo *);
    548 
    549 extern MagickExport ssize_t
    550   GetImageReferenceCount(Image *);
    551 
    552 extern MagickExport VirtualPixelMethod
    553   GetImageVirtualPixelMethod(const Image *),
    554   SetImageVirtualPixelMethod(Image *,const VirtualPixelMethod,ExceptionInfo *);
    555 
    556 extern MagickExport void
    557   AcquireNextImage(const ImageInfo *,Image *,ExceptionInfo *),
    558   DestroyImagePixels(Image *),
    559   DisassociateImageStream(Image *),
    560   GetImageInfo(ImageInfo *),
    561   SetImageInfoBlob(ImageInfo *,const void *,const size_t),
    562   SetImageInfoFile(ImageInfo *,FILE *);
    563 
    564 #if defined(__cplusplus) || defined(c_plusplus)
    565 }
    566 #endif
    567 
    568 #endif
    569