blob: f9f0b1f51411464d873a60552baf6109a63548e6 [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
cristy4c08aed2011-07-01 19:47:50 +000030typedef enum
31{
cristyc8d63672012-01-11 13:03:13 +000032 UndefinedChannel = 0x0000,
33 RedChannel = 0x0001,
34 GrayChannel = 0x0001,
35 CyanChannel = 0x0001,
36 GreenChannel = 0x0002,
37 MagentaChannel = 0x0002,
38 BlueChannel = 0x0004,
39 YellowChannel = 0x0004,
40 BlackChannel = 0x0008,
41 AlphaChannel = 0x0010,
42 OpacityChannel = 0x0010,
43 IndexChannel = 0x0020,
44 MaskChannel = 0x0040,
45 MetaChannel = 0x0080,
46 CompositeChannels = 0x002F,
47 AllChannels = 0x7ffffff,
48 /*
49 Special purpose channel types.
anthonyaa6b0842012-03-22 00:25:25 +000050 FUTURE: are these needed any more - they are more like hacks
51 SyncChannels for example is NOT a real channel but a 'flag'
52 It really says -- "User has not defined channels"
cristyc8d63672012-01-11 13:03:13 +000053 */
54 TrueAlphaChannel = 0x0100, /* extract actual alpha channel from opacity */
55 RGBChannels = 0x0200, /* set alpha from grayscale mask in RGB */
56 GrayChannels = 0x0400,
anthonyaa6b0842012-03-22 00:25:25 +000057 SyncChannels = 0x20000, /* channels modified as a single unit */
cristyc8d63672012-01-11 13:03:13 +000058 DefaultChannels = ((AllChannels | SyncChannels) &~ AlphaChannel)
59} ChannelType; /* must correspond to PixelChannel */
60
61typedef enum
62{
cristy6dcb9b82011-10-23 23:21:25 +000063 UndefinedPixelChannel = 0,
cristyed231572011-07-14 02:18:59 +000064 RedPixelChannel = 0,
65 CyanPixelChannel = 0,
66 GrayPixelChannel = 0,
cristyb5649542012-06-30 22:46:15 +000067 LPixelChannel = 0,
cristyed231572011-07-14 02:18:59 +000068 YPixelChannel = 0,
cristyb5649542012-06-30 22:46:15 +000069 aPixelChannel = 1,
cristyed231572011-07-14 02:18:59 +000070 GreenPixelChannel = 1,
71 MagentaPixelChannel = 1,
72 CbPixelChannel = 1,
cristyb5649542012-06-30 22:46:15 +000073 bPixelChannel = 2,
cristyed231572011-07-14 02:18:59 +000074 BluePixelChannel = 2,
75 YellowPixelChannel = 2,
76 CrPixelChannel = 2,
cristye2a912b2011-12-05 20:02:07 +000077 BlackPixelChannel = 3,
78 AlphaPixelChannel = 4,
79 IndexPixelChannel = 5,
anthonyaa6b0842012-03-22 00:25:25 +000080 MaskPixelChannel = 6, /* Image Write Mask */
81 MetaPixelChannel = 7, /* ??? */
82 IntensityPixelChannel = MaxPixelChannels, /* what are these ??? */
cristy5f95f4f2011-10-23 01:01:01 +000083 CompositePixelChannel = MaxPixelChannels,
cristy2bddff82011-07-25 18:39:12 +000084 SyncPixelChannel = MaxPixelChannels+1
cristyc8d63672012-01-11 13:03:13 +000085} PixelChannel; /* must correspond to ChannelType */
cristy4c08aed2011-07-01 19:47:50 +000086
87typedef enum
88{
cristyac73d1f2013-03-12 00:51:09 +000089 UndefinedPixelIntensityMethod = 0,
90 AveragePixelIntensityMethod,
91 BrightnessPixelIntensityMethod,
92 LightnessPixelIntensityMethod,
93 Rec601LumaPixelIntensityMethod,
cristy2cf5d372013-03-13 12:03:11 +000094 Rec601LuminancePixelIntensityMethod,
cristyac73d1f2013-03-12 00:51:09 +000095 Rec709LumaPixelIntensityMethod,
cristy2cf5d372013-03-13 12:03:11 +000096 Rec709LuminancePixelIntensityMethod,
cristyac73d1f2013-03-12 00:51:09 +000097 RMSPixelIntensityMethod
98} PixelIntensityMethod;
99
100typedef enum
101{
102 UndefinedInterpolatePixel,
103 AverageInterpolatePixel, /* Average 4 nearest neighbours */
104 Average9InterpolatePixel, /* Average 9 nearest neighbours */
105 Average16InterpolatePixel, /* Average 16 nearest neighbours */
106 BackgroundInterpolatePixel, /* Just return background color */
107 BilinearInterpolatePixel, /* Triangular filter interpolation */
108 BlendInterpolatePixel, /* blend of nearest 1, 2 or 4 pixels */
109 CatromInterpolatePixel, /* Catmull-Rom interpolation */
110 IntegerInterpolatePixel, /* Integer (floor) interpolation */
111 MeshInterpolatePixel, /* Triangular Mesh interpolation */
112 NearestInterpolatePixel, /* Nearest Neighbour Only */
113 SplineInterpolatePixel /* Cubic Spline (blurred) interpolation */
114 /* FilterInterpolatePixel, ** Use resize filter - (very slow) */
115} PixelInterpolateMethod;
116
117typedef enum
118{
cristy94bc3bf2011-07-04 18:55:37 +0000119 UndefinedPixelTrait = 0x000000,
cristyed231572011-07-14 02:18:59 +0000120 CopyPixelTrait = 0x000001,
121 UpdatePixelTrait = 0x000002,
122 BlendPixelTrait = 0x000004
cristy94bc3bf2011-07-04 18:55:37 +0000123} PixelTrait;
cristy4c08aed2011-07-01 19:47:50 +0000124
cristyed231572011-07-14 02:18:59 +0000125typedef struct _PixelChannelMap
126{
127 PixelChannel
128 channel;
129
130 PixelTrait
131 traits;
cristye2a912b2011-12-05 20:02:07 +0000132
cristyd26338f2011-12-14 02:39:30 +0000133 ssize_t
cristye2a912b2011-12-05 20:02:07 +0000134 offset;
cristyed231572011-07-14 02:18:59 +0000135} PixelChannelMap;
136
cristy4c08aed2011-07-01 19:47:50 +0000137typedef struct _PixelInfo
138{
139 ClassType
140 storage_class;
141
142 ColorspaceType
143 colorspace;
144
cristy8a46d822012-08-28 23:32:39 +0000145 PixelTrait
146 alpha_trait;
cristy4c08aed2011-07-01 19:47:50 +0000147
148 double
149 fuzz;
150
151 size_t
152 depth;
153
cristy3094b7f2011-10-01 23:18:02 +0000154 MagickSizeType
155 count;
156
cristyc44100b2012-10-08 12:34:07 +0000157 MagickRealType
cristy4c08aed2011-07-01 19:47:50 +0000158 red,
159 green,
160 blue,
cristy4c08aed2011-07-01 19:47:50 +0000161 black,
cristy3094b7f2011-10-01 23:18:02 +0000162 alpha,
cristy4c08aed2011-07-01 19:47:50 +0000163 index;
164} PixelInfo;
165
cristy101ab702011-10-13 13:06:32 +0000166typedef struct _PixelPacket
cristy5c4e2582011-09-11 19:21:03 +0000167{
168 unsigned int
169 red,
170 green,
171 blue,
172 alpha,
173 black;
cristy4c08aed2011-07-01 19:47:50 +0000174} PixelPacket;
175
cristy3f858f42012-01-07 00:03:25 +0000176typedef enum
177{
178 UndefinedPixel,
179 CharPixel,
180 DoublePixel,
181 FloatPixel,
cristy3f858f42012-01-07 00:03:25 +0000182 LongPixel,
cristy6c9e1682012-01-07 21:37:44 +0000183 LongLongPixel,
cristy3f858f42012-01-07 00:03:25 +0000184 QuantumPixel,
185 ShortPixel
186} StorageType;
187
cristy4c08aed2011-07-01 19:47:50 +0000188typedef struct _CacheView
189 CacheView_;
190
191extern MagickExport MagickBooleanType
cristy2dc655d2012-07-05 13:16:28 +0000192 ExportImagePixels(Image *,const ssize_t,const ssize_t,const size_t,
cristy4c08aed2011-07-01 19:47:50 +0000193 const size_t,const char *,const StorageType,void *,ExceptionInfo *),
194 ImportImagePixels(Image *,const ssize_t,const ssize_t,const size_t,
cristy018f07f2011-09-04 21:15:19 +0000195 const size_t,const char *,const StorageType,const void *,ExceptionInfo *),
cristya085a432011-07-30 01:39:32 +0000196 InterpolatePixelChannel(const Image *,const CacheView_ *,
cristy5c4e2582011-09-11 19:21:03 +0000197 const PixelChannel,const PixelInterpolateMethod,const double,const double,
cristya085a432011-07-30 01:39:32 +0000198 double *,ExceptionInfo *),
cristy5c4e2582011-09-11 19:21:03 +0000199 InterpolatePixelChannels(const Image *,const CacheView_ *,const Image *,
200 const PixelInterpolateMethod,const double,const double,Quantum *,
201 ExceptionInfo *),
cristy4c08aed2011-07-01 19:47:50 +0000202 InterpolatePixelInfo(const Image *,const CacheView_ *,
cristy5c4e2582011-09-11 19:21:03 +0000203 const PixelInterpolateMethod,const double,const double,PixelInfo *,
cristy4c08aed2011-07-01 19:47:50 +0000204 ExceptionInfo *),
cristye4a40472011-12-22 02:56:19 +0000205 IsFuzzyEquivalencePixel(const Image *,const Quantum *,const Image *,
cristy4c08aed2011-07-01 19:47:50 +0000206 const Quantum *),
cristy322d07d2012-03-18 21:17:23 +0000207 IsFuzzyEquivalencePixelInfo(const PixelInfo *,const PixelInfo *),
208 SetPixelMetaChannels(Image *,const size_t,ExceptionInfo *);
cristy4c08aed2011-07-01 19:47:50 +0000209
cristy9731df72013-03-12 16:31:13 +0000210extern MagickExport MagickRealType
211 GetPixelIntensity(const Image *restrict,const Quantum *restrict)
212 magick_hot_spot;
213
cristyed231572011-07-14 02:18:59 +0000214extern MagickExport PixelChannelMap
cristybd5a96c2011-08-21 00:04:26 +0000215 *AcquirePixelChannelMap(void),
216 *ClonePixelChannelMap(PixelChannelMap *),
217 *DestroyPixelChannelMap(PixelChannelMap *);
cristy4c08aed2011-07-01 19:47:50 +0000218
219extern MagickExport PixelInfo
220 *ClonePixelInfo(const PixelInfo *);
221
cristyc8aff842012-12-24 16:59:46 +0000222extern MagickExport MagickRealType
cristy12059542012-12-24 18:45:40 +0000223 DecodePixelGamma(const MagickRealType) magick_hot_spot,
224 EncodePixelGamma(const MagickRealType) magick_hot_spot;
cristyc8aff842012-12-24 16:59:46 +0000225
cristy4c08aed2011-07-01 19:47:50 +0000226extern MagickExport void
cristybd5a96c2011-08-21 00:04:26 +0000227 InitializePixelChannelMap(Image *),
cristy2b9582a2011-07-04 17:38:56 +0000228 GetPixelInfo(const Image *,PixelInfo *),
cristycf1296e2012-08-26 23:40:49 +0000229 SetPixelChannelMask(Image *,const ChannelType);
cristy4c08aed2011-07-01 19:47:50 +0000230
231#if defined(__cplusplus) || defined(c_plusplus)
232}
233#endif
234
235#endif