]> granicus.if.org Git - imagemagick/blob - MagickCore/pixel.h
(no commit message)
[imagemagick] / MagickCore / pixel.h
1 /*
2   Copyright 1999-2013 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   UndefinedPixelChannel = 0,
64   RedPixelChannel = 0,
65   CyanPixelChannel = 0,
66   GrayPixelChannel = 0,
67   LPixelChannel = 0,
68   YPixelChannel = 0,
69   aPixelChannel = 1,
70   GreenPixelChannel = 1,
71   MagentaPixelChannel = 1,
72   CbPixelChannel = 1,
73   bPixelChannel = 2,
74   BluePixelChannel = 2,
75   YellowPixelChannel = 2,
76   CrPixelChannel = 2,
77   BlackPixelChannel = 3,
78   AlphaPixelChannel = 4,
79   IndexPixelChannel = 5,
80   MaskPixelChannel = 6,                 /* Image Write Mask */
81   MetaPixelChannel = 7,                 /* ??? */
82   IntensityPixelChannel = MaxPixelChannels,  /* what are these ??? */
83   CompositePixelChannel = MaxPixelChannels,
84   SyncPixelChannel = MaxPixelChannels+1
85 } PixelChannel;  /* must correspond to ChannelType */
86
87 typedef enum
88 {
89   UndefinedPixelIntensityMethod = 0,
90   AveragePixelIntensityMethod,
91   BrightnessPixelIntensityMethod,
92   LightnessPixelIntensityMethod,
93   Rec601LumaPixelIntensityMethod,
94   Rec601LuminancePixelIntensityMethod,
95   Rec709LumaPixelIntensityMethod,
96   Rec709LuminancePixelIntensityMethod,
97   RMSPixelIntensityMethod
98 } PixelIntensityMethod;
99
100 typedef enum
101 {
102   UndefinedInterpolatePixel,
103   AverageInterpolatePixel,    /* Average 4 nearest neighbours */
104   Average9InterpolatePixel,   /* Average 9 nearest neighbours */
105   Average16InterpolatePixel,  /* Average 16 nearest neighbours */
106   BackgroundInterpolatePixel, /* Just return background color */
107   BilinearInterpolatePixel,   /* Triangular filter interpolation */
108   BlendInterpolatePixel,      /* blend of nearest 1, 2 or 4 pixels */
109   CatromInterpolatePixel,     /* Catmull-Rom interpolation */
110   IntegerInterpolatePixel,    /* Integer (floor) interpolation */
111   MeshInterpolatePixel,       /* Triangular Mesh interpolation */
112   NearestInterpolatePixel,    /* Nearest Neighbour Only */
113   SplineInterpolatePixel     /* Cubic Spline (blurred) interpolation */
114   /* FilterInterpolatePixel,  ** Use resize filter - (very slow) */
115 } PixelInterpolateMethod;
116
117 typedef enum
118 {
119   UndefinedPixelTrait = 0x000000,
120   CopyPixelTrait = 0x000001,
121   UpdatePixelTrait = 0x000002,
122   BlendPixelTrait = 0x000004
123 } PixelTrait;
124
125 typedef struct _PixelChannelMap
126 {
127   PixelChannel
128     channel;
129
130   PixelTrait
131     traits;
132
133   ssize_t
134     offset;
135 } PixelChannelMap;
136
137 typedef struct _PixelInfo
138 {
139   ClassType
140     storage_class;
141
142   ColorspaceType
143     colorspace;
144
145   PixelTrait
146     alpha_trait;
147
148   double
149     fuzz;
150
151   size_t
152     depth;
153
154   MagickSizeType
155     count;
156
157   MagickRealType
158     red,
159     green,
160     blue,
161     black,
162     alpha,
163     index;
164 } PixelInfo;
165
166 typedef struct _PixelPacket
167 {
168   unsigned int
169     red,
170     green,
171     blue,
172     alpha,
173     black;
174 } PixelPacket;
175
176 typedef enum
177 {
178   UndefinedPixel,
179   CharPixel,
180   DoublePixel,
181   FloatPixel,
182   LongPixel,
183   LongLongPixel,
184   QuantumPixel,
185   ShortPixel
186 } StorageType;
187
188 typedef struct _CacheView
189   CacheView_;
190
191 extern MagickExport MagickBooleanType
192   ExportImagePixels(Image *,const ssize_t,const ssize_t,const size_t,
193     const size_t,const char *,const StorageType,void *,ExceptionInfo *),
194   ImportImagePixels(Image *,const ssize_t,const ssize_t,const size_t,
195     const size_t,const char *,const StorageType,const void *,ExceptionInfo *),
196   InterpolatePixelChannel(const Image *,const CacheView_ *,
197     const PixelChannel,const PixelInterpolateMethod,const double,const double,
198     double *,ExceptionInfo *),
199   InterpolatePixelChannels(const Image *,const CacheView_ *,const Image *,
200     const PixelInterpolateMethod,const double,const double,Quantum *,
201     ExceptionInfo *),
202   InterpolatePixelInfo(const Image *,const CacheView_ *,
203     const PixelInterpolateMethod,const double,const double,PixelInfo *,
204     ExceptionInfo *),
205   IsFuzzyEquivalencePixel(const Image *,const Quantum *,const Image *,
206     const Quantum *),
207   IsFuzzyEquivalencePixelInfo(const PixelInfo *,const PixelInfo *),
208   SetPixelMetaChannels(Image *,const size_t,ExceptionInfo *);
209
210 extern MagickExport MagickRealType
211   GetPixelIntensity(const Image *restrict,const Quantum *restrict)
212     magick_hot_spot;
213
214 extern MagickExport PixelChannelMap
215   *AcquirePixelChannelMap(void),
216   *ClonePixelChannelMap(PixelChannelMap *),
217   *DestroyPixelChannelMap(PixelChannelMap *);
218
219 extern MagickExport PixelInfo
220   *ClonePixelInfo(const PixelInfo *);
221
222 extern MagickExport MagickRealType
223   DecodePixelGamma(const MagickRealType) magick_hot_spot,
224   EncodePixelGamma(const MagickRealType) magick_hot_spot;
225
226 extern MagickExport void
227   InitializePixelChannelMap(Image *),
228   GetPixelInfo(const Image *,PixelInfo *),
229   SetPixelChannelMask(Image *,const ChannelType);
230
231 #if defined(__cplusplus) || defined(c_plusplus)
232 }
233 #endif
234
235 #endif