blob: b935f4d44730fa03f6e63221a565fc92588e123f [file] [log] [blame]
cristy4c08aed2011-07-01 19:47:50 +00001/*
cristy45ef08f2012-12-07 13:13:34 +00002 Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization
cristy4c08aed2011-07-01 19:47:50 +00003 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
cristyd04e7bf2012-03-03 19:19:12 +000016 MagickCore image pixel methods.
cristy4c08aed2011-07-01 19:47:50 +000017*/
18#ifndef _MAGICKCORE_PIXEL_H
19#define _MAGICKCORE_PIXEL_H
20
21#if defined(__cplusplus) || defined(c_plusplus)
22extern "C" {
23#endif
24
cristyf697adb2013-01-11 12:20:05 +000025#include "MagickCore/colorspace.h"
cristy4c08aed2011-07-01 19:47:50 +000026
cristyed231572011-07-14 02:18:59 +000027#define MaxPixelChannels 32
cristy4af4a772011-09-07 21:40:44 +000028#undef index
cristy490408a2011-07-07 14:42:05 +000029
cristy8dfe0cb2013-03-27 22:27:53 +000030/*
31 Pixel enum declarations.
32*/
cristy4c08aed2011-07-01 19:47:50 +000033typedef enum
34{
cristyc8d63672012-01-11 13:03:13 +000035 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,
cristy883fde12013-04-08 00:50:13 +000047 ReadMaskChannel = 0x0040,
48 WriteMaskChannel = 0x0080,
49 MetaChannel = 0x0100,
cristyc8d63672012-01-11 13:03:13 +000050 CompositeChannels = 0x002F,
51 AllChannels = 0x7ffffff,
52 /*
53 Special purpose channel types.
anthonyaa6b0842012-03-22 00:25:25 +000054 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"
cristyc8d63672012-01-11 13:03:13 +000057 */
58 TrueAlphaChannel = 0x0100, /* extract actual alpha channel from opacity */
59 RGBChannels = 0x0200, /* set alpha from grayscale mask in RGB */
60 GrayChannels = 0x0400,
anthonyaa6b0842012-03-22 00:25:25 +000061 SyncChannels = 0x20000, /* channels modified as a single unit */
cristyc8d63672012-01-11 13:03:13 +000062 DefaultChannels = ((AllChannels | SyncChannels) &~ AlphaChannel)
63} ChannelType; /* must correspond to PixelChannel */
64
65typedef enum
66{
cristy6dcb9b82011-10-23 23:21:25 +000067 UndefinedPixelChannel = 0,
cristyed231572011-07-14 02:18:59 +000068 RedPixelChannel = 0,
69 CyanPixelChannel = 0,
70 GrayPixelChannel = 0,
cristyb5649542012-06-30 22:46:15 +000071 LPixelChannel = 0,
cristyed231572011-07-14 02:18:59 +000072 YPixelChannel = 0,
cristyb5649542012-06-30 22:46:15 +000073 aPixelChannel = 1,
cristyed231572011-07-14 02:18:59 +000074 GreenPixelChannel = 1,
75 MagentaPixelChannel = 1,
76 CbPixelChannel = 1,
cristyb5649542012-06-30 22:46:15 +000077 bPixelChannel = 2,
cristyed231572011-07-14 02:18:59 +000078 BluePixelChannel = 2,
79 YellowPixelChannel = 2,
80 CrPixelChannel = 2,
cristye2a912b2011-12-05 20:02:07 +000081 BlackPixelChannel = 3,
82 AlphaPixelChannel = 4,
83 IndexPixelChannel = 5,
cristy883fde12013-04-08 00:50:13 +000084 ReadMaskPixelChannel = 6,
85 WriteMaskPixelChannel = 7,
86 MetaPixelChannel = 8,
87 IntensityPixelChannel = MaxPixelChannels,
cristy5f95f4f2011-10-23 01:01:01 +000088 CompositePixelChannel = MaxPixelChannels,
cristy2bddff82011-07-25 18:39:12 +000089 SyncPixelChannel = MaxPixelChannels+1
cristyc8d63672012-01-11 13:03:13 +000090} PixelChannel; /* must correspond to ChannelType */
cristy4c08aed2011-07-01 19:47:50 +000091
92typedef enum
93{
cristyac73d1f2013-03-12 00:51:09 +000094 UndefinedPixelIntensityMethod = 0,
95 AveragePixelIntensityMethod,
96 BrightnessPixelIntensityMethod,
97 LightnessPixelIntensityMethod,
98 Rec601LumaPixelIntensityMethod,
cristy2cf5d372013-03-13 12:03:11 +000099 Rec601LuminancePixelIntensityMethod,
cristyac73d1f2013-03-12 00:51:09 +0000100 Rec709LumaPixelIntensityMethod,
cristy2cf5d372013-03-13 12:03:11 +0000101 Rec709LuminancePixelIntensityMethod,
cristyac73d1f2013-03-12 00:51:09 +0000102 RMSPixelIntensityMethod
103} PixelIntensityMethod;
104
105typedef enum
106{
107 UndefinedInterpolatePixel,
108 AverageInterpolatePixel, /* Average 4 nearest neighbours */
109 Average9InterpolatePixel, /* Average 9 nearest neighbours */
110 Average16InterpolatePixel, /* Average 16 nearest neighbours */
111 BackgroundInterpolatePixel, /* Just return background color */
112 BilinearInterpolatePixel, /* Triangular filter interpolation */
113 BlendInterpolatePixel, /* blend of nearest 1, 2 or 4 pixels */
114 CatromInterpolatePixel, /* Catmull-Rom interpolation */
115 IntegerInterpolatePixel, /* Integer (floor) interpolation */
116 MeshInterpolatePixel, /* Triangular Mesh interpolation */
117 NearestInterpolatePixel, /* Nearest Neighbour Only */
118 SplineInterpolatePixel /* Cubic Spline (blurred) interpolation */
119 /* FilterInterpolatePixel, ** Use resize filter - (very slow) */
120} PixelInterpolateMethod;
121
122typedef enum
123{
cristycf5acb32013-03-22 01:11:49 +0000124 UndefinedPixelMask = 0x000000,
125 ReadPixelMask = 0x000001,
126 WritePixelMask = 0x000002
127} PixelMask;
128
129typedef enum
130{
cristy94bc3bf2011-07-04 18:55:37 +0000131 UndefinedPixelTrait = 0x000000,
cristyed231572011-07-14 02:18:59 +0000132 CopyPixelTrait = 0x000001,
133 UpdatePixelTrait = 0x000002,
134 BlendPixelTrait = 0x000004
cristy94bc3bf2011-07-04 18:55:37 +0000135} PixelTrait;
cristy4c08aed2011-07-01 19:47:50 +0000136
cristy8dfe0cb2013-03-27 22:27:53 +0000137typedef enum
138{
139 UndefinedPixel,
140 CharPixel,
141 DoublePixel,
142 FloatPixel,
143 LongPixel,
144 LongLongPixel,
145 QuantumPixel,
146 ShortPixel
147} StorageType;
148
149/*
150 Pixel typedef declarations.
151*/
cristyed231572011-07-14 02:18:59 +0000152typedef struct _PixelChannelMap
153{
154 PixelChannel
155 channel;
156
157 PixelTrait
158 traits;
cristye2a912b2011-12-05 20:02:07 +0000159
cristyd26338f2011-12-14 02:39:30 +0000160 ssize_t
cristye2a912b2011-12-05 20:02:07 +0000161 offset;
cristyed231572011-07-14 02:18:59 +0000162} PixelChannelMap;
163
cristy4c08aed2011-07-01 19:47:50 +0000164typedef struct _PixelInfo
165{
166 ClassType
167 storage_class;
168
169 ColorspaceType
170 colorspace;
171
cristy8a46d822012-08-28 23:32:39 +0000172 PixelTrait
173 alpha_trait;
cristy4c08aed2011-07-01 19:47:50 +0000174
175 double
176 fuzz;
177
178 size_t
179 depth;
180
cristy3094b7f2011-10-01 23:18:02 +0000181 MagickSizeType
182 count;
183
cristyc44100b2012-10-08 12:34:07 +0000184 MagickRealType
cristy4c08aed2011-07-01 19:47:50 +0000185 red,
186 green,
187 blue,
cristy4c08aed2011-07-01 19:47:50 +0000188 black,
cristy3094b7f2011-10-01 23:18:02 +0000189 alpha,
cristy4c08aed2011-07-01 19:47:50 +0000190 index;
191} PixelInfo;
192
cristy101ab702011-10-13 13:06:32 +0000193typedef struct _PixelPacket
cristy5c4e2582011-09-11 19:21:03 +0000194{
195 unsigned int
196 red,
197 green,
198 blue,
199 alpha,
200 black;
cristy4c08aed2011-07-01 19:47:50 +0000201} PixelPacket;
202
203typedef struct _CacheView
204 CacheView_;
205
cristy8dfe0cb2013-03-27 22:27:53 +0000206/*
207 Pixel method declarations.
208*/
cristy4c08aed2011-07-01 19:47:50 +0000209extern MagickExport MagickBooleanType
cristy2dc655d2012-07-05 13:16:28 +0000210 ExportImagePixels(Image *,const ssize_t,const ssize_t,const size_t,
cristy4c08aed2011-07-01 19:47:50 +0000211 const size_t,const char *,const StorageType,void *,ExceptionInfo *),
212 ImportImagePixels(Image *,const ssize_t,const ssize_t,const size_t,
cristy018f07f2011-09-04 21:15:19 +0000213 const size_t,const char *,const StorageType,const void *,ExceptionInfo *),
cristya085a432011-07-30 01:39:32 +0000214 InterpolatePixelChannel(const Image *,const CacheView_ *,
cristy5c4e2582011-09-11 19:21:03 +0000215 const PixelChannel,const PixelInterpolateMethod,const double,const double,
cristya085a432011-07-30 01:39:32 +0000216 double *,ExceptionInfo *),
cristy5c4e2582011-09-11 19:21:03 +0000217 InterpolatePixelChannels(const Image *,const CacheView_ *,const Image *,
218 const PixelInterpolateMethod,const double,const double,Quantum *,
219 ExceptionInfo *),
cristy4c08aed2011-07-01 19:47:50 +0000220 InterpolatePixelInfo(const Image *,const CacheView_ *,
cristy5c4e2582011-09-11 19:21:03 +0000221 const PixelInterpolateMethod,const double,const double,PixelInfo *,
cristy4c08aed2011-07-01 19:47:50 +0000222 ExceptionInfo *),
cristye4a40472011-12-22 02:56:19 +0000223 IsFuzzyEquivalencePixel(const Image *,const Quantum *,const Image *,
cristy4c08aed2011-07-01 19:47:50 +0000224 const Quantum *),
cristy322d07d2012-03-18 21:17:23 +0000225 IsFuzzyEquivalencePixelInfo(const PixelInfo *,const PixelInfo *),
226 SetPixelMetaChannels(Image *,const size_t,ExceptionInfo *);
cristy4c08aed2011-07-01 19:47:50 +0000227
cristy9731df72013-03-12 16:31:13 +0000228extern MagickExport MagickRealType
229 GetPixelIntensity(const Image *restrict,const Quantum *restrict)
230 magick_hot_spot;
231
cristyed231572011-07-14 02:18:59 +0000232extern MagickExport PixelChannelMap
cristybd5a96c2011-08-21 00:04:26 +0000233 *AcquirePixelChannelMap(void),
234 *ClonePixelChannelMap(PixelChannelMap *),
235 *DestroyPixelChannelMap(PixelChannelMap *);
cristy4c08aed2011-07-01 19:47:50 +0000236
237extern MagickExport PixelInfo
238 *ClonePixelInfo(const PixelInfo *);
239
cristyc8aff842012-12-24 16:59:46 +0000240extern MagickExport MagickRealType
cristy12059542012-12-24 18:45:40 +0000241 DecodePixelGamma(const MagickRealType) magick_hot_spot,
242 EncodePixelGamma(const MagickRealType) magick_hot_spot;
cristyc8aff842012-12-24 16:59:46 +0000243
cristy4c08aed2011-07-01 19:47:50 +0000244extern MagickExport void
cristybd5a96c2011-08-21 00:04:26 +0000245 InitializePixelChannelMap(Image *),
cristy2b9582a2011-07-04 17:38:56 +0000246 GetPixelInfo(const Image *,PixelInfo *),
cristycf1296e2012-08-26 23:40:49 +0000247 SetPixelChannelMask(Image *,const ChannelType);
cristy4c08aed2011-07-01 19:47:50 +0000248
249#if defined(__cplusplus) || defined(c_plusplus)
250}
251#endif
252
253#endif