blob: 966d8dd56fd70d6980557b9860740a037dbb3271 [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,
94 Rec709LumaPixelIntensityMethod,
95 RMSPixelIntensityMethod
96} PixelIntensityMethod;
97
98typedef enum
99{
100 UndefinedInterpolatePixel,
101 AverageInterpolatePixel, /* Average 4 nearest neighbours */
102 Average9InterpolatePixel, /* Average 9 nearest neighbours */
103 Average16InterpolatePixel, /* Average 16 nearest neighbours */
104 BackgroundInterpolatePixel, /* Just return background color */
105 BilinearInterpolatePixel, /* Triangular filter interpolation */
106 BlendInterpolatePixel, /* blend of nearest 1, 2 or 4 pixels */
107 CatromInterpolatePixel, /* Catmull-Rom interpolation */
108 IntegerInterpolatePixel, /* Integer (floor) interpolation */
109 MeshInterpolatePixel, /* Triangular Mesh interpolation */
110 NearestInterpolatePixel, /* Nearest Neighbour Only */
111 SplineInterpolatePixel /* Cubic Spline (blurred) interpolation */
112 /* FilterInterpolatePixel, ** Use resize filter - (very slow) */
113} PixelInterpolateMethod;
114
115typedef enum
116{
cristy94bc3bf2011-07-04 18:55:37 +0000117 UndefinedPixelTrait = 0x000000,
cristyed231572011-07-14 02:18:59 +0000118 CopyPixelTrait = 0x000001,
119 UpdatePixelTrait = 0x000002,
120 BlendPixelTrait = 0x000004
cristy94bc3bf2011-07-04 18:55:37 +0000121} PixelTrait;
cristy4c08aed2011-07-01 19:47:50 +0000122
cristyed231572011-07-14 02:18:59 +0000123typedef struct _PixelChannelMap
124{
125 PixelChannel
126 channel;
127
128 PixelTrait
129 traits;
cristye2a912b2011-12-05 20:02:07 +0000130
cristyd26338f2011-12-14 02:39:30 +0000131 ssize_t
cristye2a912b2011-12-05 20:02:07 +0000132 offset;
cristyed231572011-07-14 02:18:59 +0000133} PixelChannelMap;
134
cristy4c08aed2011-07-01 19:47:50 +0000135typedef struct _PixelInfo
136{
137 ClassType
138 storage_class;
139
140 ColorspaceType
141 colorspace;
142
cristy8a46d822012-08-28 23:32:39 +0000143 PixelTrait
144 alpha_trait;
cristy4c08aed2011-07-01 19:47:50 +0000145
146 double
147 fuzz;
148
149 size_t
150 depth;
151
cristy3094b7f2011-10-01 23:18:02 +0000152 MagickSizeType
153 count;
154
cristyc44100b2012-10-08 12:34:07 +0000155 MagickRealType
cristy4c08aed2011-07-01 19:47:50 +0000156 red,
157 green,
158 blue,
cristy4c08aed2011-07-01 19:47:50 +0000159 black,
cristy3094b7f2011-10-01 23:18:02 +0000160 alpha,
cristy4c08aed2011-07-01 19:47:50 +0000161 index;
162} PixelInfo;
163
cristy101ab702011-10-13 13:06:32 +0000164typedef struct _PixelPacket
cristy5c4e2582011-09-11 19:21:03 +0000165{
166 unsigned int
167 red,
168 green,
169 blue,
170 alpha,
171 black;
cristy4c08aed2011-07-01 19:47:50 +0000172} PixelPacket;
173
cristy3f858f42012-01-07 00:03:25 +0000174typedef enum
175{
176 UndefinedPixel,
177 CharPixel,
178 DoublePixel,
179 FloatPixel,
cristy3f858f42012-01-07 00:03:25 +0000180 LongPixel,
cristy6c9e1682012-01-07 21:37:44 +0000181 LongLongPixel,
cristy3f858f42012-01-07 00:03:25 +0000182 QuantumPixel,
183 ShortPixel
184} StorageType;
185
cristy4c08aed2011-07-01 19:47:50 +0000186typedef struct _CacheView
187 CacheView_;
188
189extern MagickExport MagickBooleanType
cristy2dc655d2012-07-05 13:16:28 +0000190 ExportImagePixels(Image *,const ssize_t,const ssize_t,const size_t,
cristy4c08aed2011-07-01 19:47:50 +0000191 const size_t,const char *,const StorageType,void *,ExceptionInfo *),
192 ImportImagePixels(Image *,const ssize_t,const ssize_t,const size_t,
cristy018f07f2011-09-04 21:15:19 +0000193 const size_t,const char *,const StorageType,const void *,ExceptionInfo *),
cristya085a432011-07-30 01:39:32 +0000194 InterpolatePixelChannel(const Image *,const CacheView_ *,
cristy5c4e2582011-09-11 19:21:03 +0000195 const PixelChannel,const PixelInterpolateMethod,const double,const double,
cristya085a432011-07-30 01:39:32 +0000196 double *,ExceptionInfo *),
cristy5c4e2582011-09-11 19:21:03 +0000197 InterpolatePixelChannels(const Image *,const CacheView_ *,const Image *,
198 const PixelInterpolateMethod,const double,const double,Quantum *,
199 ExceptionInfo *),
cristy4c08aed2011-07-01 19:47:50 +0000200 InterpolatePixelInfo(const Image *,const CacheView_ *,
cristy5c4e2582011-09-11 19:21:03 +0000201 const PixelInterpolateMethod,const double,const double,PixelInfo *,
cristy4c08aed2011-07-01 19:47:50 +0000202 ExceptionInfo *),
cristye4a40472011-12-22 02:56:19 +0000203 IsFuzzyEquivalencePixel(const Image *,const Quantum *,const Image *,
cristy4c08aed2011-07-01 19:47:50 +0000204 const Quantum *),
cristy322d07d2012-03-18 21:17:23 +0000205 IsFuzzyEquivalencePixelInfo(const PixelInfo *,const PixelInfo *),
206 SetPixelMetaChannels(Image *,const size_t,ExceptionInfo *);
cristy4c08aed2011-07-01 19:47:50 +0000207
cristyed231572011-07-14 02:18:59 +0000208extern MagickExport PixelChannelMap
cristybd5a96c2011-08-21 00:04:26 +0000209 *AcquirePixelChannelMap(void),
210 *ClonePixelChannelMap(PixelChannelMap *),
211 *DestroyPixelChannelMap(PixelChannelMap *);
cristy4c08aed2011-07-01 19:47:50 +0000212
213extern MagickExport PixelInfo
214 *ClonePixelInfo(const PixelInfo *);
215
cristyc8aff842012-12-24 16:59:46 +0000216extern MagickExport MagickRealType
cristy12059542012-12-24 18:45:40 +0000217 DecodePixelGamma(const MagickRealType) magick_hot_spot,
218 EncodePixelGamma(const MagickRealType) magick_hot_spot;
cristyc8aff842012-12-24 16:59:46 +0000219
cristy4c08aed2011-07-01 19:47:50 +0000220extern MagickExport void
cristybd5a96c2011-08-21 00:04:26 +0000221 InitializePixelChannelMap(Image *),
cristy2b9582a2011-07-04 17:38:56 +0000222 GetPixelInfo(const Image *,PixelInfo *),
cristycf1296e2012-08-26 23:40:49 +0000223 SetPixelChannelMask(Image *,const ChannelType);
cristy4c08aed2011-07-01 19:47:50 +0000224
225#if defined(__cplusplus) || defined(c_plusplus)
226}
227#endif
228
229#endif