blob: 851501c8a9c49cd198d451afe7b1fcb4f1b37064 [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,
47 MaskChannel = 0x0040,
48 MetaChannel = 0x0080,
49 CompositeChannels = 0x002F,
50 AllChannels = 0x7ffffff,
51 /*
52 Special purpose channel types.
anthonyaa6b0842012-03-22 00:25:25 +000053 FUTURE: are these needed any more - they are more like hacks
54 SyncChannels for example is NOT a real channel but a 'flag'
55 It really says -- "User has not defined channels"
cristyc8d63672012-01-11 13:03:13 +000056 */
57 TrueAlphaChannel = 0x0100, /* extract actual alpha channel from opacity */
58 RGBChannels = 0x0200, /* set alpha from grayscale mask in RGB */
59 GrayChannels = 0x0400,
anthonyaa6b0842012-03-22 00:25:25 +000060 SyncChannels = 0x20000, /* channels modified as a single unit */
cristyc8d63672012-01-11 13:03:13 +000061 DefaultChannels = ((AllChannels | SyncChannels) &~ AlphaChannel)
62} ChannelType; /* must correspond to PixelChannel */
63
64typedef enum
65{
cristy6dcb9b82011-10-23 23:21:25 +000066 UndefinedPixelChannel = 0,
cristyed231572011-07-14 02:18:59 +000067 RedPixelChannel = 0,
68 CyanPixelChannel = 0,
69 GrayPixelChannel = 0,
cristyb5649542012-06-30 22:46:15 +000070 LPixelChannel = 0,
cristyed231572011-07-14 02:18:59 +000071 YPixelChannel = 0,
cristyb5649542012-06-30 22:46:15 +000072 aPixelChannel = 1,
cristyed231572011-07-14 02:18:59 +000073 GreenPixelChannel = 1,
74 MagentaPixelChannel = 1,
75 CbPixelChannel = 1,
cristyb5649542012-06-30 22:46:15 +000076 bPixelChannel = 2,
cristyed231572011-07-14 02:18:59 +000077 BluePixelChannel = 2,
78 YellowPixelChannel = 2,
79 CrPixelChannel = 2,
cristye2a912b2011-12-05 20:02:07 +000080 BlackPixelChannel = 3,
81 AlphaPixelChannel = 4,
82 IndexPixelChannel = 5,
anthonyaa6b0842012-03-22 00:25:25 +000083 MaskPixelChannel = 6, /* Image Write Mask */
84 MetaPixelChannel = 7, /* ??? */
85 IntensityPixelChannel = MaxPixelChannels, /* what are these ??? */
cristy5f95f4f2011-10-23 01:01:01 +000086 CompositePixelChannel = MaxPixelChannels,
cristy2bddff82011-07-25 18:39:12 +000087 SyncPixelChannel = MaxPixelChannels+1
cristyc8d63672012-01-11 13:03:13 +000088} PixelChannel; /* must correspond to ChannelType */
cristy4c08aed2011-07-01 19:47:50 +000089
90typedef enum
91{
cristyac73d1f2013-03-12 00:51:09 +000092 UndefinedPixelIntensityMethod = 0,
93 AveragePixelIntensityMethod,
94 BrightnessPixelIntensityMethod,
95 LightnessPixelIntensityMethod,
96 Rec601LumaPixelIntensityMethod,
cristy2cf5d372013-03-13 12:03:11 +000097 Rec601LuminancePixelIntensityMethod,
cristyac73d1f2013-03-12 00:51:09 +000098 Rec709LumaPixelIntensityMethod,
cristy2cf5d372013-03-13 12:03:11 +000099 Rec709LuminancePixelIntensityMethod,
cristyac73d1f2013-03-12 00:51:09 +0000100 RMSPixelIntensityMethod
101} PixelIntensityMethod;
102
103typedef enum
104{
105 UndefinedInterpolatePixel,
106 AverageInterpolatePixel, /* Average 4 nearest neighbours */
107 Average9InterpolatePixel, /* Average 9 nearest neighbours */
108 Average16InterpolatePixel, /* Average 16 nearest neighbours */
109 BackgroundInterpolatePixel, /* Just return background color */
110 BilinearInterpolatePixel, /* Triangular filter interpolation */
111 BlendInterpolatePixel, /* blend of nearest 1, 2 or 4 pixels */
112 CatromInterpolatePixel, /* Catmull-Rom interpolation */
113 IntegerInterpolatePixel, /* Integer (floor) interpolation */
114 MeshInterpolatePixel, /* Triangular Mesh interpolation */
115 NearestInterpolatePixel, /* Nearest Neighbour Only */
116 SplineInterpolatePixel /* Cubic Spline (blurred) interpolation */
117 /* FilterInterpolatePixel, ** Use resize filter - (very slow) */
118} PixelInterpolateMethod;
119
120typedef enum
121{
cristycf5acb32013-03-22 01:11:49 +0000122 UndefinedPixelMask = 0x000000,
123 ReadPixelMask = 0x000001,
124 WritePixelMask = 0x000002
125} PixelMask;
126
127typedef enum
128{
cristy94bc3bf2011-07-04 18:55:37 +0000129 UndefinedPixelTrait = 0x000000,
cristyed231572011-07-14 02:18:59 +0000130 CopyPixelTrait = 0x000001,
131 UpdatePixelTrait = 0x000002,
132 BlendPixelTrait = 0x000004
cristy94bc3bf2011-07-04 18:55:37 +0000133} PixelTrait;
cristy4c08aed2011-07-01 19:47:50 +0000134
cristy8dfe0cb2013-03-27 22:27:53 +0000135typedef enum
136{
137 UndefinedPixel,
138 CharPixel,
139 DoublePixel,
140 FloatPixel,
141 LongPixel,
142 LongLongPixel,
143 QuantumPixel,
144 ShortPixel
145} StorageType;
146
147/*
148 Pixel typedef declarations.
149*/
cristyed231572011-07-14 02:18:59 +0000150typedef struct _PixelChannelMap
151{
152 PixelChannel
153 channel;
154
155 PixelTrait
156 traits;
cristye2a912b2011-12-05 20:02:07 +0000157
cristyd26338f2011-12-14 02:39:30 +0000158 ssize_t
cristye2a912b2011-12-05 20:02:07 +0000159 offset;
cristyed231572011-07-14 02:18:59 +0000160} PixelChannelMap;
161
cristy4c08aed2011-07-01 19:47:50 +0000162typedef struct _PixelInfo
163{
164 ClassType
165 storage_class;
166
167 ColorspaceType
168 colorspace;
169
cristy8a46d822012-08-28 23:32:39 +0000170 PixelTrait
171 alpha_trait;
cristy4c08aed2011-07-01 19:47:50 +0000172
173 double
174 fuzz;
175
176 size_t
177 depth;
178
cristy3094b7f2011-10-01 23:18:02 +0000179 MagickSizeType
180 count;
181
cristyc44100b2012-10-08 12:34:07 +0000182 MagickRealType
cristy4c08aed2011-07-01 19:47:50 +0000183 red,
184 green,
185 blue,
cristy4c08aed2011-07-01 19:47:50 +0000186 black,
cristy3094b7f2011-10-01 23:18:02 +0000187 alpha,
cristy4c08aed2011-07-01 19:47:50 +0000188 index;
189} PixelInfo;
190
cristy101ab702011-10-13 13:06:32 +0000191typedef struct _PixelPacket
cristy5c4e2582011-09-11 19:21:03 +0000192{
193 unsigned int
194 red,
195 green,
196 blue,
197 alpha,
198 black;
cristy4c08aed2011-07-01 19:47:50 +0000199} PixelPacket;
200
201typedef struct _CacheView
202 CacheView_;
203
cristy8dfe0cb2013-03-27 22:27:53 +0000204/*
205 Pixel method declarations.
206*/
cristy4c08aed2011-07-01 19:47:50 +0000207extern MagickExport MagickBooleanType
cristy2dc655d2012-07-05 13:16:28 +0000208 ExportImagePixels(Image *,const ssize_t,const ssize_t,const size_t,
cristy4c08aed2011-07-01 19:47:50 +0000209 const size_t,const char *,const StorageType,void *,ExceptionInfo *),
210 ImportImagePixels(Image *,const ssize_t,const ssize_t,const size_t,
cristy018f07f2011-09-04 21:15:19 +0000211 const size_t,const char *,const StorageType,const void *,ExceptionInfo *),
cristya085a432011-07-30 01:39:32 +0000212 InterpolatePixelChannel(const Image *,const CacheView_ *,
cristy5c4e2582011-09-11 19:21:03 +0000213 const PixelChannel,const PixelInterpolateMethod,const double,const double,
cristya085a432011-07-30 01:39:32 +0000214 double *,ExceptionInfo *),
cristy5c4e2582011-09-11 19:21:03 +0000215 InterpolatePixelChannels(const Image *,const CacheView_ *,const Image *,
216 const PixelInterpolateMethod,const double,const double,Quantum *,
217 ExceptionInfo *),
cristy4c08aed2011-07-01 19:47:50 +0000218 InterpolatePixelInfo(const Image *,const CacheView_ *,
cristy5c4e2582011-09-11 19:21:03 +0000219 const PixelInterpolateMethod,const double,const double,PixelInfo *,
cristy4c08aed2011-07-01 19:47:50 +0000220 ExceptionInfo *),
cristye4a40472011-12-22 02:56:19 +0000221 IsFuzzyEquivalencePixel(const Image *,const Quantum *,const Image *,
cristy4c08aed2011-07-01 19:47:50 +0000222 const Quantum *),
cristy322d07d2012-03-18 21:17:23 +0000223 IsFuzzyEquivalencePixelInfo(const PixelInfo *,const PixelInfo *),
224 SetPixelMetaChannels(Image *,const size_t,ExceptionInfo *);
cristy4c08aed2011-07-01 19:47:50 +0000225
cristy9731df72013-03-12 16:31:13 +0000226extern MagickExport MagickRealType
227 GetPixelIntensity(const Image *restrict,const Quantum *restrict)
228 magick_hot_spot;
229
cristyed231572011-07-14 02:18:59 +0000230extern MagickExport PixelChannelMap
cristybd5a96c2011-08-21 00:04:26 +0000231 *AcquirePixelChannelMap(void),
232 *ClonePixelChannelMap(PixelChannelMap *),
233 *DestroyPixelChannelMap(PixelChannelMap *);
cristy4c08aed2011-07-01 19:47:50 +0000234
235extern MagickExport PixelInfo
236 *ClonePixelInfo(const PixelInfo *);
237
cristyc8aff842012-12-24 16:59:46 +0000238extern MagickExport MagickRealType
cristy12059542012-12-24 18:45:40 +0000239 DecodePixelGamma(const MagickRealType) magick_hot_spot,
240 EncodePixelGamma(const MagickRealType) magick_hot_spot;
cristyc8aff842012-12-24 16:59:46 +0000241
cristy4c08aed2011-07-01 19:47:50 +0000242extern MagickExport void
cristybd5a96c2011-08-21 00:04:26 +0000243 InitializePixelChannelMap(Image *),
cristy2b9582a2011-07-04 17:38:56 +0000244 GetPixelInfo(const Image *,PixelInfo *),
cristycf1296e2012-08-26 23:40:49 +0000245 SetPixelChannelMask(Image *,const ChannelType);
cristy4c08aed2011-07-01 19:47:50 +0000246
247#if defined(__cplusplus) || defined(c_plusplus)
248}
249#endif
250
251#endif