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