MagickCore  7.1.0
Convert, Edit, Or Compose Bitmap Images
pixel.h
1 /*
2  Copyright @ 1999 ImageMagick Studio LLC, a non-profit organization
3  dedicated to making software imaging solutions freely available.
4 
5  You may not use this file except in compliance with the License. You may
6  obtain a copy of the License at
7 
8  https://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 
16  MagickCore image pixel methods.
17 */
18 #ifndef MAGICKCORE_PIXEL_H
19 #define MAGICKCORE_PIXEL_H
20 
21 #include "MagickCore/colorspace.h"
22 
23 #if defined(__cplusplus) || defined(c_plusplus)
24 extern "C" {
25 #endif
26 
27 #define MaxPixelChannels 64
28 #undef index
29 
30 /*
31  Pixel enum declarations.
32 */
33 typedef enum
34 {
35  UndefinedChannel = 0x0000,
36  RedChannel = 0x0001,
37  GrayChannel = 0x0001,
38  CyanChannel = 0x0001,
39  LChannel = 0x0001,
40  GreenChannel = 0x0002,
41  MagentaChannel = 0x0002,
42  aChannel = 0x0002,
43  BlueChannel = 0x0004,
44  bChannel = 0x0002,
45  YellowChannel = 0x0004,
46  BlackChannel = 0x0008,
47  AlphaChannel = 0x0010,
48  OpacityChannel = 0x0010,
49  IndexChannel = 0x0020, /* Color Index Table? */
50  ReadMaskChannel = 0x0040, /* Pixel is Not Readable? */
51  WriteMaskChannel = 0x0080, /* Pixel is Write Protected? */
52  MetaChannel = 0x0100, /* not used */
53  CompositeMaskChannel = 0x0200, /* SVG mask */
54  CompositeChannels = 0x001F,
55  AllChannels = 0x7ffffff,
56  /*
57  Special purpose channel types.
58  FUTURE: are these needed any more - they are more like hacks
59  SyncChannels for example is NOT a real channel but a 'flag'
60  It really says -- "User has not defined channels"
61  Though it does have extra meaning in the "-auto-level" operator
62  */
63  TrueAlphaChannel = 0x0100, /* extract actual alpha channel from opacity */
64  RGBChannels = 0x0200, /* set alpha from grayscale mask in RGB */
65  GrayChannels = 0x0400,
66  SyncChannels = 0x20000, /* channels modified as a single unit */
67  DefaultChannels = AllChannels
68 } ChannelType; /* must correspond to PixelChannel */
69 
70 typedef enum
71 {
72  UndefinedPixelChannel = 0,
73  RedPixelChannel = 0,
74  CyanPixelChannel = 0,
75  GrayPixelChannel = 0,
76  LPixelChannel = 0,
77  LabelPixelChannel = 0,
78  YPixelChannel = 0,
79  aPixelChannel = 1,
80  GreenPixelChannel = 1,
81  MagentaPixelChannel = 1,
82  CbPixelChannel = 1,
83  bPixelChannel = 2,
84  BluePixelChannel = 2,
85  YellowPixelChannel = 2,
86  CrPixelChannel = 2,
87  BlackPixelChannel = 3,
88  AlphaPixelChannel = 4,
89  IndexPixelChannel = 5,
90  ReadMaskPixelChannel = 6,
91  WriteMaskPixelChannel = 7,
92  MetaPixelChannel = 8,
93  CompositeMaskPixelChannel = 9,
94  MetaPixelChannels = 10,
95  IntensityPixelChannel = MaxPixelChannels, /* ???? */
96  CompositePixelChannel = MaxPixelChannels, /* ???? */
97  SyncPixelChannel = MaxPixelChannels+1 /* not a real channel */
98 } PixelChannel; /* must correspond to ChannelType */
99 
100 typedef enum
101 {
102  UndefinedPixelIntensityMethod = 0,
103  AveragePixelIntensityMethod,
104  BrightnessPixelIntensityMethod,
105  LightnessPixelIntensityMethod,
106  MSPixelIntensityMethod,
107  Rec601LumaPixelIntensityMethod,
108  Rec601LuminancePixelIntensityMethod,
109  Rec709LumaPixelIntensityMethod,
110  Rec709LuminancePixelIntensityMethod,
111  RMSPixelIntensityMethod
112 } PixelIntensityMethod;
113 
114 typedef enum
115 {
116  UndefinedInterpolatePixel,
117  AverageInterpolatePixel, /* Average 4 nearest neighbours */
118  Average9InterpolatePixel, /* Average 9 nearest neighbours */
119  Average16InterpolatePixel, /* Average 16 nearest neighbours */
120  BackgroundInterpolatePixel, /* Just return background color */
121  BilinearInterpolatePixel, /* Triangular filter interpolation */
122  BlendInterpolatePixel, /* blend of nearest 1, 2 or 4 pixels */
123  CatromInterpolatePixel, /* Catmull-Rom interpolation */
124  IntegerInterpolatePixel, /* Integer (floor) interpolation */
125  MeshInterpolatePixel, /* Triangular Mesh interpolation */
126  NearestInterpolatePixel, /* Nearest Neighbour Only */
127  SplineInterpolatePixel /* Cubic Spline (blurred) interpolation */
128 } PixelInterpolateMethod;
129 
130 typedef enum
131 {
132  UndefinedPixelMask = 0x000000,
133  ReadPixelMask = 0x000001,
134  WritePixelMask = 0x000002,
135  CompositePixelMask = 0x000004
136 } PixelMask;
137 
138 typedef enum
139 {
140  UndefinedPixelTrait = 0x000000,
141  CopyPixelTrait = 0x000001,
142  UpdatePixelTrait = 0x000002,
143  BlendPixelTrait = 0x000004
144 } PixelTrait;
145 
146 typedef enum
147 {
148  UndefinedPixel,
149  CharPixel,
150  DoublePixel,
151  FloatPixel,
152  LongPixel,
153  LongLongPixel,
154  QuantumPixel,
155  ShortPixel
156 } StorageType;
157 
158 /*
159  Pixel typedef declarations.
160 */
161 typedef struct _PixelChannelMap
162 {
163  PixelChannel
164  channel;
165 
166  PixelTrait
167  traits;
168 
169  ssize_t
170  offset;
172 
173 typedef struct _PixelInfo
174 {
175  ClassType
176  storage_class;
177 
178  ColorspaceType
179  colorspace;
180 
181  PixelTrait
182  alpha_trait;
183 
184  double
185  fuzz;
186 
187  size_t
188  depth;
189 
190  MagickSizeType
191  count;
192 
193  MagickRealType
194  red,
195  green,
196  blue,
197  black,
198  alpha,
199  index;
200 } PixelInfo;
201 
202 typedef struct _PixelPacket
203 {
204  unsigned int
205  red,
206  green,
207  blue,
208  alpha,
209  black;
210 } PixelPacket;
211 
212 typedef struct _CacheView
213  CacheView_;
214 
215 /*
216  Pixel method declarations.
217 */
218 extern MagickExport ChannelType
219  SetPixelChannelMask(Image *,const ChannelType);
220 
221 extern MagickExport MagickBooleanType
222  ExportImagePixels(const Image *,const ssize_t,const ssize_t,const size_t,
223  const size_t,const char *,const StorageType,void *,ExceptionInfo *),
224  ImportImagePixels(Image *,const ssize_t,const ssize_t,const size_t,
225  const size_t,const char *,const StorageType,const void *,ExceptionInfo *),
226  InterpolatePixelChannel(const Image *magick_restrict,const CacheView_ *,
227  const PixelChannel,const PixelInterpolateMethod,const double,const double,
228  double *,ExceptionInfo *),
229  InterpolatePixelChannels(const Image *magick_restrict,const CacheView_ *,
230  const Image * magick_restrict,const PixelInterpolateMethod,const double,
231  const double,Quantum *,ExceptionInfo *),
232  InterpolatePixelInfo(const Image *,const CacheView_ *,
233  const PixelInterpolateMethod,const double,const double,PixelInfo *,
234  ExceptionInfo *),
235  IsFuzzyEquivalencePixel(const Image *,const Quantum *,const Image *,
236  const Quantum *) magick_attribute((__pure__)),
237  IsFuzzyEquivalencePixelInfo(const PixelInfo *,const PixelInfo *)
238  magick_attribute((__pure__)),
239  SetPixelMetaChannels(Image *,const size_t,ExceptionInfo *),
240  SortImagePixels(Image *,ExceptionInfo *);
241 
242 extern MagickExport MagickRealType
243  GetPixelInfoIntensity(const Image *magick_restrict,
244  const PixelInfo *magick_restrict) magick_hot_spot,
245  GetPixelIntensity(const Image *magick_restrict,
246  const Quantum *magick_restrict) magick_hot_spot;
247 
248 extern MagickExport PixelChannelMap
249  *AcquirePixelChannelMap(void),
250  *ClonePixelChannelMap(PixelChannelMap *),
251  *DestroyPixelChannelMap(PixelChannelMap *);
252 
253 extern MagickExport PixelInfo
254  *ClonePixelInfo(const PixelInfo *);
255 
256 extern MagickExport MagickRealType
257  DecodePixelGamma(const MagickRealType) magick_hot_spot,
258  EncodePixelGamma(const MagickRealType) magick_hot_spot;
259 
260 extern MagickExport void
261  ConformPixelInfo(Image *,const PixelInfo *,PixelInfo *,ExceptionInfo *),
262  GetPixelInfo(const Image *,PixelInfo *),
263  InitializePixelChannelMap(Image *);
264 
265 #if defined(__cplusplus) || defined(c_plusplus)
266 }
267 #endif
268 
269 #endif
Definition: image.h:152