MagickCore  7.0.7
Convert, Edit, Or Compose Bitmap Images
pixel-accessor.h
Go to the documentation of this file.
1 /*
2  Copyright 1999-2018 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.
6  obtain a copy of the License at
7 
8  https://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 
16  MagickCore pixel accessor methods.
17 */
18 #ifndef MAGICKCORE_PIXEL_ACCESSOR_H
19 #define MAGICKCORE_PIXEL_ACCESSOR_H
20 
21 #include <assert.h>
22 #include "MagickCore/cache.h"
23 #include "MagickCore/cache-view.h"
24 #include "MagickCore/color.h"
25 #include "MagickCore/colorspace.h"
26 #include "MagickCore/gem.h"
27 #include "MagickCore/image.h"
28 
29 #if defined(__cplusplus) || defined(c_plusplus)
30 extern "C" {
31 #endif
32 
33 #undef index
34 
35 static inline Quantum ClampPixel(const MagickRealType pixel)
36 {
37  if (pixel < 0.0f)
38  return((Quantum) 0);
39  if (pixel >= (MagickRealType) QuantumRange)
40  return((Quantum) QuantumRange);
41 #if !defined(MAGICKCORE_HDRI_SUPPORT)
42  return((Quantum) (pixel+0.5f));
43 #else
44  return((Quantum) pixel);
45 #endif
46 }
47 
48 static inline Quantum GetPixela(const Image *magick_restrict image,
49  const Quantum *magick_restrict pixel)
50 {
51  return(pixel[image->channel_map[aPixelChannel].offset]);
52 }
53 
54 static inline Quantum GetPixelAlpha(const Image *magick_restrict image,
55  const Quantum *magick_restrict pixel)
56 {
57  if (image->channel_map[AlphaPixelChannel].traits == UndefinedPixelTrait)
58  return(OpaqueAlpha);
59  return(pixel[image->channel_map[AlphaPixelChannel].offset]);
60 }
61 
63  const Image *magick_restrict image)
64 {
65  return(image->channel_map[AlphaPixelChannel].traits);
66 }
67 
68 static inline Quantum GetPixelb(const Image *magick_restrict image,
69  const Quantum *magick_restrict pixel)
70 {
71  return(pixel[image->channel_map[bPixelChannel].offset]);
72 }
73 
74 static inline Quantum GetPixelBlack(const Image *magick_restrict image,
75  const Quantum *magick_restrict pixel)
76 {
77  if (image->channel_map[BlackPixelChannel].traits == UndefinedPixelTrait)
78  return((Quantum) 0);
79  return(pixel[image->channel_map[BlackPixelChannel].offset]);
80 }
81 
83  const Image *magick_restrict image)
84 {
85  return(image->channel_map[BlackPixelChannel].traits);
86 }
87 
88 static inline Quantum GetPixelBlue(const Image *magick_restrict image,
89  const Quantum *magick_restrict pixel)
90 {
91  return(pixel[image->channel_map[BluePixelChannel].offset]);
92 }
93 
95 {
96  return(image->channel_map[BluePixelChannel].traits);
97 }
98 
99 static inline Quantum GetPixelCb(const Image *magick_restrict image,
100  const Quantum *magick_restrict pixel)
101 {
102  return(pixel[image->channel_map[CbPixelChannel].offset]);
103 }
104 
106 {
107  return(image->channel_map[CbPixelChannel].traits);
108 }
109 
110 static inline Quantum GetPixelChannel(const Image *magick_restrict image,
111  const PixelChannel channel,const Quantum *magick_restrict pixel)
112 {
113  if (image->channel_map[channel].traits == UndefinedPixelTrait)
114  return((Quantum) 0);
115  return(pixel[image->channel_map[channel].offset]);
116 }
117 
119  const Image *magick_restrict image,const ssize_t offset)
120 {
121  return(image->channel_map[offset].channel);
122 }
123 
124 static inline ssize_t GetPixelChannelOffset(const Image *magick_restrict image,
125  const PixelChannel channel)
126 {
127  return(image->channel_map[channel].offset);
128 }
129 
131  const Image *magick_restrict image,const PixelChannel channel)
132 {
133  return(image->channel_map[channel].traits);
134 }
135 
136 static inline size_t GetPixelChannels(const Image *magick_restrict image)
137 {
138  return(image->number_channels);
139 }
140 
141 static inline Quantum GetPixelCr(const Image *magick_restrict image,
142  const Quantum *magick_restrict pixel)
143 {
144  return(pixel[image->channel_map[CrPixelChannel].offset]);
145 }
146 
148 {
149  return(image->channel_map[CrPixelChannel].traits);
150 }
151 
152 static inline Quantum GetPixelCyan(const Image *magick_restrict image,
153  const Quantum *magick_restrict pixel)
154 {
155  return(pixel[image->channel_map[CyanPixelChannel].offset]);
156 }
157 
159 {
160  return(image->channel_map[CyanPixelChannel].traits);
161 }
162 
163 static inline Quantum GetPixelGray(const Image *magick_restrict image,
164  const Quantum *magick_restrict pixel)
165 {
166  return(pixel[image->channel_map[GrayPixelChannel].offset]);
167 }
168 
170 {
171  return(image->channel_map[GrayPixelChannel].traits);
172 }
173 
174 static inline Quantum GetPixelGreen(const Image *magick_restrict image,
175  const Quantum *magick_restrict pixel)
176 {
177  return(pixel[image->channel_map[GreenPixelChannel].offset]);
178 }
179 
181  const Image *magick_restrict image)
182 {
183  return(image->channel_map[GreenPixelChannel].traits);
184 }
185 
186 static inline Quantum GetPixelIndex(const Image *magick_restrict image,
187  const Quantum *magick_restrict pixel)
188 {
189  if (image->channel_map[IndexPixelChannel].traits == UndefinedPixelTrait)
190  return((Quantum) 0);
191  return(pixel[image->channel_map[IndexPixelChannel].offset]);
192 }
193 
195  const Image *magick_restrict image)
196 {
197  return(image->channel_map[IndexPixelChannel].traits);
198 }
199 
201  const PixelInfo *magick_restrict pixel_info,const PixelChannel channel)
202 {
203  switch (channel)
204  {
205  case RedPixelChannel: return(pixel_info->red);
206  case GreenPixelChannel: return(pixel_info->green);
207  case BluePixelChannel: return(pixel_info->blue);
208  case BlackPixelChannel: return(pixel_info->black);
209  case AlphaPixelChannel: return(pixel_info->alpha);
210  case IndexPixelChannel: return(pixel_info->index);
211  default: return((MagickRealType) 0.0);
212  }
213 }
214 
215 static inline double PerceptibleReciprocal(const double x)
216 {
217  double
218  sign;
219 
220  /*
221  Return 1/x where x is perceptible (not unlimited or infinitesimal).
222  */
223  sign=x < 0.0 ? -1.0 : 1.0;
224  if ((sign*x) >= MagickEpsilon)
225  return(1.0/x);
226  return(sign/MagickEpsilon);
227 }
228 
230  const PixelInfo *magick_restrict pixel)
231 {
233  intensity;
234 
235  if (pixel->colorspace == sRGBColorspace)
236  {
237  intensity=(MagickRealType) (0.212656f*pixel->red+0.715158f*pixel->green+
238  0.072186f*pixel->blue);
239  return(intensity);
240  }
241  intensity=(MagickRealType) (0.212656f*EncodePixelGamma(pixel->red)+
242  0.715158f*EncodePixelGamma(pixel->green)+
243  0.072186f*EncodePixelGamma(pixel->blue));
244  return(intensity);
245 }
246 
248  const PixelInfo *magick_restrict pixel)
249 {
251  intensity;
252 
253  if (pixel->colorspace != sRGBColorspace)
254  {
255  intensity=(MagickRealType) (0.212656f*pixel->red+0.715158f*pixel->green+
256  0.072186f*pixel->blue);
257  return(intensity);
258  }
259  intensity=(MagickRealType) (0.212656f*DecodePixelGamma(pixel->red)+
260  0.715158f*DecodePixelGamma(pixel->green)+
261  0.072186f*DecodePixelGamma(pixel->blue));
262  return(intensity);
263 }
264 
265 static inline Quantum GetPixelL(const Image *magick_restrict image,
266  const Quantum *magick_restrict pixel)
267 {
268  return(pixel[image->channel_map[LPixelChannel].offset]);
269 }
270 
271 static inline ssize_t GetPixelLabel(const Image *magick_restrict image,
272  const Quantum *magick_restrict pixel)
273 {
274  return((ssize_t) pixel[image->channel_map[LabelPixelChannel].offset]);
275 }
276 
278  const Quantum *magick_restrict pixel)
279 {
281  intensity;
282 
283  intensity=(MagickRealType) (
284  0.212656f*pixel[image->channel_map[RedPixelChannel].offset]+
285  0.715158f*pixel[image->channel_map[GreenPixelChannel].offset]+
286  0.072186f*pixel[image->channel_map[BluePixelChannel].offset]);
287  return(intensity);
288 }
289 
291  const Image *magick_restrict image,const Quantum *magick_restrict pixel)
292 {
294  intensity;
295 
296  if (image->colorspace != sRGBColorspace)
297  {
298  intensity=(MagickRealType) (
299  0.212656f*pixel[image->channel_map[RedPixelChannel].offset]+
300  0.715158f*pixel[image->channel_map[GreenPixelChannel].offset]+
301  0.072186f*pixel[image->channel_map[BluePixelChannel].offset]);
302  return(intensity);
303  }
304  intensity=(MagickRealType) (0.212656f*DecodePixelGamma((MagickRealType)
305  pixel[image->channel_map[RedPixelChannel].offset])+0.715158f*
307  pixel[image->channel_map[GreenPixelChannel].offset])+0.072186f*
309  pixel[image->channel_map[BluePixelChannel].offset]));
310  return(intensity);
311 }
312 
313 static inline Quantum GetPixelMagenta(const Image *magick_restrict image,
314  const Quantum *magick_restrict pixel)
315 {
316  return(pixel[image->channel_map[MagentaPixelChannel].offset]);
317 }
318 
320  const Image *magick_restrict image)
321 {
322  return(image->channel_map[MagentaPixelChannel].traits);
323 }
324 
325 static inline Quantum GetPixelReadMask(const Image *magick_restrict image,
326  const Quantum *magick_restrict pixel)
327 {
328  if (image->channel_map[ReadMaskPixelChannel].traits == UndefinedPixelTrait)
329  return((Quantum) QuantumRange);
330  return(pixel[image->channel_map[ReadMaskPixelChannel].offset]);
331 }
332 
333 static inline Quantum GetPixelWriteMask(const Image *magick_restrict image,
334  const Quantum *magick_restrict pixel)
335 {
336  if (image->channel_map[WriteMaskPixelChannel].traits == UndefinedPixelTrait)
337  return((Quantum) QuantumRange);
338  return(pixel[image->channel_map[WriteMaskPixelChannel].offset]);
339 }
340 
342  const Image *magick_restrict image)
343 {
344  return(image->channel_map[ReadMaskPixelChannel].traits);
345 }
346 
347 static inline size_t GetPixelMetaChannels(const Image *magick_restrict image)
348 {
349  return(image->number_meta_channels);
350 }
351 
352 static inline size_t GetPixelMetacontentExtent(
353  const Image *magick_restrict image)
354 {
355  return(image->metacontent_extent);
356 }
357 
358 static inline Quantum GetPixelOpacity(const Image *magick_restrict image,
359  const Quantum *magick_restrict pixel)
360 {
361  if (image->channel_map[AlphaPixelChannel].traits != BlendPixelTrait)
362  return(QuantumRange-OpaqueAlpha);
363  return(QuantumRange-pixel[image->channel_map[AlphaPixelChannel].offset]);
364 }
365 
366 static inline Quantum GetPixelRed(const Image *magick_restrict image,
367  const Quantum *magick_restrict pixel)
368 {
369  return(pixel[image->channel_map[RedPixelChannel].offset]);
370 }
371 
373 {
374  return(image->channel_map[RedPixelChannel].traits);
375 }
376 
377 static inline void GetPixelInfoPixel(const Image *magick_restrict image,
378  const Quantum *magick_restrict pixel,PixelInfo *magick_restrict pixel_info)
379 {
380  pixel_info->storage_class=DirectClass;
381  pixel_info->colorspace=sRGBColorspace;
382  pixel_info->fuzz=0.0f;
383  pixel_info->depth=MAGICKCORE_QUANTUM_DEPTH;
384  pixel_info->red=0.0f;
385  pixel_info->green=0.0f;
386  pixel_info->blue=0.0f;
387  pixel_info->black=0.0f;
388  pixel_info->index=0.0f;
389  pixel_info->alpha_trait=UndefinedPixelTrait;
390  pixel_info->alpha=(MagickRealType) OpaqueAlpha;
391  pixel_info->count=0;
392  if (image != (Image *) NULL)
393  {
394  pixel_info->storage_class=image->storage_class;
395  pixel_info->colorspace=image->colorspace;
396  pixel_info->fuzz=image->fuzz;
397  pixel_info->depth=image->depth;
398  pixel_info->alpha_trait=image->alpha_trait;
399  }
400  if (pixel != (Quantum *) NULL)
401  {
402  pixel_info->red=(MagickRealType)
403  pixel[image->channel_map[RedPixelChannel].offset];
404  pixel_info->green=(MagickRealType)
405  pixel[image->channel_map[GreenPixelChannel].offset];
406  pixel_info->blue=(MagickRealType)
407  pixel[image->channel_map[BluePixelChannel].offset];
408  if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
409  pixel_info->black=(MagickRealType)
410  pixel[image->channel_map[BlackPixelChannel].offset];
411  if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
412  {
413  pixel_info->alpha=(MagickRealType)
414  pixel[image->channel_map[AlphaPixelChannel].offset];
415  pixel_info->alpha_trait=BlendPixelTrait;
416  }
417  if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
418  pixel_info->index=(MagickRealType)
419  pixel[image->channel_map[IndexPixelChannel].offset];
420  }
421 }
422 
423 static inline PixelTrait GetPixelTraits(const Image *magick_restrict image,
424  const PixelChannel channel)
425 {
426  return(image->channel_map[channel].traits);
427 }
428 
429 static inline Quantum GetPixelY(const Image *magick_restrict image,
430  const Quantum *magick_restrict pixel)
431 {
432  return(pixel[image->channel_map[YPixelChannel].offset]);
433 }
434 
435 static inline PixelTrait GetPixelYTraits(const Image *magick_restrict image)
436 {
437  return(image->channel_map[YPixelChannel].traits);
438 }
439 
440 static inline Quantum GetPixelYellow(const Image *magick_restrict image,
441  const Quantum *magick_restrict pixel)
442 {
443  return(pixel[image->channel_map[YellowPixelChannel].offset]);
444 }
445 
447  const Image *magick_restrict image)
448 {
449  return(image->channel_map[YellowPixelChannel].traits);
450 }
451 
453 {
454  return(x < 0.0f ? -x : x);
455 }
456 
457 static inline MagickBooleanType IsPixelAtDepth(const Quantum pixel,
458  const QuantumAny range)
459 {
460  Quantum
461  quantum;
462 
463 #if !defined(MAGICKCORE_HDRI_SUPPORT)
465  (((MagickRealType) range*pixel)/QuantumRange+0.5)))/range+0.5);
466 #else
468  (((MagickRealType) range*pixel)/QuantumRange+0.5)))/range);
469 #endif
470  return(pixel == quantum ? MagickTrue : MagickFalse);
471 }
472 
474  const Image *magick_restrict image,const Quantum *magick_restrict p,
475  const PixelInfo *magick_restrict q)
476 {
478  alpha,
479  beta,
480  color;
481 
482  color=(MagickRealType) p[image->channel_map[AlphaPixelChannel].offset];
483  alpha=image->alpha_trait == UndefinedPixelTrait ? (MagickRealType)
484  OpaqueAlpha : color;
485  beta=q->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
486  q->alpha;
487  if (AbsolutePixelValue(alpha-beta) >= MagickEpsilon)
488  return(MagickFalse);
491  return(MagickTrue); /* no color component if pixel is transparent */
492  color=(MagickRealType) p[image->channel_map[RedPixelChannel].offset];
493  if (AbsolutePixelValue(color-q->red) >= MagickEpsilon)
494  return(MagickFalse);
495  color=(MagickRealType) p[image->channel_map[GreenPixelChannel].offset];
496  if (AbsolutePixelValue(color-q->green) >= MagickEpsilon)
497  return(MagickFalse);
498  color=(MagickRealType) p[image->channel_map[BluePixelChannel].offset];
499  if (AbsolutePixelValue(color-q->blue) >= MagickEpsilon)
500  return(MagickFalse);
501  if (image->colorspace == CMYKColorspace)
502  {
503  color=(MagickRealType) p[image->channel_map[BlackPixelChannel].offset];
504  if (AbsolutePixelValue(color-q->black) >= MagickEpsilon)
505  return(MagickFalse);
506  }
507  return(MagickTrue);
508 }
509 
511  const Quantum *magick_restrict pixel)
512 {
514  green_blue,
515  red_green;
516 
517  red_green=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]-
518  pixel[image->channel_map[GreenPixelChannel].offset];
519  green_blue=(MagickRealType)
520  pixel[image->channel_map[GreenPixelChannel].offset]-
521  pixel[image->channel_map[BluePixelChannel].offset];
522  if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
523  (AbsolutePixelValue(green_blue) < MagickEpsilon))
524  return(MagickTrue);
525  return(MagickFalse);
526 }
527 
530 {
532  alpha,
533  beta;
534 
535  alpha=p->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
536  p->alpha;
537  beta=q->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
538  q->alpha;
539  if (AbsolutePixelValue(alpha-beta) >= MagickEpsilon)
540  return(MagickFalse);
543  return(MagickTrue); /* no color component if pixel is transparent */
544  if (AbsolutePixelValue(p->red-q->red) >= MagickEpsilon)
545  return(MagickFalse);
546  if (AbsolutePixelValue(p->green-q->green) >= MagickEpsilon)
547  return(MagickFalse);
548  if (AbsolutePixelValue(p->blue-q->blue) >= MagickEpsilon)
549  return(MagickFalse);
550  if (p->colorspace == CMYKColorspace)
551  {
552  if (AbsolutePixelValue(p->black-q->black) >= MagickEpsilon)
553  return(MagickFalse);
554  }
555  return(MagickTrue);
556 }
557 
559  const Image *magick_restrict image,const Quantum *magick_restrict pixel)
560 {
562  green_blue,
563  red,
564  red_green;
565 
566  red=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset];
567  if ((AbsolutePixelValue(red) >= MagickEpsilon) &&
569  return(MagickFalse);
570  red_green=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]-
571  pixel[image->channel_map[GreenPixelChannel].offset];
572  green_blue=(MagickRealType)
573  pixel[image->channel_map[GreenPixelChannel].offset]-
574  pixel[image->channel_map[BluePixelChannel].offset];
575  if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
576  (AbsolutePixelValue(green_blue) < MagickEpsilon))
577  return(MagickTrue);
578  return(MagickFalse);
579 }
580 
582  const PixelInfo *magick_restrict pixel)
583 {
584  if ((AbsolutePixelValue(pixel->red-pixel->green) < MagickEpsilon) &&
585  (AbsolutePixelValue(pixel->green-pixel->blue) < MagickEpsilon))
586  return(MagickTrue);
587  return(MagickFalse);
588 }
589 
591  const PixelInfo *magick_restrict pixel_info)
592 {
594  green_blue,
595  red_green;
596 
597  if ((AbsolutePixelValue(pixel_info->red) >= MagickEpsilon) ||
598  (AbsolutePixelValue(pixel_info->red-QuantumRange) >= MagickEpsilon))
599  return(MagickFalse);
600  red_green=pixel_info->red-pixel_info->green;
601  green_blue=pixel_info->green-pixel_info->blue;
602  if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
603  (AbsolutePixelValue(green_blue) < MagickEpsilon))
604  return(MagickTrue);
605  return(MagickFalse);
606 }
607 
608 static inline void SetPixela(const Image *magick_restrict image,
609  const Quantum a,Quantum *magick_restrict pixel)
610 {
611  if (image->channel_map[aPixelChannel].traits != UndefinedPixelTrait)
612  pixel[image->channel_map[aPixelChannel].offset]=a;
613 }
614 
615 static inline void SetPixelAlpha(const Image *magick_restrict image,
616  const Quantum alpha,Quantum *magick_restrict pixel)
617 {
618  if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
619  pixel[image->channel_map[AlphaPixelChannel].offset]=alpha;
620 }
621 
622 static inline void SetPixelAlphaTraits(Image *image,const PixelTrait traits)
623 {
624  image->channel_map[AlphaPixelChannel].traits=traits;
625 }
626 
627 static inline void SetPixelb(const Image *magick_restrict image,
628  const Quantum b,Quantum *magick_restrict pixel)
629 {
630  if (image->channel_map[bPixelChannel].traits != UndefinedPixelTrait)
631  pixel[image->channel_map[bPixelChannel].offset]=b;
632 }
633 
634 static inline void SetPixelBackgoundColor(const Image *magick_restrict image,
635  Quantum *magick_restrict pixel)
636 {
637  register ssize_t
638  i;
639 
640  for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
641  pixel[i]=(Quantum) 0;
642  pixel[image->channel_map[RedPixelChannel].offset]=
643  ClampToQuantum(image->background_color.red);
644  pixel[image->channel_map[GreenPixelChannel].offset]=
645  ClampToQuantum(image->background_color.green);
646  pixel[image->channel_map[BluePixelChannel].offset]=
647  ClampToQuantum(image->background_color.blue);
648  if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
649  pixel[image->channel_map[BlackPixelChannel].offset]=
650  ClampToQuantum(image->background_color.black);
651  if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
652  pixel[image->channel_map[AlphaPixelChannel].offset]=
653  image->background_color.alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
654  ClampToQuantum(image->background_color.alpha);
655 }
656 
657 static inline void SetPixelBlack(const Image *magick_restrict image,
658  const Quantum black,Quantum *magick_restrict pixel)
659 {
660  if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
661  pixel[image->channel_map[BlackPixelChannel].offset]=black;
662 }
663 
664 static inline void SetPixelBlackTraits(Image *image,const PixelTrait traits)
665 {
666  image->channel_map[BlackPixelChannel].traits=traits;
667 }
668 
669 static inline void SetPixelBlue(const Image *magick_restrict image,
670  const Quantum blue,Quantum *magick_restrict pixel)
671 {
672  pixel[image->channel_map[BluePixelChannel].offset]=blue;
673 }
674 
675 static inline void SetPixelBlueTraits(Image *image,const PixelTrait traits)
676 {
677  image->channel_map[BluePixelChannel].traits=traits;
678 }
679 
680 static inline void SetPixelCb(const Image *magick_restrict image,
681  const Quantum cb,Quantum *magick_restrict pixel)
682 {
683  pixel[image->channel_map[CbPixelChannel].offset]=cb;
684 }
685 
686 static inline void SetPixelCbTraits(Image *image,const PixelTrait traits)
687 {
688  image->channel_map[CbPixelChannel].traits=traits;
689 }
690 
691 static inline void SetPixelChannel(const Image *magick_restrict image,
692  const PixelChannel channel,const Quantum quantum,
693  Quantum *magick_restrict pixel)
694 {
695  if (image->channel_map[channel].traits != UndefinedPixelTrait)
696  pixel[image->channel_map[channel].offset]=quantum;
697 }
698 
699 static inline void SetPixelChannelAttributes(
700  const Image *magick_restrict image,const PixelChannel channel,
701  const PixelTrait traits,const ssize_t offset)
702 {
703  assert((ssize_t) channel < MaxPixelChannels);
704  assert(offset < MaxPixelChannels);
705  image->channel_map[offset].channel=channel;
706  image->channel_map[channel].offset=offset;
707  image->channel_map[channel].traits=traits;
708 }
709 
710 static inline void SetPixelChannelChannel(const Image *magick_restrict image,
711  const PixelChannel channel,const ssize_t offset)
712 {
713  image->channel_map[offset].channel=channel;
714  image->channel_map[channel].offset=offset;
715 }
716 
717 static inline void SetPixelChannels(Image *image,const size_t number_channels)
718 {
719  image->number_channels=number_channels;
720 }
721 
722 static inline void SetPixelChannelTraits(Image *image,
723  const PixelChannel channel,const PixelTrait traits)
724 {
725  image->channel_map[channel].traits=traits;
726 }
727 
728 static inline void SetPixelCr(const Image *magick_restrict image,
729  const Quantum cr,Quantum *magick_restrict pixel)
730 {
731  pixel[image->channel_map[CrPixelChannel].offset]=cr;
732 }
733 
734 static inline void SetPixelCrTraits(Image *image,const PixelTrait traits)
735 {
736  image->channel_map[CrPixelChannel].traits=traits;
737 }
738 
739 static inline void SetPixelCyan(const Image *magick_restrict image,
740  const Quantum cyan,Quantum *magick_restrict pixel)
741 {
742  pixel[image->channel_map[CyanPixelChannel].offset]=cyan;
743 }
744 
745 static inline void SetPixelGray(const Image *magick_restrict image,
746  const Quantum gray,Quantum *magick_restrict pixel)
747 {
748  pixel[image->channel_map[GrayPixelChannel].offset]=gray;
749 }
750 
751 static inline void SetPixelGrayTraits(Image *image,const PixelTrait traits)
752 {
753  image->channel_map[GrayPixelChannel].traits=traits;
754 }
755 
756 static inline void SetPixelGreen(const Image *magick_restrict image,
757  const Quantum green,Quantum *magick_restrict pixel)
758 {
759  pixel[image->channel_map[GreenPixelChannel].offset]=green;
760 }
761 
762 static inline void SetPixelGreenTraits(Image *image,const PixelTrait traits)
763 {
764  image->channel_map[GreenPixelChannel].traits=traits;
765 }
766 
767 static inline void SetPixelIndex(const Image *magick_restrict image,
768  const Quantum index,Quantum *magick_restrict pixel)
769 {
770  if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
771  pixel[image->channel_map[IndexPixelChannel].offset]=index;
772 }
773 
774 static inline void SetPixelIndexTraits(Image *image,const PixelTrait traits)
775 {
776  image->channel_map[IndexPixelChannel].traits=traits;
777 }
778 
779 static inline void SetPixelViaPixelInfo(const Image *magick_restrict image,
780  const PixelInfo *magick_restrict pixel_info,Quantum *magick_restrict pixel)
781 {
782  pixel[image->channel_map[RedPixelChannel].offset]=
783  ClampToQuantum(pixel_info->red);
784  pixel[image->channel_map[GreenPixelChannel].offset]=
785  ClampToQuantum(pixel_info->green);
786  pixel[image->channel_map[BluePixelChannel].offset]=
787  ClampToQuantum(pixel_info->blue);
788  if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
789  pixel[image->channel_map[BlackPixelChannel].offset]=
790  ClampToQuantum(pixel_info->black);
791  if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
792  pixel[image->channel_map[AlphaPixelChannel].offset]=
793  pixel_info->alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
794  ClampToQuantum(pixel_info->alpha);
795 }
796 
797 static inline void SetPixelL(const Image *magick_restrict image,const Quantum L,
798  Quantum *magick_restrict pixel)
799 {
800  if (image->channel_map[LPixelChannel].traits != UndefinedPixelTrait)
801  pixel[image->channel_map[LPixelChannel].offset]=L;
802 }
803 
804 static inline void SetPixelMagenta(const Image *magick_restrict image,
805  const Quantum magenta,Quantum *magick_restrict pixel)
806 {
807  pixel[image->channel_map[MagentaPixelChannel].offset]=magenta;
808 }
809 
810 static inline void SetPixelMagentaTraits(Image *image,const PixelTrait traits)
811 {
812  image->channel_map[MagentaPixelChannel].traits=traits;
813 }
814 
815 static inline void SetPixelReadMask(const Image *magick_restrict image,
816  const Quantum mask,Quantum *magick_restrict pixel)
817 {
818  if (image->channel_map[ReadMaskPixelChannel].traits != UndefinedPixelTrait)
819  pixel[image->channel_map[ReadMaskPixelChannel].offset]=mask;
820 }
821 
822 static inline void SetPixelWriteMask(const Image *magick_restrict image,
823  const Quantum mask,Quantum *magick_restrict pixel)
824 {
825  if (image->channel_map[WriteMaskPixelChannel].traits != UndefinedPixelTrait)
826  pixel[image->channel_map[WriteMaskPixelChannel].offset]=mask;
827 }
828 
829 static inline void SetPixelMetacontentExtent(Image *image,const size_t extent)
830 {
831  image->metacontent_extent=extent;
832 }
833 
834 static inline void SetPixelOpacity(const Image *magick_restrict image,
835  const Quantum alpha,Quantum *magick_restrict pixel)
836 {
837  if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
838  pixel[image->channel_map[AlphaPixelChannel].offset]=QuantumRange-alpha;
839 }
840 
841 static inline void SetPixelRed(const Image *magick_restrict image,
842  const Quantum red,Quantum *magick_restrict pixel)
843 {
844  pixel[image->channel_map[RedPixelChannel].offset]=red;
845 }
846 
847 static inline void SetPixelRedTraits(Image *image,const PixelTrait traits)
848 {
849  image->channel_map[RedPixelChannel].traits=traits;
850 }
851 
852 static inline void SetPixelYellow(const Image *magick_restrict image,
853  const Quantum yellow,Quantum *magick_restrict pixel)
854 {
855  pixel[image->channel_map[YellowPixelChannel].offset]=yellow;
856 }
857 
858 static inline void SetPixelYellowTraits(Image *image,const PixelTrait traits)
859 {
860  image->channel_map[YellowPixelChannel].traits=traits;
861 }
862 
863 static inline void SetPixelY(const Image *magick_restrict image,
864  const Quantum y,Quantum *magick_restrict pixel)
865 {
866  pixel[image->channel_map[YPixelChannel].offset]=y;
867 }
868 
869 static inline void SetPixelYTraits(Image *image,const PixelTrait traits)
870 {
871  image->channel_map[YPixelChannel].traits=traits;
872 }
873 
874 #if defined(__cplusplus) || defined(c_plusplus)
875 }
876 #endif
877 
878 #endif
static void SetPixelChannelChannel(const Image *magick_restrict image, const PixelChannel channel, const ssize_t offset)
#define magick_restrict
Definition: MagickCore.h:41
MagickExport MagickRealType EncodePixelGamma(const MagickRealType pixel)
Definition: pixel.c:446
static size_t GetPixelMetacontentExtent(const Image *magick_restrict image)
MagickDoubleType MagickRealType
Definition: magick-type.h:118
static void SetPixelChannelAttributes(const Image *magick_restrict image, const PixelChannel channel, const PixelTrait traits, const ssize_t offset)
static Quantum GetPixelCyan(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
#define TransparentAlpha
Definition: image.h:26
static ssize_t GetPixelChannelOffset(const Image *magick_restrict image, const PixelChannel channel)
static PixelTrait GetPixelYTraits(const Image *magick_restrict image)
static void SetPixelBlackTraits(Image *image, const PixelTrait traits)
static void SetPixelY(const Image *magick_restrict image, const Quantum y, Quantum *magick_restrict pixel)
static void SetPixelYTraits(Image *image, const PixelTrait traits)
static PixelTrait GetPixelBlackTraits(const Image *magick_restrict image)
static void SetPixelBackgoundColor(const Image *magick_restrict image, Quantum *magick_restrict pixel)
static Quantum GetPixelAlpha(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static PixelTrait GetPixelRedTraits(const Image *magick_restrict image)
static Quantum GetPixelCr(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void SetPixelMetacontentExtent(Image *image, const size_t extent)
static void SetPixelOpacity(const Image *magick_restrict image, const Quantum alpha, Quantum *magick_restrict pixel)
static PixelTrait GetPixelIndexTraits(const Image *magick_restrict image)
static PixelTrait GetPixelAlphaTraits(const Image *magick_restrict image)
static Quantum GetPixelRed(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void SetPixelGrayTraits(Image *image, const PixelTrait traits)
static Quantum GetPixelGray(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void SetPixelYellowTraits(Image *image, const PixelTrait traits)
static void SetPixelGray(const Image *magick_restrict image, const Quantum gray, Quantum *magick_restrict pixel)
#define OpaqueAlpha
Definition: image.h:25
static Quantum GetPixelChannel(const Image *magick_restrict image, const PixelChannel channel, const Quantum *magick_restrict pixel)
static PixelTrait GetPixelChannelTraits(const Image *magick_restrict image, const PixelChannel channel)
static MagickRealType AbsolutePixelValue(const MagickRealType x)
static void SetPixelViaPixelInfo(const Image *magick_restrict image, const PixelInfo *magick_restrict pixel_info, Quantum *magick_restrict pixel)
static Quantum GetPixelReadMask(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static MagickBooleanType IsPixelMonochrome(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static Quantum GetPixela(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void SetPixela(const Image *magick_restrict image, const Quantum a, Quantum *magick_restrict pixel)
static PixelTrait GetPixelCbTraits(const Image *magick_restrict image)
#define MAGICKCORE_QUANTUM_DEPTH
Definition: magick-type.h:28
static Quantum GetPixelb(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static MagickRealType GetPixelLuma(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
#define MagickEpsilon
Definition: magick-type.h:110
static MagickBooleanType IsPixelInfoEquivalent(const PixelInfo *magick_restrict p, const PixelInfo *magick_restrict q)
Definition: image.h:151
MagickExport MagickRealType DecodePixelGamma(const MagickRealType pixel)
Definition: pixel.c:319
static void SetPixelChannelTraits(Image *image, const PixelChannel channel, const PixelTrait traits)
static MagickBooleanType IsPixelEquivalent(const Image *magick_restrict image, const Quantum *magick_restrict p, const PixelInfo *magick_restrict q)
static Quantum ClampPixel(const MagickRealType pixel)
static void SetPixelRedTraits(Image *image, const PixelTrait traits)
static MagickBooleanType IsPixelInfoMonochrome(const PixelInfo *magick_restrict pixel_info)
static Quantum GetPixelY(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void SetPixelAlphaTraits(Image *image, const PixelTrait traits)
MagickBooleanType
Definition: magick-type.h:156
static double PerceptibleReciprocal(const double x)
static Quantum GetPixelWriteMask(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void SetPixelChannels(Image *image, const size_t number_channels)
static void SetPixelL(const Image *magick_restrict image, const Quantum L, Quantum *magick_restrict pixel)
static PixelTrait GetPixelReadMaskTraits(const Image *magick_restrict image)
static Quantum GetPixelOpacity(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static Quantum GetPixelMagenta(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void SetPixelMagentaTraits(Image *image, const PixelTrait traits)
static MagickBooleanType IsPixelAtDepth(const Quantum pixel, const QuantumAny range)
static PixelTrait GetPixelCrTraits(const Image *magick_restrict image)
static Quantum GetPixelGreen(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void GetPixelInfoPixel(const Image *magick_restrict image, const Quantum *magick_restrict pixel, PixelInfo *magick_restrict pixel_info)
static PixelTrait GetPixelCyanTraits(const Image *magick_restrict image)
static Quantum GetPixelIndex(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static Quantum GetPixelBlack(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void SetPixelCr(const Image *magick_restrict image, const Quantum cr, Quantum *magick_restrict pixel)
static void SetPixelIndexTraits(Image *image, const PixelTrait traits)
static MagickBooleanType IsPixelGray(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void SetPixelMagenta(const Image *magick_restrict image, const Quantum magenta, Quantum *magick_restrict pixel)
static PixelTrait GetPixelGreenTraits(const Image *magick_restrict image)
static PixelTrait GetPixelGrayTraits(const Image *magick_restrict image)
static void SetPixelBlue(const Image *magick_restrict image, const Quantum blue, Quantum *magick_restrict pixel)
static void SetPixelWriteMask(const Image *magick_restrict image, const Quantum mask, Quantum *magick_restrict pixel)
PixelChannel
Definition: pixel.h:66
static void SetPixelCbTraits(Image *image, const PixelTrait traits)
static size_t GetPixelChannels(const Image *magick_restrict image)
static void SetPixelCyan(const Image *magick_restrict image, const Quantum cyan, Quantum *magick_restrict pixel)
static Quantum ClampToQuantum(const MagickRealType value)
Definition: quantum.h:84
static PixelChannel GetPixelChannelChannel(const Image *magick_restrict image, const ssize_t offset)
static MagickRealType GetPixelInfoChannel(const PixelInfo *magick_restrict pixel_info, const PixelChannel channel)
static void SetPixelCrTraits(Image *image, const PixelTrait traits)
static PixelTrait GetPixelMagentaTraits(const Image *magick_restrict image)
unsigned short Quantum
Definition: magick-type.h:82
static size_t GetPixelMetaChannels(const Image *magick_restrict image)
static MagickBooleanType IsPixelInfoGray(const PixelInfo *magick_restrict pixel)
static Quantum GetPixelCb(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void SetPixelIndex(const Image *magick_restrict image, const Quantum index, Quantum *magick_restrict pixel)
size_t number_channels
Definition: image.h:283
static void SetPixelChannel(const Image *magick_restrict image, const PixelChannel channel, const Quantum quantum, Quantum *magick_restrict pixel)
static void SetPixelYellow(const Image *magick_restrict image, const Quantum yellow, Quantum *magick_restrict pixel)
static PixelTrait GetPixelTraits(const Image *magick_restrict image, const PixelChannel channel)
static void SetPixelAlpha(const Image *magick_restrict image, const Quantum alpha, Quantum *magick_restrict pixel)
static MagickRealType GetPixelInfoLuminance(const PixelInfo *magick_restrict pixel)
size_t metacontent_extent
Definition: image.h:283
#define MaxPixelChannels
Definition: pixel.h:27
static void SetPixelGreenTraits(Image *image, const PixelTrait traits)
static MagickRealType GetPixelLuminance(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static PixelTrait GetPixelYellowTraits(const Image *magick_restrict image)
static ssize_t GetPixelLabel(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void SetPixelRed(const Image *magick_restrict image, const Quantum red, Quantum *magick_restrict pixel)
static MagickRealType GetPixelInfoLuma(const PixelInfo *magick_restrict pixel)
PixelTrait traits
Definition: pixel.h:161
static void SetPixelb(const Image *magick_restrict image, const Quantum b, Quantum *magick_restrict pixel)
static Quantum GetPixelYellow(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void SetPixelBlack(const Image *magick_restrict image, const Quantum black, Quantum *magick_restrict pixel)
static Quantum GetPixelBlue(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
PixelTrait
Definition: pixel.h:132
MagickSizeType QuantumAny
Definition: magick-type.h:142
static void SetPixelReadMask(const Image *magick_restrict image, const Quantum mask, Quantum *magick_restrict pixel)
static Quantum GetPixelL(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void SetPixelBlueTraits(Image *image, const PixelTrait traits)
static void SetPixelCb(const Image *magick_restrict image, const Quantum cb, Quantum *magick_restrict pixel)
#define QuantumRange
Definition: magick-type.h:83
PixelChannelMap * channel_map
Definition: image.h:291
static void SetPixelGreen(const Image *magick_restrict image, const Quantum green, Quantum *magick_restrict pixel)
static PixelTrait GetPixelBlueTraits(const Image *magick_restrict image)