blob: 5c6285af2d255d8066451be6ecf3cf32e99e863d [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,
cristyb04db122013-04-11 10:26:01 +000098 MSPixelIntensityMethod,
cristyac73d1f2013-03-12 00:51:09 +000099 Rec601LumaPixelIntensityMethod,
cristy2cf5d372013-03-13 12:03:11 +0000100 Rec601LuminancePixelIntensityMethod,
cristyac73d1f2013-03-12 00:51:09 +0000101 Rec709LumaPixelIntensityMethod,
cristy2cf5d372013-03-13 12:03:11 +0000102 Rec709LuminancePixelIntensityMethod,
cristyac73d1f2013-03-12 00:51:09 +0000103 RMSPixelIntensityMethod
104} PixelIntensityMethod;
105
106typedef enum
107{
108 UndefinedInterpolatePixel,
109 AverageInterpolatePixel, /* Average 4 nearest neighbours */
110 Average9InterpolatePixel, /* Average 9 nearest neighbours */
111 Average16InterpolatePixel, /* Average 16 nearest neighbours */
112 BackgroundInterpolatePixel, /* Just return background color */
113 BilinearInterpolatePixel, /* Triangular filter interpolation */
114 BlendInterpolatePixel, /* blend of nearest 1, 2 or 4 pixels */
115 CatromInterpolatePixel, /* Catmull-Rom interpolation */
116 IntegerInterpolatePixel, /* Integer (floor) interpolation */
117 MeshInterpolatePixel, /* Triangular Mesh interpolation */
118 NearestInterpolatePixel, /* Nearest Neighbour Only */
119 SplineInterpolatePixel /* Cubic Spline (blurred) interpolation */
120 /* FilterInterpolatePixel, ** Use resize filter - (very slow) */
121} PixelInterpolateMethod;
122
123typedef enum
124{
cristycf5acb32013-03-22 01:11:49 +0000125 UndefinedPixelMask = 0x000000,
126 ReadPixelMask = 0x000001,
127 WritePixelMask = 0x000002
128} PixelMask;
129
130typedef enum
131{
cristy94bc3bf2011-07-04 18:55:37 +0000132 UndefinedPixelTrait = 0x000000,
cristyed231572011-07-14 02:18:59 +0000133 CopyPixelTrait = 0x000001,
134 UpdatePixelTrait = 0x000002,
135 BlendPixelTrait = 0x000004
cristy94bc3bf2011-07-04 18:55:37 +0000136} PixelTrait;
cristy4c08aed2011-07-01 19:47:50 +0000137
cristy8dfe0cb2013-03-27 22:27:53 +0000138typedef enum
139{
140 UndefinedPixel,
141 CharPixel,
142 DoublePixel,
143 FloatPixel,
144 LongPixel,
145 LongLongPixel,
146 QuantumPixel,
147 ShortPixel
148} StorageType;
149
150/*
151 Pixel typedef declarations.
152*/
cristyed231572011-07-14 02:18:59 +0000153typedef struct _PixelChannelMap
154{
155 PixelChannel
156 channel;
157
158 PixelTrait
159 traits;
cristye2a912b2011-12-05 20:02:07 +0000160
cristyd26338f2011-12-14 02:39:30 +0000161 ssize_t
cristye2a912b2011-12-05 20:02:07 +0000162 offset;
cristyed231572011-07-14 02:18:59 +0000163} PixelChannelMap;
164
cristy4c08aed2011-07-01 19:47:50 +0000165typedef struct _PixelInfo
166{
167 ClassType
168 storage_class;
169
170 ColorspaceType
171 colorspace;
172
cristy8a46d822012-08-28 23:32:39 +0000173 PixelTrait
174 alpha_trait;
cristy4c08aed2011-07-01 19:47:50 +0000175
176 double
177 fuzz;
178
179 size_t
180 depth;
181
cristy3094b7f2011-10-01 23:18:02 +0000182 MagickSizeType
183 count;
184
cristyc44100b2012-10-08 12:34:07 +0000185 MagickRealType
cristy4c08aed2011-07-01 19:47:50 +0000186 red,
187 green,
188 blue,
cristy4c08aed2011-07-01 19:47:50 +0000189 black,
cristy3094b7f2011-10-01 23:18:02 +0000190 alpha,
cristy4c08aed2011-07-01 19:47:50 +0000191 index;
192} PixelInfo;
193
cristy101ab702011-10-13 13:06:32 +0000194typedef struct _PixelPacket
cristy5c4e2582011-09-11 19:21:03 +0000195{
196 unsigned int
197 red,
198 green,
199 blue,
200 alpha,
201 black;
cristy4c08aed2011-07-01 19:47:50 +0000202} PixelPacket;
203
204typedef struct _CacheView
205 CacheView_;
206
cristy8dfe0cb2013-03-27 22:27:53 +0000207/*
208 Pixel method declarations.
209*/
cristy4c08aed2011-07-01 19:47:50 +0000210extern MagickExport MagickBooleanType
cristy2dc655d2012-07-05 13:16:28 +0000211 ExportImagePixels(Image *,const ssize_t,const ssize_t,const size_t,
cristy4c08aed2011-07-01 19:47:50 +0000212 const size_t,const char *,const StorageType,void *,ExceptionInfo *),
213 ImportImagePixels(Image *,const ssize_t,const ssize_t,const size_t,
cristy018f07f2011-09-04 21:15:19 +0000214 const size_t,const char *,const StorageType,const void *,ExceptionInfo *),
cristya085a432011-07-30 01:39:32 +0000215 InterpolatePixelChannel(const Image *,const CacheView_ *,
cristy5c4e2582011-09-11 19:21:03 +0000216 const PixelChannel,const PixelInterpolateMethod,const double,const double,
cristya085a432011-07-30 01:39:32 +0000217 double *,ExceptionInfo *),
cristy5c4e2582011-09-11 19:21:03 +0000218 InterpolatePixelChannels(const Image *,const CacheView_ *,const Image *,
219 const PixelInterpolateMethod,const double,const double,Quantum *,
220 ExceptionInfo *),
cristy4c08aed2011-07-01 19:47:50 +0000221 InterpolatePixelInfo(const Image *,const CacheView_ *,
cristy5c4e2582011-09-11 19:21:03 +0000222 const PixelInterpolateMethod,const double,const double,PixelInfo *,
cristy4c08aed2011-07-01 19:47:50 +0000223 ExceptionInfo *),
cristye4a40472011-12-22 02:56:19 +0000224 IsFuzzyEquivalencePixel(const Image *,const Quantum *,const Image *,
cristy4c08aed2011-07-01 19:47:50 +0000225 const Quantum *),
cristy322d07d2012-03-18 21:17:23 +0000226 IsFuzzyEquivalencePixelInfo(const PixelInfo *,const PixelInfo *),
227 SetPixelMetaChannels(Image *,const size_t,ExceptionInfo *);
cristy4c08aed2011-07-01 19:47:50 +0000228
cristy9731df72013-03-12 16:31:13 +0000229extern MagickExport MagickRealType
230 GetPixelIntensity(const Image *restrict,const Quantum *restrict)
231 magick_hot_spot;
232
cristyed231572011-07-14 02:18:59 +0000233extern MagickExport PixelChannelMap
cristybd5a96c2011-08-21 00:04:26 +0000234 *AcquirePixelChannelMap(void),
235 *ClonePixelChannelMap(PixelChannelMap *),
236 *DestroyPixelChannelMap(PixelChannelMap *);
cristy4c08aed2011-07-01 19:47:50 +0000237
238extern MagickExport PixelInfo
239 *ClonePixelInfo(const PixelInfo *);
240
cristyc8aff842012-12-24 16:59:46 +0000241extern MagickExport MagickRealType
cristy12059542012-12-24 18:45:40 +0000242 DecodePixelGamma(const MagickRealType) magick_hot_spot,
243 EncodePixelGamma(const MagickRealType) magick_hot_spot;
cristyc8aff842012-12-24 16:59:46 +0000244
cristy4c08aed2011-07-01 19:47:50 +0000245extern MagickExport void
cristybd5a96c2011-08-21 00:04:26 +0000246 InitializePixelChannelMap(Image *),
cristy2b9582a2011-07-04 17:38:56 +0000247 GetPixelInfo(const Image *,PixelInfo *),
cristycf1296e2012-08-26 23:40:49 +0000248 SetPixelChannelMask(Image *,const ChannelType);
cristy4c08aed2011-07-01 19:47:50 +0000249
250#if defined(__cplusplus) || defined(c_plusplus)
251}
252#endif
253
254#endif