]> granicus.if.org Git - imagemagick/blob - MagickCore/pixel.h
(no commit message)
[imagemagick] / MagickCore / pixel.h
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 pixel methods.
17 */
18 #ifndef _MAGICKCORE_PIXEL_H
19 #define _MAGICKCORE_PIXEL_H
20
21 #if defined(__cplusplus) || defined(c_plusplus)
22 extern "C" {
23 #endif
24
25 #include <MagickCore/colorspace.h>
26
27 #define MaxPixelChannels  32
28 #undef index
29
30 typedef enum
31 {
32   UndefinedChannel = 0x0000,
33   RedChannel = 0x0001,
34   GrayChannel = 0x0001,
35   CyanChannel = 0x0001,
36   GreenChannel = 0x0002,
37   MagentaChannel = 0x0002,
38   BlueChannel = 0x0004,
39   YellowChannel = 0x0004,
40   BlackChannel = 0x0008,
41   AlphaChannel = 0x0010,
42   OpacityChannel = 0x0010,
43   IndexChannel = 0x0020,
44   MaskChannel = 0x0040,
45   MetaChannel = 0x0080,
46   CompositeChannels = 0x002F,
47   AllChannels = 0x7ffffff,
48   /*
49     Special purpose channel types.
50     FUTURE: are these needed any more - they are more like hacks
51     SyncChannels for example is NOT a real channel but a 'flag'
52     It really says -- "User has not defined channels"
53   */
54   TrueAlphaChannel = 0x0100, /* extract actual alpha channel from opacity */
55   RGBChannels = 0x0200,      /* set alpha from grayscale mask in RGB */
56   GrayChannels = 0x0400,
57   SyncChannels = 0x20000,    /* channels modified as a single unit */
58   DefaultChannels = ((AllChannels | SyncChannels) &~ AlphaChannel)
59 } ChannelType;  /* must correspond to PixelChannel */
60
61 typedef enum
62 {
63   UndefinedInterpolatePixel,
64   AverageInterpolatePixel,    /* Average 4 nearest neighbours */
65   Average9InterpolatePixel,   /* Average 9 nearest neighbours */
66   Average16InterpolatePixel,  /* Average 16 nearest neighbours */
67   BackgroundInterpolatePixel, /* Just return background color */
68   BilinearInterpolatePixel,   /* Triangular filter interpolation */
69   BlendInterpolatePixel,      /* blend of nearest 1, 2 or 4 pixels */
70   CatromInterpolatePixel,     /* Catmull-Rom interpolation */
71   IntegerInterpolatePixel,    /* Integer (floor) interpolation */
72   MeshInterpolatePixel,       /* Triangular Mesh interpolation */
73   NearestInterpolatePixel,    /* Nearest Neighbour Only */
74   SplineInterpolatePixel     /* Cubic Spline (blurred) interpolation */
75   /* FilterInterpolatePixel,  ** Use resize filter - (very slow) */
76 } PixelInterpolateMethod;
77
78 typedef enum
79 {
80   UndefinedPixelChannel = 0,
81   RedPixelChannel = 0,
82   CyanPixelChannel = 0,
83   GrayPixelChannel = 0,
84   YPixelChannel = 0,
85   GreenPixelChannel = 1,
86   MagentaPixelChannel = 1,
87   CbPixelChannel = 1,
88   BluePixelChannel = 2,
89   YellowPixelChannel = 2,
90   CrPixelChannel = 2,
91   BlackPixelChannel = 3,
92   AlphaPixelChannel = 4,
93   IndexPixelChannel = 5,
94   MaskPixelChannel = 6,                 /* Image Write Mask */
95   MetaPixelChannel = 7,                 /* ??? */
96   IntensityPixelChannel = MaxPixelChannels,  /* what are these ??? */
97   CompositePixelChannel = MaxPixelChannels,
98   SyncPixelChannel = MaxPixelChannels+1
99 } PixelChannel;  /* must correspond to ChannelType */
100
101 typedef enum
102 {
103   UndefinedPixelTrait = 0x000000,
104   CopyPixelTrait = 0x000001,
105   UpdatePixelTrait = 0x000002,
106   BlendPixelTrait = 0x000004
107 } PixelTrait;
108
109 typedef struct _PixelChannelMap
110 {
111   PixelChannel
112     channel;
113
114   PixelTrait
115     traits;
116
117   ssize_t
118     offset;
119 } PixelChannelMap;
120
121 typedef struct _PixelInfo
122 {
123   ClassType
124     storage_class;
125
126   ColorspaceType
127     colorspace;
128
129   MagickBooleanType
130     matte;
131
132   double
133     fuzz;
134
135   size_t
136     depth;
137
138   MagickSizeType
139     count;
140
141   double
142     red,
143     green,
144     blue,
145     black,
146     alpha,
147     index;
148 } PixelInfo;
149
150 typedef struct _PixelPacket
151 {
152   unsigned int
153     red,
154     green,
155     blue,
156     alpha,
157     black;
158 } PixelPacket;
159
160 typedef enum
161 {
162   UndefinedPixel,
163   CharPixel,
164   DoublePixel,
165   FloatPixel,
166   LongPixel,
167   LongLongPixel,
168   QuantumPixel,
169   ShortPixel
170 } StorageType;
171
172 typedef struct _CacheView
173   CacheView_;
174
175 extern MagickExport ChannelType
176   SetPixelChannelMask(Image *,const ChannelType);
177
178 extern MagickExport MagickBooleanType
179   ExportImagePixels(const Image *,const ssize_t,const ssize_t,const size_t,
180     const size_t,const char *,const StorageType,void *,ExceptionInfo *),
181   ImportImagePixels(Image *,const ssize_t,const ssize_t,const size_t,
182     const size_t,const char *,const StorageType,const void *,ExceptionInfo *),
183   InterpolatePixelChannel(const Image *,const CacheView_ *,
184     const PixelChannel,const PixelInterpolateMethod,const double,const double,
185     double *,ExceptionInfo *),
186   InterpolatePixelChannels(const Image *,const CacheView_ *,const Image *,
187     const PixelInterpolateMethod,const double,const double,Quantum *,
188     ExceptionInfo *),
189   InterpolatePixelInfo(const Image *,const CacheView_ *,
190     const PixelInterpolateMethod,const double,const double,PixelInfo *,
191     ExceptionInfo *),
192   IsFuzzyEquivalencePixel(const Image *,const Quantum *,const Image *,
193     const Quantum *),
194   IsFuzzyEquivalencePixelInfo(const PixelInfo *,const PixelInfo *),
195   SetPixelMetaChannels(Image *,const size_t,ExceptionInfo *);
196
197 extern MagickExport PixelChannelMap
198   *AcquirePixelChannelMap(void),
199   *ClonePixelChannelMap(PixelChannelMap *),
200   *DestroyPixelChannelMap(PixelChannelMap *);
201
202 extern MagickExport PixelInfo
203   *ClonePixelInfo(const PixelInfo *);
204
205 extern MagickExport void
206   InitializePixelChannelMap(Image *),
207   GetPixelInfo(const Image *,PixelInfo *),
208   SetPixelChannelMapMask(Image *,const ChannelType);
209
210 #if defined(__cplusplus) || defined(c_plusplus)
211 }
212 #endif
213
214 #endif