]> 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   LPixelChannel = 0,
85   YPixelChannel = 0,
86   aPixelChannel = 1,
87   GreenPixelChannel = 1,
88   MagentaPixelChannel = 1,
89   CbPixelChannel = 1,
90   bPixelChannel = 2,
91   BluePixelChannel = 2,
92   YellowPixelChannel = 2,
93   CrPixelChannel = 2,
94   BlackPixelChannel = 3,
95   AlphaPixelChannel = 4,
96   IndexPixelChannel = 5,
97   MaskPixelChannel = 6,                 /* Image Write Mask */
98   MetaPixelChannel = 7,                 /* ??? */
99   IntensityPixelChannel = MaxPixelChannels,  /* what are these ??? */
100   CompositePixelChannel = MaxPixelChannels,
101   SyncPixelChannel = MaxPixelChannels+1
102 } PixelChannel;  /* must correspond to ChannelType */
103
104 typedef enum
105 {
106   UndefinedPixelTrait = 0x000000,
107   CopyPixelTrait = 0x000001,
108   UpdatePixelTrait = 0x000002,
109   BlendPixelTrait = 0x000004
110 } PixelTrait;
111
112 typedef struct _PixelChannelMap
113 {
114   PixelChannel
115     channel;
116
117   PixelTrait
118     traits;
119
120   ssize_t
121     offset;
122 } PixelChannelMap;
123
124 typedef struct _PixelInfo
125 {
126   ClassType
127     storage_class;
128
129   ColorspaceType
130     colorspace;
131
132   MagickBooleanType
133     matte;
134
135   double
136     fuzz;
137
138   size_t
139     depth;
140
141   MagickSizeType
142     count;
143
144   double
145     red,
146     green,
147     blue,
148     black,
149     alpha,
150     index;
151 } PixelInfo;
152
153 typedef struct _PixelPacket
154 {
155   unsigned int
156     red,
157     green,
158     blue,
159     alpha,
160     black;
161 } PixelPacket;
162
163 typedef enum
164 {
165   UndefinedPixel,
166   CharPixel,
167   DoublePixel,
168   FloatPixel,
169   LongPixel,
170   LongLongPixel,
171   QuantumPixel,
172   ShortPixel
173 } StorageType;
174
175 typedef struct _CacheView
176   CacheView_;
177
178 extern MagickExport ChannelType
179   SetPixelChannelMask(Image *,const ChannelType);
180
181 extern MagickExport MagickBooleanType
182   ExportImagePixels(const Image *,const ssize_t,const ssize_t,const size_t,
183     const size_t,const char *,const StorageType,void *,ExceptionInfo *),
184   ImportImagePixels(Image *,const ssize_t,const ssize_t,const size_t,
185     const size_t,const char *,const StorageType,const void *,ExceptionInfo *),
186   InterpolatePixelChannel(const Image *,const CacheView_ *,
187     const PixelChannel,const PixelInterpolateMethod,const double,const double,
188     double *,ExceptionInfo *),
189   InterpolatePixelChannels(const Image *,const CacheView_ *,const Image *,
190     const PixelInterpolateMethod,const double,const double,Quantum *,
191     ExceptionInfo *),
192   InterpolatePixelInfo(const Image *,const CacheView_ *,
193     const PixelInterpolateMethod,const double,const double,PixelInfo *,
194     ExceptionInfo *),
195   IsFuzzyEquivalencePixel(const Image *,const Quantum *,const Image *,
196     const Quantum *),
197   IsFuzzyEquivalencePixelInfo(const PixelInfo *,const PixelInfo *),
198   SetPixelMetaChannels(Image *,const size_t,ExceptionInfo *);
199
200 extern MagickExport PixelChannelMap
201   *AcquirePixelChannelMap(void),
202   *ClonePixelChannelMap(PixelChannelMap *),
203   *DestroyPixelChannelMap(PixelChannelMap *);
204
205 extern MagickExport PixelInfo
206   *ClonePixelInfo(const PixelInfo *);
207
208 extern MagickExport void
209   InitializePixelChannelMap(Image *),
210   GetPixelInfo(const Image *,PixelInfo *),
211   SetPixelChannelMapMask(Image *,const ChannelType);
212
213 #if defined(__cplusplus) || defined(c_plusplus)
214 }
215 #endif
216
217 #endif