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