| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1 | /* |
| cristy | b56bb24 | 2014-11-25 17:12:48 +0000 | [diff] [blame] | 2 | Copyright 1999-2015 ImageMagick Studio LLC, a non-profit organization |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 3 | 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 | |
| cristy | d04e7bf | 2012-03-03 19:19:12 +0000 | [diff] [blame] | 16 | MagickCore image pixel methods. |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 17 | */ |
| 18 | #ifndef _MAGICKCORE_PIXEL_H |
| 19 | #define _MAGICKCORE_PIXEL_H |
| 20 | |
| cristy | 6398ec7 | 2013-11-28 02:00:27 +0000 | [diff] [blame] | 21 | #include "MagickCore/colorspace.h" |
| 22 | |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 23 | #if defined(__cplusplus) || defined(c_plusplus) |
| 24 | extern "C" { |
| 25 | #endif |
| 26 | |
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 27 | #define MaxPixelChannels 32 |
| cristy | 4af4a77 | 2011-09-07 21:40:44 +0000 | [diff] [blame] | 28 | #undef index |
| cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 29 | |
| cristy | 8dfe0cb | 2013-03-27 22:27:53 +0000 | [diff] [blame] | 30 | /* |
| 31 | Pixel enum declarations. |
| 32 | */ |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 33 | typedef enum |
| 34 | { |
| cristy | c8d6367 | 2012-01-11 13:03:13 +0000 | [diff] [blame] | 35 | 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, |
| anthony | 4023b26 | 2013-06-03 07:43:50 +0000 | [diff] [blame] | 46 | IndexChannel = 0x0020, /* Color Index Table? */ |
| 47 | ReadMaskChannel = 0x0040, /* Pixel is Not Readable? */ |
| 48 | WriteMaskChannel = 0x0080, /* Pixel is Write Protected? */ |
| 49 | MetaChannel = 0x0100, /* ???? */ |
| cristy | 89971ad | 2014-01-10 13:15:35 +0000 | [diff] [blame] | 50 | CompositeChannels = 0x002F, |
| cristy | c8d6367 | 2012-01-11 13:03:13 +0000 | [diff] [blame] | 51 | AllChannels = 0x7ffffff, |
| 52 | /* |
| 53 | Special purpose channel types. |
| anthony | aa6b084 | 2012-03-22 00:25:25 +0000 | [diff] [blame] | 54 | 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" |
| anthony | 4023b26 | 2013-06-03 07:43:50 +0000 | [diff] [blame] | 57 | Though it does have extra meaning in the "-auto-level" operator |
| cristy | c8d6367 | 2012-01-11 13:03:13 +0000 | [diff] [blame] | 58 | */ |
| 59 | TrueAlphaChannel = 0x0100, /* extract actual alpha channel from opacity */ |
| 60 | RGBChannels = 0x0200, /* set alpha from grayscale mask in RGB */ |
| 61 | GrayChannels = 0x0400, |
| anthony | aa6b084 | 2012-03-22 00:25:25 +0000 | [diff] [blame] | 62 | SyncChannels = 0x20000, /* channels modified as a single unit */ |
| cristy | 6aeeb02 | 2014-09-28 18:48:50 +0000 | [diff] [blame] | 63 | DefaultChannels = AllChannels |
| cristy | c8d6367 | 2012-01-11 13:03:13 +0000 | [diff] [blame] | 64 | } ChannelType; /* must correspond to PixelChannel */ |
| 65 | |
| 66 | typedef enum |
| 67 | { |
| cristy | 6dcb9b8 | 2011-10-23 23:21:25 +0000 | [diff] [blame] | 68 | UndefinedPixelChannel = 0, |
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 69 | RedPixelChannel = 0, |
| 70 | CyanPixelChannel = 0, |
| 71 | GrayPixelChannel = 0, |
| cristy | b564954 | 2012-06-30 22:46:15 +0000 | [diff] [blame] | 72 | LPixelChannel = 0, |
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 73 | YPixelChannel = 0, |
| cristy | b564954 | 2012-06-30 22:46:15 +0000 | [diff] [blame] | 74 | aPixelChannel = 1, |
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 75 | GreenPixelChannel = 1, |
| 76 | MagentaPixelChannel = 1, |
| 77 | CbPixelChannel = 1, |
| cristy | b564954 | 2012-06-30 22:46:15 +0000 | [diff] [blame] | 78 | bPixelChannel = 2, |
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 79 | BluePixelChannel = 2, |
| 80 | YellowPixelChannel = 2, |
| 81 | CrPixelChannel = 2, |
| cristy | e2a912b | 2011-12-05 20:02:07 +0000 | [diff] [blame] | 82 | BlackPixelChannel = 3, |
| 83 | AlphaPixelChannel = 4, |
| 84 | IndexPixelChannel = 5, |
| cristy | 883fde1 | 2013-04-08 00:50:13 +0000 | [diff] [blame] | 85 | ReadMaskPixelChannel = 6, |
| 86 | WriteMaskPixelChannel = 7, |
| 87 | MetaPixelChannel = 8, |
| anthony | 4023b26 | 2013-06-03 07:43:50 +0000 | [diff] [blame] | 88 | IntensityPixelChannel = MaxPixelChannels, /* ???? */ |
| 89 | CompositePixelChannel = MaxPixelChannels, /* ???? */ |
| 90 | SyncPixelChannel = MaxPixelChannels+1 /* not a real channel */ |
| cristy | c8d6367 | 2012-01-11 13:03:13 +0000 | [diff] [blame] | 91 | } PixelChannel; /* must correspond to ChannelType */ |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 92 | |
| 93 | typedef enum |
| 94 | { |
| cristy | ac73d1f | 2013-03-12 00:51:09 +0000 | [diff] [blame] | 95 | UndefinedPixelIntensityMethod = 0, |
| 96 | AveragePixelIntensityMethod, |
| 97 | BrightnessPixelIntensityMethod, |
| 98 | LightnessPixelIntensityMethod, |
| cristy | b04db12 | 2013-04-11 10:26:01 +0000 | [diff] [blame] | 99 | MSPixelIntensityMethod, |
| cristy | ac73d1f | 2013-03-12 00:51:09 +0000 | [diff] [blame] | 100 | Rec601LumaPixelIntensityMethod, |
| cristy | 2cf5d37 | 2013-03-13 12:03:11 +0000 | [diff] [blame] | 101 | Rec601LuminancePixelIntensityMethod, |
| cristy | ac73d1f | 2013-03-12 00:51:09 +0000 | [diff] [blame] | 102 | Rec709LumaPixelIntensityMethod, |
| cristy | 2cf5d37 | 2013-03-13 12:03:11 +0000 | [diff] [blame] | 103 | Rec709LuminancePixelIntensityMethod, |
| cristy | ac73d1f | 2013-03-12 00:51:09 +0000 | [diff] [blame] | 104 | RMSPixelIntensityMethod |
| 105 | } PixelIntensityMethod; |
| 106 | |
| 107 | typedef 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 */ |
| anthony | 4023b26 | 2013-06-03 07:43:50 +0000 | [diff] [blame] | 120 | SplineInterpolatePixel /* Cubic Spline (blurred) interpolation */ |
| cristy | ac73d1f | 2013-03-12 00:51:09 +0000 | [diff] [blame] | 121 | /* FilterInterpolatePixel, ** Use resize filter - (very slow) */ |
| 122 | } PixelInterpolateMethod; |
| 123 | |
| 124 | typedef enum |
| 125 | { |
| cristy | cf5acb3 | 2013-03-22 01:11:49 +0000 | [diff] [blame] | 126 | UndefinedPixelMask = 0x000000, |
| 127 | ReadPixelMask = 0x000001, |
| 128 | WritePixelMask = 0x000002 |
| 129 | } PixelMask; |
| 130 | |
| 131 | typedef enum |
| 132 | { |
| cristy | 94bc3bf | 2011-07-04 18:55:37 +0000 | [diff] [blame] | 133 | UndefinedPixelTrait = 0x000000, |
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 134 | CopyPixelTrait = 0x000001, |
| 135 | UpdatePixelTrait = 0x000002, |
| 136 | BlendPixelTrait = 0x000004 |
| cristy | 94bc3bf | 2011-07-04 18:55:37 +0000 | [diff] [blame] | 137 | } PixelTrait; |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 138 | |
| cristy | 8dfe0cb | 2013-03-27 22:27:53 +0000 | [diff] [blame] | 139 | typedef 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 | */ |
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 154 | typedef struct _PixelChannelMap |
| 155 | { |
| 156 | PixelChannel |
| 157 | channel; |
| 158 | |
| 159 | PixelTrait |
| 160 | traits; |
| cristy | e2a912b | 2011-12-05 20:02:07 +0000 | [diff] [blame] | 161 | |
| cristy | d26338f | 2011-12-14 02:39:30 +0000 | [diff] [blame] | 162 | ssize_t |
| cristy | e2a912b | 2011-12-05 20:02:07 +0000 | [diff] [blame] | 163 | offset; |
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 164 | } PixelChannelMap; |
| 165 | |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 166 | typedef struct _PixelInfo |
| 167 | { |
| 168 | ClassType |
| 169 | storage_class; |
| 170 | |
| 171 | ColorspaceType |
| 172 | colorspace; |
| 173 | |
| cristy | 8a46d82 | 2012-08-28 23:32:39 +0000 | [diff] [blame] | 174 | PixelTrait |
| 175 | alpha_trait; |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 176 | |
| 177 | double |
| 178 | fuzz; |
| 179 | |
| 180 | size_t |
| 181 | depth; |
| 182 | |
| cristy | 3094b7f | 2011-10-01 23:18:02 +0000 | [diff] [blame] | 183 | MagickSizeType |
| 184 | count; |
| 185 | |
| cristy | c44100b | 2012-10-08 12:34:07 +0000 | [diff] [blame] | 186 | MagickRealType |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 187 | red, |
| 188 | green, |
| 189 | blue, |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 190 | black, |
| cristy | 3094b7f | 2011-10-01 23:18:02 +0000 | [diff] [blame] | 191 | alpha, |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 192 | index; |
| 193 | } PixelInfo; |
| 194 | |
| cristy | 101ab70 | 2011-10-13 13:06:32 +0000 | [diff] [blame] | 195 | typedef struct _PixelPacket |
| cristy | 5c4e258 | 2011-09-11 19:21:03 +0000 | [diff] [blame] | 196 | { |
| 197 | unsigned int |
| 198 | red, |
| 199 | green, |
| 200 | blue, |
| 201 | alpha, |
| 202 | black; |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 203 | } PixelPacket; |
| 204 | |
| 205 | typedef struct _CacheView |
| 206 | CacheView_; |
| 207 | |
| cristy | 8dfe0cb | 2013-03-27 22:27:53 +0000 | [diff] [blame] | 208 | /* |
| 209 | Pixel method declarations. |
| 210 | */ |
| cristy | bcd5934 | 2015-06-07 14:07:19 +0000 | [diff] [blame] | 211 | extern MagickExport ChannelType |
| 212 | SetPixelChannelMask(Image *,const ChannelType); |
| 213 | |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 214 | extern MagickExport MagickBooleanType |
| cristy | 2dc655d | 2012-07-05 13:16:28 +0000 | [diff] [blame] | 215 | ExportImagePixels(Image *,const ssize_t,const ssize_t,const size_t, |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 216 | const size_t,const char *,const StorageType,void *,ExceptionInfo *), |
| 217 | ImportImagePixels(Image *,const ssize_t,const ssize_t,const size_t, |
| cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 218 | const size_t,const char *,const StorageType,const void *,ExceptionInfo *), |
| cristy | a085a43 | 2011-07-30 01:39:32 +0000 | [diff] [blame] | 219 | InterpolatePixelChannel(const Image *,const CacheView_ *, |
| cristy | 5c4e258 | 2011-09-11 19:21:03 +0000 | [diff] [blame] | 220 | const PixelChannel,const PixelInterpolateMethod,const double,const double, |
| cristy | a085a43 | 2011-07-30 01:39:32 +0000 | [diff] [blame] | 221 | double *,ExceptionInfo *), |
| cristy | 5c4e258 | 2011-09-11 19:21:03 +0000 | [diff] [blame] | 222 | InterpolatePixelChannels(const Image *,const CacheView_ *,const Image *, |
| 223 | const PixelInterpolateMethod,const double,const double,Quantum *, |
| 224 | ExceptionInfo *), |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 225 | InterpolatePixelInfo(const Image *,const CacheView_ *, |
| cristy | 5c4e258 | 2011-09-11 19:21:03 +0000 | [diff] [blame] | 226 | const PixelInterpolateMethod,const double,const double,PixelInfo *, |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 227 | ExceptionInfo *), |
| cristy | e4a4047 | 2011-12-22 02:56:19 +0000 | [diff] [blame] | 228 | IsFuzzyEquivalencePixel(const Image *,const Quantum *,const Image *, |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 229 | const Quantum *), |
| cristy | 322d07d | 2012-03-18 21:17:23 +0000 | [diff] [blame] | 230 | IsFuzzyEquivalencePixelInfo(const PixelInfo *,const PixelInfo *), |
| 231 | SetPixelMetaChannels(Image *,const size_t,ExceptionInfo *); |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 232 | |
| cristy | 9731df7 | 2013-03-12 16:31:13 +0000 | [diff] [blame] | 233 | extern MagickExport MagickRealType |
| dirk | 05d2ff7 | 2015-11-18 23:13:43 +0100 | [diff] [blame^] | 234 | 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; |
| cristy | 9731df7 | 2013-03-12 16:31:13 +0000 | [diff] [blame] | 238 | |
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 239 | extern MagickExport PixelChannelMap |
| cristy | bd5a96c | 2011-08-21 00:04:26 +0000 | [diff] [blame] | 240 | *AcquirePixelChannelMap(void), |
| 241 | *ClonePixelChannelMap(PixelChannelMap *), |
| 242 | *DestroyPixelChannelMap(PixelChannelMap *); |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 243 | |
| 244 | extern MagickExport PixelInfo |
| 245 | *ClonePixelInfo(const PixelInfo *); |
| 246 | |
| cristy | c8aff84 | 2012-12-24 16:59:46 +0000 | [diff] [blame] | 247 | extern MagickExport MagickRealType |
| cristy | 1205954 | 2012-12-24 18:45:40 +0000 | [diff] [blame] | 248 | DecodePixelGamma(const MagickRealType) magick_hot_spot, |
| 249 | EncodePixelGamma(const MagickRealType) magick_hot_spot; |
| cristy | c8aff84 | 2012-12-24 16:59:46 +0000 | [diff] [blame] | 250 | |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 251 | extern MagickExport void |
| dirk | bfdd5bc | 2014-11-04 19:47:44 +0000 | [diff] [blame] | 252 | ConformPixelInfo(Image *,const PixelInfo *,PixelInfo *,ExceptionInfo *), |
| cristy | 2b9582a | 2011-07-04 17:38:56 +0000 | [diff] [blame] | 253 | GetPixelInfo(const Image *,PixelInfo *), |
| cristy | bcd5934 | 2015-06-07 14:07:19 +0000 | [diff] [blame] | 254 | InitializePixelChannelMap(Image *); |
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 255 | |
| 256 | #if defined(__cplusplus) || defined(c_plusplus) |
| 257 | } |
| 258 | #endif |
| 259 | |
| 260 | #endif |