blob: f610bf32e3eca026517fd83036a7914fd6913f6f [file] [log] [blame]
cristy4c08aed2011-07-01 19:47:50 +00001/*
cristyb56bb242014-11-25 17:12:48 +00002 Copyright 1999-2015 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
cristy6398ec72013-11-28 02:00:27 +000021#include "MagickCore/colorspace.h"
22
cristy4c08aed2011-07-01 19:47:50 +000023#if defined(__cplusplus) || defined(c_plusplus)
24extern "C" {
25#endif
26
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,
anthony4023b262013-06-03 07:43:50 +000046 IndexChannel = 0x0020, /* Color Index Table? */
47 ReadMaskChannel = 0x0040, /* Pixel is Not Readable? */
48 WriteMaskChannel = 0x0080, /* Pixel is Write Protected? */
49 MetaChannel = 0x0100, /* ???? */
cristy89971ad2014-01-10 13:15:35 +000050 CompositeChannels = 0x002F,
cristyc8d63672012-01-11 13:03:13 +000051 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"
anthony4023b262013-06-03 07:43:50 +000057 Though it does have extra meaning in the "-auto-level" operator
cristyc8d63672012-01-11 13:03:13 +000058 */
59 TrueAlphaChannel = 0x0100, /* extract actual alpha channel from opacity */
60 RGBChannels = 0x0200, /* set alpha from grayscale mask in RGB */
61 GrayChannels = 0x0400,
anthonyaa6b0842012-03-22 00:25:25 +000062 SyncChannels = 0x20000, /* channels modified as a single unit */
cristy6aeeb022014-09-28 18:48:50 +000063 DefaultChannels = AllChannels
cristyc8d63672012-01-11 13:03:13 +000064} ChannelType; /* must correspond to PixelChannel */
65
66typedef enum
67{
cristy6dcb9b82011-10-23 23:21:25 +000068 UndefinedPixelChannel = 0,
cristyed231572011-07-14 02:18:59 +000069 RedPixelChannel = 0,
70 CyanPixelChannel = 0,
71 GrayPixelChannel = 0,
cristyb5649542012-06-30 22:46:15 +000072 LPixelChannel = 0,
cristyed231572011-07-14 02:18:59 +000073 YPixelChannel = 0,
cristyb5649542012-06-30 22:46:15 +000074 aPixelChannel = 1,
cristyed231572011-07-14 02:18:59 +000075 GreenPixelChannel = 1,
76 MagentaPixelChannel = 1,
77 CbPixelChannel = 1,
cristyb5649542012-06-30 22:46:15 +000078 bPixelChannel = 2,
cristyed231572011-07-14 02:18:59 +000079 BluePixelChannel = 2,
80 YellowPixelChannel = 2,
81 CrPixelChannel = 2,
cristye2a912b2011-12-05 20:02:07 +000082 BlackPixelChannel = 3,
83 AlphaPixelChannel = 4,
84 IndexPixelChannel = 5,
cristy883fde12013-04-08 00:50:13 +000085 ReadMaskPixelChannel = 6,
86 WriteMaskPixelChannel = 7,
87 MetaPixelChannel = 8,
anthony4023b262013-06-03 07:43:50 +000088 IntensityPixelChannel = MaxPixelChannels, /* ???? */
89 CompositePixelChannel = MaxPixelChannels, /* ???? */
90 SyncPixelChannel = MaxPixelChannels+1 /* not a real channel */
cristyc8d63672012-01-11 13:03:13 +000091} PixelChannel; /* must correspond to ChannelType */
cristy4c08aed2011-07-01 19:47:50 +000092
93typedef enum
94{
cristyac73d1f2013-03-12 00:51:09 +000095 UndefinedPixelIntensityMethod = 0,
96 AveragePixelIntensityMethod,
97 BrightnessPixelIntensityMethod,
98 LightnessPixelIntensityMethod,
cristyb04db122013-04-11 10:26:01 +000099 MSPixelIntensityMethod,
cristyac73d1f2013-03-12 00:51:09 +0000100 Rec601LumaPixelIntensityMethod,
cristy2cf5d372013-03-13 12:03:11 +0000101 Rec601LuminancePixelIntensityMethod,
cristyac73d1f2013-03-12 00:51:09 +0000102 Rec709LumaPixelIntensityMethod,
cristy2cf5d372013-03-13 12:03:11 +0000103 Rec709LuminancePixelIntensityMethod,
cristyac73d1f2013-03-12 00:51:09 +0000104 RMSPixelIntensityMethod
105} PixelIntensityMethod;
106
107typedef enum
108{
109 UndefinedInterpolatePixel,
110 AverageInterpolatePixel, /* Average 4 nearest neighbours */
111 Average9InterpolatePixel, /* Average 9 nearest neighbours */
112 Average16InterpolatePixel, /* Average 16 nearest neighbours */
113 BackgroundInterpolatePixel, /* Just return background color */
114 BilinearInterpolatePixel, /* Triangular filter interpolation */
115 BlendInterpolatePixel, /* blend of nearest 1, 2 or 4 pixels */
116 CatromInterpolatePixel, /* Catmull-Rom interpolation */
117 IntegerInterpolatePixel, /* Integer (floor) interpolation */
118 MeshInterpolatePixel, /* Triangular Mesh interpolation */
119 NearestInterpolatePixel, /* Nearest Neighbour Only */
anthony4023b262013-06-03 07:43:50 +0000120 SplineInterpolatePixel /* Cubic Spline (blurred) interpolation */
cristyac73d1f2013-03-12 00:51:09 +0000121 /* FilterInterpolatePixel, ** Use resize filter - (very slow) */
122} PixelInterpolateMethod;
123
124typedef enum
125{
cristycf5acb32013-03-22 01:11:49 +0000126 UndefinedPixelMask = 0x000000,
127 ReadPixelMask = 0x000001,
128 WritePixelMask = 0x000002
129} PixelMask;
130
131typedef enum
132{
cristy94bc3bf2011-07-04 18:55:37 +0000133 UndefinedPixelTrait = 0x000000,
cristyed231572011-07-14 02:18:59 +0000134 CopyPixelTrait = 0x000001,
135 UpdatePixelTrait = 0x000002,
136 BlendPixelTrait = 0x000004
cristy94bc3bf2011-07-04 18:55:37 +0000137} PixelTrait;
cristy4c08aed2011-07-01 19:47:50 +0000138
cristy8dfe0cb2013-03-27 22:27:53 +0000139typedef enum
140{
141 UndefinedPixel,
142 CharPixel,
143 DoublePixel,
144 FloatPixel,
145 LongPixel,
146 LongLongPixel,
147 QuantumPixel,
148 ShortPixel
149} StorageType;
150
151/*
152 Pixel typedef declarations.
153*/
cristyed231572011-07-14 02:18:59 +0000154typedef struct _PixelChannelMap
155{
156 PixelChannel
157 channel;
158
159 PixelTrait
160 traits;
cristye2a912b2011-12-05 20:02:07 +0000161
cristyd26338f2011-12-14 02:39:30 +0000162 ssize_t
cristye2a912b2011-12-05 20:02:07 +0000163 offset;
cristyed231572011-07-14 02:18:59 +0000164} PixelChannelMap;
165
cristy4c08aed2011-07-01 19:47:50 +0000166typedef struct _PixelInfo
167{
168 ClassType
169 storage_class;
170
171 ColorspaceType
172 colorspace;
173
cristy8a46d822012-08-28 23:32:39 +0000174 PixelTrait
175 alpha_trait;
cristy4c08aed2011-07-01 19:47:50 +0000176
177 double
178 fuzz;
179
180 size_t
181 depth;
182
cristy3094b7f2011-10-01 23:18:02 +0000183 MagickSizeType
184 count;
185
cristyc44100b2012-10-08 12:34:07 +0000186 MagickRealType
cristy4c08aed2011-07-01 19:47:50 +0000187 red,
188 green,
189 blue,
cristy4c08aed2011-07-01 19:47:50 +0000190 black,
cristy3094b7f2011-10-01 23:18:02 +0000191 alpha,
cristy4c08aed2011-07-01 19:47:50 +0000192 index;
193} PixelInfo;
194
cristy101ab702011-10-13 13:06:32 +0000195typedef struct _PixelPacket
cristy5c4e2582011-09-11 19:21:03 +0000196{
197 unsigned int
198 red,
199 green,
200 blue,
201 alpha,
202 black;
cristy4c08aed2011-07-01 19:47:50 +0000203} PixelPacket;
204
205typedef struct _CacheView
206 CacheView_;
207
cristy8dfe0cb2013-03-27 22:27:53 +0000208/*
209 Pixel method declarations.
210*/
cristybcd59342015-06-07 14:07:19 +0000211extern MagickExport ChannelType
212 SetPixelChannelMask(Image *,const ChannelType);
213
cristy4c08aed2011-07-01 19:47:50 +0000214extern MagickExport MagickBooleanType
cristy2dc655d2012-07-05 13:16:28 +0000215 ExportImagePixels(Image *,const ssize_t,const ssize_t,const size_t,
cristy4c08aed2011-07-01 19:47:50 +0000216 const size_t,const char *,const StorageType,void *,ExceptionInfo *),
217 ImportImagePixels(Image *,const ssize_t,const ssize_t,const size_t,
cristy018f07f2011-09-04 21:15:19 +0000218 const size_t,const char *,const StorageType,const void *,ExceptionInfo *),
cristya085a432011-07-30 01:39:32 +0000219 InterpolatePixelChannel(const Image *,const CacheView_ *,
cristy5c4e2582011-09-11 19:21:03 +0000220 const PixelChannel,const PixelInterpolateMethod,const double,const double,
cristya085a432011-07-30 01:39:32 +0000221 double *,ExceptionInfo *),
cristy5c4e2582011-09-11 19:21:03 +0000222 InterpolatePixelChannels(const Image *,const CacheView_ *,const Image *,
223 const PixelInterpolateMethod,const double,const double,Quantum *,
224 ExceptionInfo *),
cristy4c08aed2011-07-01 19:47:50 +0000225 InterpolatePixelInfo(const Image *,const CacheView_ *,
cristy5c4e2582011-09-11 19:21:03 +0000226 const PixelInterpolateMethod,const double,const double,PixelInfo *,
cristy4c08aed2011-07-01 19:47:50 +0000227 ExceptionInfo *),
cristye4a40472011-12-22 02:56:19 +0000228 IsFuzzyEquivalencePixel(const Image *,const Quantum *,const Image *,
cristy4c08aed2011-07-01 19:47:50 +0000229 const Quantum *),
cristy322d07d2012-03-18 21:17:23 +0000230 IsFuzzyEquivalencePixelInfo(const PixelInfo *,const PixelInfo *),
231 SetPixelMetaChannels(Image *,const size_t,ExceptionInfo *);
cristy4c08aed2011-07-01 19:47:50 +0000232
cristy9731df72013-03-12 16:31:13 +0000233extern MagickExport MagickRealType
dirk05d2ff72015-11-18 23:13:43 +0100234 GetPixelInfoIntensity(const Image *magick_restrict,
235 const PixelInfo *magick_restrict) magick_hot_spot,
236 GetPixelIntensity(const Image *magick_restrict,
237 const Quantum *magick_restrict) magick_hot_spot;
cristy9731df72013-03-12 16:31:13 +0000238
cristyed231572011-07-14 02:18:59 +0000239extern MagickExport PixelChannelMap
cristybd5a96c2011-08-21 00:04:26 +0000240 *AcquirePixelChannelMap(void),
241 *ClonePixelChannelMap(PixelChannelMap *),
242 *DestroyPixelChannelMap(PixelChannelMap *);
cristy4c08aed2011-07-01 19:47:50 +0000243
244extern MagickExport PixelInfo
245 *ClonePixelInfo(const PixelInfo *);
246
cristyc8aff842012-12-24 16:59:46 +0000247extern MagickExport MagickRealType
cristy12059542012-12-24 18:45:40 +0000248 DecodePixelGamma(const MagickRealType) magick_hot_spot,
249 EncodePixelGamma(const MagickRealType) magick_hot_spot;
cristyc8aff842012-12-24 16:59:46 +0000250
cristy4c08aed2011-07-01 19:47:50 +0000251extern MagickExport void
dirkbfdd5bc2014-11-04 19:47:44 +0000252 ConformPixelInfo(Image *,const PixelInfo *,PixelInfo *,ExceptionInfo *),
cristy2b9582a2011-07-04 17:38:56 +0000253 GetPixelInfo(const Image *,PixelInfo *),
cristybcd59342015-06-07 14:07:19 +0000254 InitializePixelChannelMap(Image *);
cristy4c08aed2011-07-01 19:47:50 +0000255
256#if defined(__cplusplus) || defined(c_plusplus)
257}
258#endif
259
260#endif