MagickCore  7.1.0
pixel-accessor.h
Go to the documentation of this file.
1 /*
2  Copyright 1999-2021 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 pixel accessor methods.
17 */
18 #ifndef MAGICKCORE_PIXEL_ACCESSOR_H
19 #define MAGICKCORE_PIXEL_ACCESSOR_H
20 
21 #include "MagickCore/cache.h"
22 #include "MagickCore/cache-view.h"
23 #include "MagickCore/color.h"
24 #include "MagickCore/colorspace.h"
25 #include "MagickCore/gem.h"
26 #include "MagickCore/image.h"
27 #include "MagickCore/memory_.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 
142  const Quantum *magick_restrict pixel)
143 {
144  if (image->channel_map[CompositeMaskPixelChannel].traits == UndefinedPixelTrait)
145  return((Quantum) QuantumRange);
146  return(pixel[image->channel_map[CompositeMaskPixelChannel].offset]);
147 }
148 
149 static inline Quantum GetPixelCr(const Image *magick_restrict image,
150  const Quantum *magick_restrict pixel)
151 {
152  return(pixel[image->channel_map[CrPixelChannel].offset]);
153 }
154 
156 {
157  return(image->channel_map[CrPixelChannel].traits);
158 }
159 
160 static inline Quantum GetPixelCyan(const Image *magick_restrict image,
161  const Quantum *magick_restrict pixel)
162 {
163  return(pixel[image->channel_map[CyanPixelChannel].offset]);
164 }
165 
167 {
168  return(image->channel_map[CyanPixelChannel].traits);
169 }
170 
171 static inline Quantum GetPixelGray(const Image *magick_restrict image,
172  const Quantum *magick_restrict pixel)
173 {
174  return(pixel[image->channel_map[GrayPixelChannel].offset]);
175 }
176 
178 {
179  return(image->channel_map[GrayPixelChannel].traits);
180 }
181 
182 static inline Quantum GetPixelGreen(const Image *magick_restrict image,
183  const Quantum *magick_restrict pixel)
184 {
185  return(pixel[image->channel_map[GreenPixelChannel].offset]);
186 }
187 
189  const Image *magick_restrict image)
190 {
191  return(image->channel_map[GreenPixelChannel].traits);
192 }
193 
194 static inline Quantum GetPixelIndex(const Image *magick_restrict image,
195  const Quantum *magick_restrict pixel)
196 {
197  if (image->channel_map[IndexPixelChannel].traits == UndefinedPixelTrait)
198  return((Quantum) 0);
199  return(pixel[image->channel_map[IndexPixelChannel].offset]);
200 }
201 
203  const Image *magick_restrict image)
204 {
205  return(image->channel_map[IndexPixelChannel].traits);
206 }
207 
209  const PixelInfo *magick_restrict pixel_info,const PixelChannel channel)
210 {
211  switch (channel)
212  {
213  case RedPixelChannel: return(pixel_info->red);
214  case GreenPixelChannel: return(pixel_info->green);
215  case BluePixelChannel: return(pixel_info->blue);
216  case BlackPixelChannel:
217  {
218  if (pixel_info->colorspace != CMYKColorspace)
219  return(0.0);
220  return(pixel_info->black);
221  }
222  case AlphaPixelChannel:
223  {
224  if (pixel_info->alpha_trait == UndefinedPixelTrait)
225  return(OpaqueAlpha);
226  return(pixel_info->alpha);
227  }
228  case IndexPixelChannel: return(pixel_info->index);
229  default: return((MagickRealType) 0.0);
230  }
231 }
232 
233 static inline double PerceptibleReciprocal(const double x)
234 {
235  double
236  sign;
237 
238  /*
239  Return 1/x where x is perceptible (not unlimited or infinitesimal).
240  */
241  sign=x < 0.0 ? -1.0 : 1.0;
242  if ((sign*x) >= MagickEpsilon)
243  return(1.0/x);
244  return(sign/MagickEpsilon);
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*EncodePixelGamma(pixel->red)+
260  0.715158f*EncodePixelGamma(pixel->green)+
261  0.072186f*EncodePixelGamma(pixel->blue));
262  return(intensity);
263 }
264 
266  const PixelInfo *magick_restrict pixel)
267 {
269  intensity;
270 
271  if (pixel->colorspace != sRGBColorspace)
272  {
273  intensity=(MagickRealType) (0.212656f*pixel->red+0.715158f*pixel->green+
274  0.072186f*pixel->blue);
275  return(intensity);
276  }
277  intensity=(MagickRealType) (0.212656f*DecodePixelGamma(pixel->red)+
278  0.715158f*DecodePixelGamma(pixel->green)+
279  0.072186f*DecodePixelGamma(pixel->blue));
280  return(intensity);
281 }
282 
283 static inline Quantum GetPixelL(const Image *magick_restrict image,
284  const Quantum *magick_restrict pixel)
285 {
286  return(pixel[image->channel_map[LPixelChannel].offset]);
287 }
288 
289 static inline ssize_t GetPixelLabel(const Image *magick_restrict image,
290  const Quantum *magick_restrict pixel)
291 {
292  return((ssize_t) pixel[image->channel_map[LabelPixelChannel].offset]);
293 }
294 
296  const Quantum *magick_restrict pixel)
297 {
299  intensity;
300 
301  intensity=
302  0.212656f*(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]+
303  0.715158f*(MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset]+
304  0.072186f*(MagickRealType) pixel[image->channel_map[BluePixelChannel].offset];
305  return(intensity);
306 }
307 
309  const Image *magick_restrict image,const Quantum *magick_restrict pixel)
310 {
312  intensity;
313 
314  if (image->colorspace != sRGBColorspace)
315  {
316  intensity=
317  0.212656f*(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]+
318  0.715158f*(MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset]+
319  0.072186f*(MagickRealType) pixel[image->channel_map[BluePixelChannel].offset];
320  return(intensity);
321  }
322  intensity=(MagickRealType) (0.212656f*DecodePixelGamma((MagickRealType)
323  pixel[image->channel_map[RedPixelChannel].offset])+0.715158f*
325  pixel[image->channel_map[GreenPixelChannel].offset])+0.072186f*
327  pixel[image->channel_map[BluePixelChannel].offset]));
328  return(intensity);
329 }
330 
331 static inline Quantum GetPixelMagenta(const Image *magick_restrict image,
332  const Quantum *magick_restrict pixel)
333 {
334  return(pixel[image->channel_map[MagentaPixelChannel].offset]);
335 }
336 
338  const Image *magick_restrict image)
339 {
340  return(image->channel_map[MagentaPixelChannel].traits);
341 }
342 
343 static inline Quantum GetPixelReadMask(const Image *magick_restrict image,
344  const Quantum *magick_restrict pixel)
345 {
346  if (image->channel_map[ReadMaskPixelChannel].traits == UndefinedPixelTrait)
347  return((Quantum) QuantumRange);
348  return(pixel[image->channel_map[ReadMaskPixelChannel].offset]);
349 }
350 
351 static inline Quantum GetPixelWriteMask(const Image *magick_restrict image,
352  const Quantum *magick_restrict pixel)
353 {
354  if (image->channel_map[WriteMaskPixelChannel].traits == UndefinedPixelTrait)
355  return((Quantum) QuantumRange);
356  return(pixel[image->channel_map[WriteMaskPixelChannel].offset]);
357 }
358 
360  const Image *magick_restrict image)
361 {
362  return(image->channel_map[ReadMaskPixelChannel].traits);
363 }
364 
365 static inline size_t GetPixelMetaChannels(const Image *magick_restrict image)
366 {
367  return(image->number_meta_channels);
368 }
369 
370 static inline size_t GetPixelMetacontentExtent(
371  const Image *magick_restrict image)
372 {
373  return(image->metacontent_extent);
374 }
375 
376 static inline Quantum GetPixelOpacity(const Image *magick_restrict image,
377  const Quantum *magick_restrict pixel)
378 {
379  if (image->channel_map[AlphaPixelChannel].traits != BlendPixelTrait)
380  return(QuantumRange-OpaqueAlpha);
381  return(QuantumRange-pixel[image->channel_map[AlphaPixelChannel].offset]);
382 }
383 
384 static inline Quantum GetPixelRed(const Image *magick_restrict image,
385  const Quantum *magick_restrict pixel)
386 {
387  return(pixel[image->channel_map[RedPixelChannel].offset]);
388 }
389 
391 {
392  return(image->channel_map[RedPixelChannel].traits);
393 }
394 
395 static inline void GetPixelInfoPixel(const Image *magick_restrict image,
396  const Quantum *magick_restrict pixel,PixelInfo *magick_restrict pixel_info)
397 {
398  (void) ResetMagickMemory(pixel_info,0,sizeof(*pixel_info));
399  pixel_info->storage_class=DirectClass;
400  pixel_info->colorspace=sRGBColorspace;
401  pixel_info->depth=MAGICKCORE_QUANTUM_DEPTH;
402  pixel_info->alpha_trait=UndefinedPixelTrait;
403  pixel_info->alpha=(MagickRealType) OpaqueAlpha;
404  if (image != (Image *) NULL)
405  {
406  pixel_info->storage_class=image->storage_class;
407  pixel_info->colorspace=image->colorspace;
408  pixel_info->fuzz=image->fuzz;
409  pixel_info->depth=image->depth;
410  pixel_info->alpha_trait=image->alpha_trait;
411  if (pixel != (Quantum *) NULL)
412  {
413  pixel_info->red=(MagickRealType)
414  pixel[image->channel_map[RedPixelChannel].offset];
415  pixel_info->green=(MagickRealType)
416  pixel[image->channel_map[GreenPixelChannel].offset];
417  pixel_info->blue=(MagickRealType)
418  pixel[image->channel_map[BluePixelChannel].offset];
419  if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
420  pixel_info->black=(MagickRealType)
421  pixel[image->channel_map[BlackPixelChannel].offset];
422  if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
423  pixel_info->alpha=(MagickRealType)
424  pixel[image->channel_map[AlphaPixelChannel].offset];
425  if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
426  pixel_info->index=(MagickRealType)
427  pixel[image->channel_map[IndexPixelChannel].offset];
428  }
429  }
430 }
431 
432 static inline PixelTrait GetPixelTraits(const Image *magick_restrict image,
433  const PixelChannel channel)
434 {
435  return(image->channel_map[channel].traits);
436 }
437 
438 static inline Quantum GetPixelY(const Image *magick_restrict image,
439  const Quantum *magick_restrict pixel)
440 {
441  return(pixel[image->channel_map[YPixelChannel].offset]);
442 }
443 
444 static inline PixelTrait GetPixelYTraits(const Image *magick_restrict image)
445 {
446  return(image->channel_map[YPixelChannel].traits);
447 }
448 
449 static inline Quantum GetPixelYellow(const Image *magick_restrict image,
450  const Quantum *magick_restrict pixel)
451 {
452  return(pixel[image->channel_map[YellowPixelChannel].offset]);
453 }
454 
456  const Image *magick_restrict image)
457 {
458  return(image->channel_map[YellowPixelChannel].traits);
459 }
460 
462 {
463  return(x < 0.0f ? -x : x);
464 }
465 
466 static inline MagickBooleanType IsPixelAtDepth(const Quantum pixel,
467  const QuantumAny range)
468 {
469  Quantum
470  quantum;
471 
472  if (range == 0)
473  return(MagickTrue);
474 #if !defined(MAGICKCORE_HDRI_SUPPORT)
476  (((MagickRealType) range*pixel)/QuantumRange+0.5)))/range+0.5);
477 #else
479  (((MagickRealType) range*pixel)/QuantumRange+0.5)))/range);
480 #endif
481  return(pixel == quantum ? MagickTrue : MagickFalse);
482 }
483 
485  const Image *magick_restrict image,const Quantum *magick_restrict p,
486  const PixelInfo *magick_restrict q)
487 {
489  alpha,
490  beta,
491  color;
492 
493  color=(MagickRealType) p[image->channel_map[AlphaPixelChannel].offset];
494  alpha=image->alpha_trait == UndefinedPixelTrait ? (MagickRealType)
495  OpaqueAlpha : color;
496  beta=q->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
497  q->alpha;
498  if (AbsolutePixelValue(alpha-beta) >= MagickEpsilon)
499  return(MagickFalse);
502  return(MagickTrue); /* no color component if pixel is transparent */
503  color=(MagickRealType) p[image->channel_map[RedPixelChannel].offset];
504  if (AbsolutePixelValue(color-q->red) >= MagickEpsilon)
505  return(MagickFalse);
506  color=(MagickRealType) p[image->channel_map[GreenPixelChannel].offset];
507  if (AbsolutePixelValue(color-q->green) >= MagickEpsilon)
508  return(MagickFalse);
509  color=(MagickRealType) p[image->channel_map[BluePixelChannel].offset];
510  if (AbsolutePixelValue(color-q->blue) >= MagickEpsilon)
511  return(MagickFalse);
512  if (image->colorspace == CMYKColorspace)
513  {
514  color=(MagickRealType) p[image->channel_map[BlackPixelChannel].offset];
515  if (AbsolutePixelValue(color-q->black) >= MagickEpsilon)
516  return(MagickFalse);
517  }
518  return(MagickTrue);
519 }
520 
522  const Quantum *magick_restrict pixel)
523 {
525  green_blue,
526  red_green;
527 
528  red_green=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]-
529  pixel[image->channel_map[GreenPixelChannel].offset];
530  green_blue=(MagickRealType)
531  pixel[image->channel_map[GreenPixelChannel].offset]-
532  pixel[image->channel_map[BluePixelChannel].offset];
533  if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
534  (AbsolutePixelValue(green_blue) < MagickEpsilon))
535  return(MagickTrue);
536  return(MagickFalse);
537 }
538 
541 {
543  alpha,
544  beta;
545 
546  alpha=p->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
547  p->alpha;
548  beta=q->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
549  q->alpha;
550  if (AbsolutePixelValue(alpha-beta) >= MagickEpsilon)
551  return(MagickFalse);
554  return(MagickTrue); /* no color component if pixel is transparent */
555  if (AbsolutePixelValue(p->red-q->red) >= MagickEpsilon)
556  return(MagickFalse);
557  if (AbsolutePixelValue(p->green-q->green) >= MagickEpsilon)
558  return(MagickFalse);
559  if (AbsolutePixelValue(p->blue-q->blue) >= MagickEpsilon)
560  return(MagickFalse);
561  if (p->colorspace == CMYKColorspace)
562  {
563  if (AbsolutePixelValue(p->black-q->black) >= MagickEpsilon)
564  return(MagickFalse);
565  }
566  return(MagickTrue);
567 }
568 
570  const Image *magick_restrict image,const Quantum *magick_restrict pixel)
571 {
573  green_blue,
574  red,
575  red_green;
576 
577  red=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset];
578  if ((AbsolutePixelValue(red) >= MagickEpsilon) &&
580  return(MagickFalse);
581  red_green=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]-
582  pixel[image->channel_map[GreenPixelChannel].offset];
583  green_blue=(MagickRealType)
584  pixel[image->channel_map[GreenPixelChannel].offset]-
585  pixel[image->channel_map[BluePixelChannel].offset];
586  if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
587  (AbsolutePixelValue(green_blue) < MagickEpsilon))
588  return(MagickTrue);
589  return(MagickFalse);
590 }
591 
593  const PixelInfo *magick_restrict pixel)
594 {
595  if ((AbsolutePixelValue(pixel->red-pixel->green) < MagickEpsilon) &&
596  (AbsolutePixelValue(pixel->green-pixel->blue) < MagickEpsilon))
597  return(MagickTrue);
598  return(MagickFalse);
599 }
600 
602  const PixelInfo *magick_restrict pixel_info)
603 {
605  green_blue,
606  red_green;
607 
608  if ((AbsolutePixelValue(pixel_info->red) >= MagickEpsilon) ||
609  (AbsolutePixelValue(pixel_info->red-QuantumRange) >= MagickEpsilon))
610  return(MagickFalse);
611  red_green=pixel_info->red-pixel_info->green;
612  green_blue=pixel_info->green-pixel_info->blue;
613  if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
614  (AbsolutePixelValue(green_blue) < MagickEpsilon))
615  return(MagickTrue);
616  return(MagickFalse);
617 }
618 
619 static inline void SetPixela(const Image *magick_restrict image,
620  const Quantum a,Quantum *magick_restrict pixel)
621 {
622  if (image->channel_map[aPixelChannel].traits != UndefinedPixelTrait)
623  pixel[image->channel_map[aPixelChannel].offset]=a;
624 }
625 
626 static inline void SetPixelAlpha(const Image *magick_restrict image,
627  const Quantum alpha,Quantum *magick_restrict pixel)
628 {
629  if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
630  pixel[image->channel_map[AlphaPixelChannel].offset]=alpha;
631 }
632 
633 static inline void SetPixelAlphaTraits(Image *image,const PixelTrait traits)
634 {
635  image->channel_map[AlphaPixelChannel].traits=traits;
636 }
637 
638 static inline void SetPixelb(const Image *magick_restrict image,
639  const Quantum b,Quantum *magick_restrict pixel)
640 {
641  if (image->channel_map[bPixelChannel].traits != UndefinedPixelTrait)
642  pixel[image->channel_map[bPixelChannel].offset]=b;
643 }
644 
645 static inline void SetPixelBackgoundColor(const Image *magick_restrict image,
646  Quantum *magick_restrict pixel)
647 {
648  ssize_t
649  i;
650 
651  for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
652  pixel[i]=(Quantum) 0;
653  pixel[image->channel_map[RedPixelChannel].offset]=
654  ClampToQuantum(image->background_color.red);
655  pixel[image->channel_map[GreenPixelChannel].offset]=
656  ClampToQuantum(image->background_color.green);
657  pixel[image->channel_map[BluePixelChannel].offset]=
658  ClampToQuantum(image->background_color.blue);
659  if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
660  pixel[image->channel_map[BlackPixelChannel].offset]=
661  ClampToQuantum(image->background_color.black);
662  if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
663  pixel[image->channel_map[AlphaPixelChannel].offset]=
664  image->background_color.alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
665  ClampToQuantum(image->background_color.alpha);
666 }
667 
668 static inline void SetPixelBlack(const Image *magick_restrict image,
669  const Quantum black,Quantum *magick_restrict pixel)
670 {
671  if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
672  pixel[image->channel_map[BlackPixelChannel].offset]=black;
673 }
674 
675 static inline void SetPixelBlackTraits(Image *image,const PixelTrait traits)
676 {
677  image->channel_map[BlackPixelChannel].traits=traits;
678 }
679 
680 static inline void SetPixelBlue(const Image *magick_restrict image,
681  const Quantum blue,Quantum *magick_restrict pixel)
682 {
683  pixel[image->channel_map[BluePixelChannel].offset]=blue;
684 }
685 
686 static inline void SetPixelBlueTraits(Image *image,const PixelTrait traits)
687 {
688  image->channel_map[BluePixelChannel].traits=traits;
689 }
690 
691 static inline void SetPixelCb(const Image *magick_restrict image,
692  const Quantum cb,Quantum *magick_restrict pixel)
693 {
694  pixel[image->channel_map[CbPixelChannel].offset]=cb;
695 }
696 
697 static inline void SetPixelCbTraits(Image *image,const PixelTrait traits)
698 {
699  image->channel_map[CbPixelChannel].traits=traits;
700 }
701 
702 static inline void SetPixelChannel(const Image *magick_restrict image,
703  const PixelChannel channel,const Quantum quantum,
704  Quantum *magick_restrict pixel)
705 {
706  if (image->channel_map[channel].traits != UndefinedPixelTrait)
707  pixel[image->channel_map[channel].offset]=quantum;
708 }
709 
710 static inline void SetPixelChannelAttributes(
711  const Image *magick_restrict image,const PixelChannel channel,
712  const PixelTrait traits,const ssize_t offset)
713 {
714  if ((ssize_t) channel >= MaxPixelChannels)
715  return;
716  if (offset >= MaxPixelChannels)
717  return;
718  image->channel_map[offset].channel=channel;
719  image->channel_map[channel].offset=offset;
720  image->channel_map[channel].traits=traits;
721 }
722 
723 static inline void SetPixelChannelChannel(const Image *magick_restrict image,
724  const PixelChannel channel,const ssize_t offset)
725 {
726  image->channel_map[offset].channel=channel;
727  image->channel_map[channel].offset=offset;
728 }
729 
730 static inline void SetPixelChannels(Image *image,const size_t number_channels)
731 {
732  image->number_channels=number_channels;
733 }
734 
735 static inline void SetPixelChannelTraits(Image *image,
736  const PixelChannel channel,const PixelTrait traits)
737 {
738  image->channel_map[channel].traits=traits;
739 }
740 
741 static inline void SetPixelCompositeMask(const Image *magick_restrict image,
742  const Quantum mask,Quantum *magick_restrict pixel)
743 {
744  if (image->channel_map[CompositeMaskPixelChannel].traits != UndefinedPixelTrait)
745  pixel[image->channel_map[CompositeMaskPixelChannel].offset]=mask;
746 }
747 
748 static inline void SetPixelCr(const Image *magick_restrict image,
749  const Quantum cr,Quantum *magick_restrict pixel)
750 {
751  pixel[image->channel_map[CrPixelChannel].offset]=cr;
752 }
753 
754 static inline void SetPixelCrTraits(Image *image,const PixelTrait traits)
755 {
756  image->channel_map[CrPixelChannel].traits=traits;
757 }
758 
759 static inline void SetPixelCyan(const Image *magick_restrict image,
760  const Quantum cyan,Quantum *magick_restrict pixel)
761 {
762  pixel[image->channel_map[CyanPixelChannel].offset]=cyan;
763 }
764 
765 static inline void SetPixelGray(const Image *magick_restrict image,
766  const Quantum gray,Quantum *magick_restrict pixel)
767 {
768  pixel[image->channel_map[GrayPixelChannel].offset]=gray;
769 }
770 
771 static inline void SetPixelGrayTraits(Image *image,const PixelTrait traits)
772 {
773  image->channel_map[GrayPixelChannel].traits=traits;
774 }
775 
776 static inline void SetPixelGreen(const Image *magick_restrict image,
777  const Quantum green,Quantum *magick_restrict pixel)
778 {
779  pixel[image->channel_map[GreenPixelChannel].offset]=green;
780 }
781 
782 static inline void SetPixelGreenTraits(Image *image,const PixelTrait traits)
783 {
784  image->channel_map[GreenPixelChannel].traits=traits;
785 }
786 
787 static inline void SetPixelIndex(const Image *magick_restrict image,
788  const Quantum index,Quantum *magick_restrict pixel)
789 {
790  if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
791  pixel[image->channel_map[IndexPixelChannel].offset]=index;
792 }
793 
794 static inline void SetPixelIndexTraits(Image *image,const PixelTrait traits)
795 {
796  image->channel_map[IndexPixelChannel].traits=traits;
797 }
798 
799 static inline void SetPixelViaPixelInfo(const Image *magick_restrict image,
800  const PixelInfo *magick_restrict pixel_info,Quantum *magick_restrict pixel)
801 {
802  pixel[image->channel_map[RedPixelChannel].offset]=
803  ClampToQuantum(pixel_info->red);
804  pixel[image->channel_map[GreenPixelChannel].offset]=
805  ClampToQuantum(pixel_info->green);
806  pixel[image->channel_map[BluePixelChannel].offset]=
807  ClampToQuantum(pixel_info->blue);
808  if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
809  pixel[image->channel_map[BlackPixelChannel].offset]=
810  ClampToQuantum(pixel_info->black);
811  if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
812  pixel[image->channel_map[AlphaPixelChannel].offset]=
813  pixel_info->alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
814  ClampToQuantum(pixel_info->alpha);
815 }
816 
817 static inline void SetPixelL(const Image *magick_restrict image,const Quantum L,
818  Quantum *magick_restrict pixel)
819 {
820  if (image->channel_map[LPixelChannel].traits != UndefinedPixelTrait)
821  pixel[image->channel_map[LPixelChannel].offset]=L;
822 }
823 
824 static inline void SetPixelMagenta(const Image *magick_restrict image,
825  const Quantum magenta,Quantum *magick_restrict pixel)
826 {
827  pixel[image->channel_map[MagentaPixelChannel].offset]=magenta;
828 }
829 
830 static inline void SetPixelMagentaTraits(Image *image,const PixelTrait traits)
831 {
832  image->channel_map[MagentaPixelChannel].traits=traits;
833 }
834 
835 static inline void SetPixelReadMask(const Image *magick_restrict image,
836  const Quantum mask,Quantum *magick_restrict pixel)
837 {
838  if (image->channel_map[ReadMaskPixelChannel].traits != UndefinedPixelTrait)
839  pixel[image->channel_map[ReadMaskPixelChannel].offset]=mask;
840 }
841 
842 static inline void SetPixelWriteMask(const Image *magick_restrict image,
843  const Quantum mask,Quantum *magick_restrict pixel)
844 {
845  if (image->channel_map[WriteMaskPixelChannel].traits != UndefinedPixelTrait)
846  pixel[image->channel_map[WriteMaskPixelChannel].offset]=mask;
847 }
848 
849 static inline void SetPixelMetacontentExtent(Image *image,const size_t extent)
850 {
851  image->metacontent_extent=extent;
852 }
853 
854 static inline void SetPixelOpacity(const Image *magick_restrict image,
855  const Quantum alpha,Quantum *magick_restrict pixel)
856 {
857  if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
858  pixel[image->channel_map[AlphaPixelChannel].offset]=QuantumRange-alpha;
859 }
860 
861 static inline void SetPixelRed(const Image *magick_restrict image,
862  const Quantum red,Quantum *magick_restrict pixel)
863 {
864  pixel[image->channel_map[RedPixelChannel].offset]=red;
865 }
866 
867 static inline void SetPixelRedTraits(Image *image,const PixelTrait traits)
868 {
869  image->channel_map[RedPixelChannel].traits=traits;
870 }
871 
872 static inline void SetPixelYellow(const Image *magick_restrict image,
873  const Quantum yellow,Quantum *magick_restrict pixel)
874 {
875  pixel[image->channel_map[YellowPixelChannel].offset]=yellow;
876 }
877 
878 static inline void SetPixelYellowTraits(Image *image,const PixelTrait traits)
879 {
880  image->channel_map[YellowPixelChannel].traits=traits;
881 }
882 
883 static inline void SetPixelY(const Image *magick_restrict image,
884  const Quantum y,Quantum *magick_restrict pixel)
885 {
886  pixel[image->channel_map[YPixelChannel].offset]=y;
887 }
888 
889 static inline void SetPixelYTraits(Image *image,const PixelTrait traits)
890 {
891  image->channel_map[YPixelChannel].traits=traits;
892 }
893 
894 #if defined(__cplusplus) || defined(c_plusplus)
895 }
896 #endif
897 
898 #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:124
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:32
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:114
static Quantum ClampToQuantum(const MagickRealType quantum)
Definition: quantum.h:85
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:161
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)
MagickExport void * ResetMagickMemory(void *memory, int c, const size_t size)
Definition: memory.c:1290
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:70
static void SetPixelCbTraits(Image *image, const PixelTrait traits)
static size_t GetPixelChannels(const Image *magick_restrict image)
static void SetPixelCompositeMask(const Image *magick_restrict image, const Quantum mask, Quantum *magick_restrict pixel)
static void SetPixelCyan(const Image *magick_restrict image, const Quantum cyan, Quantum *magick_restrict pixel)
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:86
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 Quantum GetPixelCompositeMask(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
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:166
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:137
MagickSizeType QuantumAny
Definition: magick-type.h:152
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:87
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)