18 #ifndef MAGICKCORE_PIXEL_ACCESSOR_H
19 #define MAGICKCORE_PIXEL_ACCESSOR_H
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"
29 #if defined(__cplusplus) || defined(c_plusplus)
35 static inline Quantum ClampPixel(
const MagickRealType pixel)
39 if (pixel >= (MagickRealType) QuantumRange)
40 return((Quantum) QuantumRange);
41 #if !defined(MAGICKCORE_HDRI_SUPPORT)
42 return((Quantum) (pixel+0.5f));
44 return((Quantum) pixel);
48 static inline Quantum GetPixela(
const Image *magick_restrict image,
49 const Quantum *magick_restrict pixel)
51 return(pixel[image->channel_map[aPixelChannel].offset]);
54 static inline Quantum GetPixelAlpha(
const Image *magick_restrict image,
55 const Quantum *magick_restrict pixel)
57 if (image->channel_map[AlphaPixelChannel].traits == UndefinedPixelTrait)
59 return(pixel[image->channel_map[AlphaPixelChannel].offset]);
62 static inline PixelTrait GetPixelAlphaTraits(
const Image *magick_restrict image)
64 return(image->channel_map[AlphaPixelChannel].traits);
67 static inline Quantum GetPixelb(
const Image *magick_restrict image,
68 const Quantum *magick_restrict pixel)
70 return(pixel[image->channel_map[bPixelChannel].offset]);
73 static inline Quantum GetPixelBlack(
const Image *magick_restrict image,
74 const Quantum *magick_restrict pixel)
76 if (image->channel_map[BlackPixelChannel].traits == UndefinedPixelTrait)
78 return(pixel[image->channel_map[BlackPixelChannel].offset]);
81 static inline PixelTrait GetPixelBlackTraits(
const Image *magick_restrict image)
83 return(image->channel_map[BlackPixelChannel].traits);
86 static inline Quantum GetPixelBlue(
const Image *magick_restrict image,
87 const Quantum *magick_restrict pixel)
89 return(pixel[image->channel_map[BluePixelChannel].offset]);
92 static inline PixelTrait GetPixelBlueTraits(
const Image *magick_restrict image)
94 return(image->channel_map[BluePixelChannel].traits);
97 static inline Quantum GetPixelCb(
const Image *magick_restrict image,
98 const Quantum *magick_restrict pixel)
100 return(pixel[image->channel_map[CbPixelChannel].offset]);
103 static inline PixelTrait GetPixelCbTraits(
const Image *magick_restrict image)
105 return(image->channel_map[CbPixelChannel].traits);
108 static inline Quantum GetPixelChannel(
const Image *magick_restrict image,
109 const PixelChannel channel,
const Quantum *magick_restrict pixel)
111 if (image->channel_map[channel].traits == UndefinedPixelTrait)
113 return(pixel[image->channel_map[channel].offset]);
116 static inline PixelChannel GetPixelChannelChannel(
117 const Image *magick_restrict image,
const ssize_t offset)
119 return(image->channel_map[offset].channel);
122 static inline ssize_t GetPixelChannelOffset(
const Image *magick_restrict image,
123 const PixelChannel channel)
125 return(image->channel_map[channel].offset);
128 static inline PixelTrait GetPixelChannelTraits(
129 const Image *magick_restrict image,
const PixelChannel channel)
131 return(image->channel_map[channel].traits);
134 static inline size_t GetPixelChannels(
const Image *magick_restrict image)
136 return(image->number_channels);
139 static inline Quantum GetPixelCompositeMask(
140 const Image *magick_restrict image,
const Quantum *magick_restrict pixel)
142 if (image->channel_map[CompositeMaskPixelChannel].traits == UndefinedPixelTrait)
143 return((Quantum) QuantumRange);
144 return(pixel[image->channel_map[CompositeMaskPixelChannel].offset]);
147 static inline Quantum GetPixelCr(
const Image *magick_restrict image,
148 const Quantum *magick_restrict pixel)
150 return(pixel[image->channel_map[CrPixelChannel].offset]);
153 static inline PixelTrait GetPixelCrTraits(
const Image *magick_restrict image)
155 return(image->channel_map[CrPixelChannel].traits);
158 static inline Quantum GetPixelCyan(
const Image *magick_restrict image,
159 const Quantum *magick_restrict pixel)
161 return(pixel[image->channel_map[CyanPixelChannel].offset]);
164 static inline PixelTrait GetPixelCyanTraits(
const Image *magick_restrict image)
166 return(image->channel_map[CyanPixelChannel].traits);
169 static inline Quantum GetPixelGray(
const Image *magick_restrict image,
170 const Quantum *magick_restrict pixel)
172 return(pixel[image->channel_map[GrayPixelChannel].offset]);
175 static inline PixelTrait GetPixelGrayTraits(
const Image *magick_restrict image)
177 return(image->channel_map[GrayPixelChannel].traits);
180 static inline Quantum GetPixelGreen(
const Image *magick_restrict image,
181 const Quantum *magick_restrict pixel)
183 return(pixel[image->channel_map[GreenPixelChannel].offset]);
186 static inline PixelTrait GetPixelGreenTraits(
const Image *magick_restrict image)
188 return(image->channel_map[GreenPixelChannel].traits);
191 static inline Quantum GetPixelIndex(
const Image *magick_restrict image,
192 const Quantum *magick_restrict pixel)
194 if (image->channel_map[IndexPixelChannel].traits == UndefinedPixelTrait)
196 return(pixel[image->channel_map[IndexPixelChannel].offset]);
199 static inline PixelTrait GetPixelIndexTraits(
const Image *magick_restrict image)
201 return(image->channel_map[IndexPixelChannel].traits);
204 static inline MagickRealType GetPixelInfoChannel(
205 const PixelInfo *magick_restrict pixel_info,
const PixelChannel channel)
209 case RedPixelChannel:
return(pixel_info->red);
210 case GreenPixelChannel:
return(pixel_info->green);
211 case BluePixelChannel:
return(pixel_info->blue);
212 case BlackPixelChannel:
214 if (pixel_info->colorspace != CMYKColorspace)
216 return(pixel_info->black);
218 case AlphaPixelChannel:
220 if (pixel_info->alpha_trait == UndefinedPixelTrait)
222 return(pixel_info->alpha);
224 case IndexPixelChannel:
return(pixel_info->index);
225 default:
return((MagickRealType) 0.0);
229 static inline double PerceptibleReciprocal(
const double x)
237 sign=x < 0.0 ? -1.0 : 1.0;
238 if ((sign*x) >= MagickEpsilon)
240 return(sign/MagickEpsilon);
243 static inline MagickRealType GetPixelInfoLuma(
249 if (pixel->colorspace == sRGBColorspace)
251 intensity=(MagickRealType) (0.212656f*pixel->red+0.715158f*pixel->green+
252 0.072186f*pixel->blue);
255 intensity=(MagickRealType) (0.212656f*EncodePixelGamma(pixel->red)+
256 0.715158f*EncodePixelGamma(pixel->green)+
257 0.072186f*EncodePixelGamma(pixel->blue));
261 static inline MagickRealType GetPixelInfoLuminance(
267 if (pixel->colorspace != sRGBColorspace)
269 intensity=(MagickRealType) (0.212656f*pixel->red+0.715158f*pixel->green+
270 0.072186f*pixel->blue);
273 intensity=(MagickRealType) (0.212656f*DecodePixelGamma(pixel->red)+
274 0.715158f*DecodePixelGamma(pixel->green)+
275 0.072186f*DecodePixelGamma(pixel->blue));
279 static inline Quantum GetPixelL(
const Image *magick_restrict image,
280 const Quantum *magick_restrict pixel)
282 return(pixel[image->channel_map[LPixelChannel].offset]);
285 static inline ssize_t GetPixelLabel(
const Image *magick_restrict image,
286 const Quantum *magick_restrict pixel)
288 return((ssize_t) pixel[image->channel_map[LabelPixelChannel].offset]);
291 static inline MagickRealType GetPixelLuma(
292 const Image *magick_restrict image,
const Quantum *magick_restrict pixel)
298 0.212656f*(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]+
299 0.715158f*(MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset]+
300 0.072186f*(MagickRealType) pixel[image->channel_map[BluePixelChannel].offset];
304 static inline MagickRealType GetPixelLuminance(
305 const Image *magick_restrict image,
const Quantum *magick_restrict pixel)
310 if (image->colorspace != sRGBColorspace)
313 0.212656f*(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]+
314 0.715158f*(MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset]+
315 0.072186f*(MagickRealType) pixel[image->channel_map[BluePixelChannel].offset];
318 intensity=(MagickRealType) (0.212656f*DecodePixelGamma((MagickRealType)
319 pixel[image->channel_map[RedPixelChannel].offset])+0.715158f*
320 DecodePixelGamma((MagickRealType)
321 pixel[image->channel_map[GreenPixelChannel].offset])+0.072186f*
322 DecodePixelGamma((MagickRealType)
323 pixel[image->channel_map[BluePixelChannel].offset]));
327 static inline Quantum GetPixelMagenta(
const Image *magick_restrict image,
328 const Quantum *magick_restrict pixel)
330 return(pixel[image->channel_map[MagentaPixelChannel].offset]);
333 static inline PixelTrait GetPixelMagentaTraits(
334 const Image *magick_restrict image)
336 return(image->channel_map[MagentaPixelChannel].traits);
339 static inline Quantum GetPixelMeta(
const Image *magick_restrict image,
340 const Quantum *magick_restrict pixel)
342 if (image->channel_map[MetaPixelChannel].traits == UndefinedPixelTrait)
344 return(pixel[image->channel_map[MetaPixelChannel].offset]);
347 static inline PixelTrait GetPixelMetaTraits(
const Image *magick_restrict image)
349 return(image->channel_map[MetaPixelChannel].traits);
352 static inline Quantum GetPixelReadMask(
const Image *magick_restrict image,
353 const Quantum *magick_restrict pixel)
355 if (image->channel_map[ReadMaskPixelChannel].traits == UndefinedPixelTrait)
356 return((Quantum) QuantumRange);
357 return(pixel[image->channel_map[ReadMaskPixelChannel].offset]);
360 static inline Quantum GetPixelWriteMask(
361 const Image *magick_restrict image,
const Quantum *magick_restrict pixel)
363 if (image->channel_map[WriteMaskPixelChannel].traits == UndefinedPixelTrait)
364 return((Quantum) QuantumRange);
365 return(pixel[image->channel_map[WriteMaskPixelChannel].offset]);
368 static inline PixelTrait GetPixelReadMaskTraits(
369 const Image *magick_restrict image)
371 return(image->channel_map[ReadMaskPixelChannel].traits);
374 static inline size_t GetPixelMetaChannels(
const Image *magick_restrict image)
376 return(image->number_meta_channels);
379 static inline size_t GetPixelMetacontentExtent(
380 const Image *magick_restrict image)
382 return(image->metacontent_extent);
385 static inline Quantum GetPixelOpacity(
const Image *magick_restrict image,
386 const Quantum *magick_restrict pixel)
388 if (image->channel_map[AlphaPixelChannel].traits != BlendPixelTrait)
389 return(QuantumRange-OpaqueAlpha);
390 return(QuantumRange-pixel[image->channel_map[AlphaPixelChannel].offset]);
393 static inline Quantum GetPixelRed(
const Image *magick_restrict image,
394 const Quantum *magick_restrict pixel)
396 return(pixel[image->channel_map[RedPixelChannel].offset]);
399 static inline PixelTrait GetPixelRedTraits(
const Image *magick_restrict image)
401 return(image->channel_map[RedPixelChannel].traits);
404 static inline void GetPixelInfoPixel(
const Image *magick_restrict image,
405 const Quantum *magick_restrict pixel,
PixelInfo *magick_restrict pixel_info)
407 (void) ResetMagickMemory(pixel_info,0,
sizeof(*pixel_info));
408 pixel_info->storage_class=DirectClass;
409 pixel_info->colorspace=sRGBColorspace;
410 pixel_info->depth=MAGICKCORE_QUANTUM_DEPTH;
411 pixel_info->alpha_trait=UndefinedPixelTrait;
412 pixel_info->alpha=(MagickRealType) OpaqueAlpha;
413 if (image != (
Image *) NULL)
415 pixel_info->storage_class=image->storage_class;
416 pixel_info->colorspace=image->colorspace;
417 pixel_info->fuzz=image->fuzz;
418 pixel_info->depth=image->depth;
419 pixel_info->alpha_trait=image->alpha_trait;
420 if (pixel != (Quantum *) NULL)
422 pixel_info->red=(MagickRealType)
423 pixel[image->channel_map[RedPixelChannel].offset];
424 pixel_info->green=(MagickRealType)
425 pixel[image->channel_map[GreenPixelChannel].offset];
426 pixel_info->blue=(MagickRealType)
427 pixel[image->channel_map[BluePixelChannel].offset];
428 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
429 pixel_info->black=(MagickRealType)
430 pixel[image->channel_map[BlackPixelChannel].offset];
431 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
432 pixel_info->alpha=(MagickRealType)
433 pixel[image->channel_map[AlphaPixelChannel].offset];
434 if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
435 pixel_info->index=(MagickRealType)
436 pixel[image->channel_map[IndexPixelChannel].offset];
441 static inline PixelTrait GetPixelTraits(
const Image *magick_restrict image,
442 const PixelChannel channel)
444 return(image->channel_map[channel].traits);
447 static inline Quantum GetPixelY(
const Image *magick_restrict image,
448 const Quantum *magick_restrict pixel)
450 return(pixel[image->channel_map[YPixelChannel].offset]);
453 static inline PixelTrait GetPixelYTraits(
const Image *magick_restrict image)
455 return(image->channel_map[YPixelChannel].traits);
458 static inline Quantum GetPixelYellow(
const Image *magick_restrict image,
459 const Quantum *magick_restrict pixel)
461 return(pixel[image->channel_map[YellowPixelChannel].offset]);
464 static inline PixelTrait GetPixelYellowTraits(
465 const Image *magick_restrict image)
467 return(image->channel_map[YellowPixelChannel].traits);
470 static inline MagickRealType AbsolutePixelValue(
const MagickRealType x)
472 return(x < 0.0f ? -x : x);
475 static inline MagickBooleanType IsPixelAtDepth(
const Quantum pixel,
476 const QuantumAny range)
483 #if !defined(MAGICKCORE_HDRI_SUPPORT)
484 quantum=(Quantum) (((MagickRealType) QuantumRange*((QuantumAny)
485 (((MagickRealType) range*pixel)/QuantumRange+0.5)))/range+0.5);
487 quantum=(Quantum) (((MagickRealType) QuantumRange*((QuantumAny)
488 (((MagickRealType) range*pixel)/QuantumRange+0.5)))/(MagickRealType) range);
490 return(pixel == quantum ? MagickTrue : MagickFalse);
493 static inline MagickBooleanType IsPixelEquivalent(
494 const Image *magick_restrict image,
const Quantum *magick_restrict p,
502 color=(MagickRealType) p[image->channel_map[AlphaPixelChannel].offset];
503 alpha=image->alpha_trait == UndefinedPixelTrait ? (MagickRealType)
505 beta=q->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
507 if (AbsolutePixelValue(alpha-beta) >= MagickEpsilon)
509 if ((AbsolutePixelValue(alpha-TransparentAlpha) < MagickEpsilon) ||
510 (AbsolutePixelValue(beta-TransparentAlpha) < MagickEpsilon))
512 color=(MagickRealType) p[image->channel_map[RedPixelChannel].offset];
513 if (AbsolutePixelValue(color-q->red) >= MagickEpsilon)
515 color=(MagickRealType) p[image->channel_map[GreenPixelChannel].offset];
516 if (AbsolutePixelValue(color-q->green) >= MagickEpsilon)
518 color=(MagickRealType) p[image->channel_map[BluePixelChannel].offset];
519 if (AbsolutePixelValue(color-q->blue) >= MagickEpsilon)
521 if (image->colorspace == CMYKColorspace)
523 color=(MagickRealType) p[image->channel_map[BlackPixelChannel].offset];
524 if (AbsolutePixelValue(color-q->black) >= MagickEpsilon)
530 static inline MagickBooleanType IsPixelGray(
const Image *magick_restrict image,
531 const Quantum *magick_restrict pixel)
537 red_green=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]-
538 pixel[image->channel_map[GreenPixelChannel].offset];
539 green_blue=(MagickRealType)
540 pixel[image->channel_map[GreenPixelChannel].offset]-
541 pixel[image->channel_map[BluePixelChannel].offset];
542 if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
543 (AbsolutePixelValue(green_blue) < MagickEpsilon))
548 static inline MagickBooleanType IsPixelInfoEquivalent(
555 alpha=p->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
557 beta=q->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
559 if (AbsolutePixelValue(alpha-beta) >= MagickEpsilon)
561 if ((AbsolutePixelValue(alpha-TransparentAlpha) < MagickEpsilon) ||
562 (AbsolutePixelValue(beta-TransparentAlpha) < MagickEpsilon))
564 if (AbsolutePixelValue(p->red-q->red) >= MagickEpsilon)
566 if (AbsolutePixelValue(p->green-q->green) >= MagickEpsilon)
568 if (AbsolutePixelValue(p->blue-q->blue) >= MagickEpsilon)
570 if (p->colorspace == CMYKColorspace)
572 if (AbsolutePixelValue(p->black-q->black) >= MagickEpsilon)
578 static inline MagickBooleanType IsPixelMonochrome(
579 const Image *magick_restrict image,
const Quantum *magick_restrict pixel)
586 red=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset];
587 if ((AbsolutePixelValue(red) >= MagickEpsilon) &&
588 (AbsolutePixelValue(red-QuantumRange) >= MagickEpsilon))
590 red_green=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]-
591 pixel[image->channel_map[GreenPixelChannel].offset];
592 green_blue=(MagickRealType)
593 pixel[image->channel_map[GreenPixelChannel].offset]-
594 pixel[image->channel_map[BluePixelChannel].offset];
595 if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
596 (AbsolutePixelValue(green_blue) < MagickEpsilon))
601 static inline MagickBooleanType IsPixelInfoGray(
604 if ((AbsolutePixelValue(pixel->red-pixel->green) < MagickEpsilon) &&
605 (AbsolutePixelValue(pixel->green-pixel->blue) < MagickEpsilon))
610 static inline MagickBooleanType IsPixelInfoMonochrome(
611 const PixelInfo *magick_restrict pixel_info)
617 if ((AbsolutePixelValue(pixel_info->red) >= MagickEpsilon) ||
618 (AbsolutePixelValue(pixel_info->red-QuantumRange) >= MagickEpsilon))
620 red_green=pixel_info->red-pixel_info->green;
621 green_blue=pixel_info->green-pixel_info->blue;
622 if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
623 (AbsolutePixelValue(green_blue) < MagickEpsilon))
628 static inline void SetPixela(
const Image *magick_restrict image,
629 const Quantum a,Quantum *magick_restrict pixel)
631 if (image->channel_map[aPixelChannel].traits != UndefinedPixelTrait)
632 pixel[image->channel_map[aPixelChannel].offset]=a;
635 static inline void SetPixelAlpha(
const Image *magick_restrict image,
636 const Quantum alpha,Quantum *magick_restrict pixel)
638 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
639 pixel[image->channel_map[AlphaPixelChannel].offset]=alpha;
642 static inline void SetPixelAlphaTraits(
Image *image,
const PixelTrait traits)
644 image->channel_map[AlphaPixelChannel].traits=traits;
647 static inline void SetPixelb(
const Image *magick_restrict image,
648 const Quantum b,Quantum *magick_restrict pixel)
650 if (image->channel_map[bPixelChannel].traits != UndefinedPixelTrait)
651 pixel[image->channel_map[bPixelChannel].offset]=b;
654 static inline void SetPixelBackgoundColor(
const Image *magick_restrict image,
655 Quantum *magick_restrict pixel)
660 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
661 pixel[i]=(Quantum) 0;
662 pixel[image->channel_map[RedPixelChannel].offset]=
663 ClampToQuantum(image->background_color.red);
664 pixel[image->channel_map[GreenPixelChannel].offset]=
665 ClampToQuantum(image->background_color.green);
666 pixel[image->channel_map[BluePixelChannel].offset]=
667 ClampToQuantum(image->background_color.blue);
668 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
669 pixel[image->channel_map[BlackPixelChannel].offset]=
670 ClampToQuantum(image->background_color.black);
671 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
672 pixel[image->channel_map[AlphaPixelChannel].offset]=
673 image->background_color.alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
674 ClampToQuantum(image->background_color.alpha);
677 static inline void SetPixelBlack(
const Image *magick_restrict image,
678 const Quantum black,Quantum *magick_restrict pixel)
680 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
681 pixel[image->channel_map[BlackPixelChannel].offset]=black;
684 static inline void SetPixelBlackTraits(
Image *image,
const PixelTrait traits)
686 image->channel_map[BlackPixelChannel].traits=traits;
689 static inline void SetPixelBlue(
const Image *magick_restrict image,
690 const Quantum blue,Quantum *magick_restrict pixel)
692 pixel[image->channel_map[BluePixelChannel].offset]=blue;
695 static inline void SetPixelBlueTraits(
Image *image,
const PixelTrait traits)
697 image->channel_map[BluePixelChannel].traits=traits;
700 static inline void SetPixelCb(
const Image *magick_restrict image,
701 const Quantum cb,Quantum *magick_restrict pixel)
703 pixel[image->channel_map[CbPixelChannel].offset]=cb;
706 static inline void SetPixelCbTraits(
Image *image,
const PixelTrait traits)
708 image->channel_map[CbPixelChannel].traits=traits;
711 static inline void SetPixelChannel(
const Image *magick_restrict image,
712 const PixelChannel channel,
const Quantum quantum,
713 Quantum *magick_restrict pixel)
715 if (image->channel_map[channel].traits != UndefinedPixelTrait)
716 pixel[image->channel_map[channel].offset]=quantum;
719 static inline void SetPixelChannelAttributes(
720 const Image *magick_restrict image,
const PixelChannel channel,
721 const PixelTrait traits,
const ssize_t offset)
723 if ((ssize_t) channel >= MaxPixelChannels)
725 if (offset >= MaxPixelChannels)
727 image->channel_map[offset].channel=channel;
728 image->channel_map[channel].offset=offset;
729 image->channel_map[channel].traits=traits;
732 static inline void SetPixelChannelChannel(
const Image *magick_restrict image,
733 const PixelChannel channel,
const ssize_t offset)
735 image->channel_map[offset].channel=channel;
736 image->channel_map[channel].offset=offset;
739 static inline void SetPixelChannels(
Image *image,
const size_t number_channels)
741 image->number_channels=number_channels;
744 static inline void SetPixelChannelTraits(
Image *image,
745 const PixelChannel channel,
const PixelTrait traits)
747 image->channel_map[channel].traits=traits;
750 static inline void SetPixelCompositeMask(
const Image *magick_restrict image,
751 const Quantum mask,Quantum *magick_restrict pixel)
753 if (image->channel_map[CompositeMaskPixelChannel].traits != UndefinedPixelTrait)
754 pixel[image->channel_map[CompositeMaskPixelChannel].offset]=mask;
757 static inline void SetPixelCr(
const Image *magick_restrict image,
758 const Quantum cr,Quantum *magick_restrict pixel)
760 pixel[image->channel_map[CrPixelChannel].offset]=cr;
763 static inline void SetPixelCrTraits(
Image *image,
const PixelTrait traits)
765 image->channel_map[CrPixelChannel].traits=traits;
768 static inline void SetPixelCyan(
const Image *magick_restrict image,
769 const Quantum cyan,Quantum *magick_restrict pixel)
771 pixel[image->channel_map[CyanPixelChannel].offset]=cyan;
774 static inline void SetPixelGray(
const Image *magick_restrict image,
775 const Quantum gray,Quantum *magick_restrict pixel)
777 pixel[image->channel_map[GrayPixelChannel].offset]=gray;
780 static inline void SetPixelGrayTraits(
Image *image,
const PixelTrait traits)
782 image->channel_map[GrayPixelChannel].traits=traits;
785 static inline void SetPixelGreen(
const Image *magick_restrict image,
786 const Quantum green,Quantum *magick_restrict pixel)
788 pixel[image->channel_map[GreenPixelChannel].offset]=green;
791 static inline void SetPixelGreenTraits(
Image *image,
const PixelTrait traits)
793 image->channel_map[GreenPixelChannel].traits=traits;
796 static inline void SetPixelIndex(
const Image *magick_restrict image,
797 const Quantum index,Quantum *magick_restrict pixel)
799 if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
800 pixel[image->channel_map[IndexPixelChannel].offset]=index;
803 static inline void SetPixelIndexTraits(
Image *image,
const PixelTrait traits)
805 image->channel_map[IndexPixelChannel].traits=traits;
808 static inline void SetPixelViaPixelInfo(
const Image *magick_restrict image,
809 const PixelInfo *magick_restrict pixel_info,Quantum *magick_restrict pixel)
811 pixel[image->channel_map[RedPixelChannel].offset]=
812 ClampToQuantum(pixel_info->red);
813 pixel[image->channel_map[GreenPixelChannel].offset]=
814 ClampToQuantum(pixel_info->green);
815 pixel[image->channel_map[BluePixelChannel].offset]=
816 ClampToQuantum(pixel_info->blue);
817 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
818 pixel[image->channel_map[BlackPixelChannel].offset]=
819 ClampToQuantum(pixel_info->black);
820 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
821 pixel[image->channel_map[AlphaPixelChannel].offset]=
822 pixel_info->alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
823 ClampToQuantum(pixel_info->alpha);
826 static inline void SetPixelL(
const Image *magick_restrict image,
const Quantum L,
827 Quantum *magick_restrict pixel)
829 if (image->channel_map[LPixelChannel].traits != UndefinedPixelTrait)
830 pixel[image->channel_map[LPixelChannel].offset]=L;
833 static inline void SetPixelMagenta(
const Image *magick_restrict image,
834 const Quantum magenta,Quantum *magick_restrict pixel)
836 pixel[image->channel_map[MagentaPixelChannel].offset]=magenta;
839 static inline void SetPixelMagentaTraits(
Image *image,
const PixelTrait traits)
841 image->channel_map[MagentaPixelChannel].traits=traits;
844 static inline void SetPixelMeta(
const Image *magick_restrict image,
845 const Quantum red,Quantum *magick_restrict pixel)
847 pixel[image->channel_map[MetaPixelChannel].offset]=red;
850 static inline void SetPixelMetaTraits(
Image *image,
const PixelTrait traits)
852 image->channel_map[MetaPixelChannel].traits=traits;
855 static inline void SetPixelReadMask(
const Image *magick_restrict image,
856 const Quantum mask,Quantum *magick_restrict pixel)
858 if (image->channel_map[ReadMaskPixelChannel].traits != UndefinedPixelTrait)
859 pixel[image->channel_map[ReadMaskPixelChannel].offset]=mask;
862 static inline void SetPixelWriteMask(
const Image *magick_restrict image,
863 const Quantum mask,Quantum *magick_restrict pixel)
865 if (image->channel_map[WriteMaskPixelChannel].traits != UndefinedPixelTrait)
866 pixel[image->channel_map[WriteMaskPixelChannel].offset]=mask;
869 static inline void SetPixelMetacontentExtent(
Image *image,
const size_t extent)
871 image->metacontent_extent=extent;
874 static inline void SetPixelOpacity(
const Image *magick_restrict image,
875 const Quantum alpha,Quantum *magick_restrict pixel)
877 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
878 pixel[image->channel_map[AlphaPixelChannel].offset]=QuantumRange-alpha;
881 static inline void SetPixelRed(
const Image *magick_restrict image,
882 const Quantum red,Quantum *magick_restrict pixel)
884 pixel[image->channel_map[RedPixelChannel].offset]=red;
887 static inline void SetPixelRedTraits(
Image *image,
const PixelTrait traits)
889 image->channel_map[RedPixelChannel].traits=traits;
892 static inline void SetPixelYellow(
const Image *magick_restrict image,
893 const Quantum yellow,Quantum *magick_restrict pixel)
895 pixel[image->channel_map[YellowPixelChannel].offset]=yellow;
898 static inline void SetPixelYellowTraits(
Image *image,
const PixelTrait traits)
900 image->channel_map[YellowPixelChannel].traits=traits;
903 static inline void SetPixelY(
const Image *magick_restrict image,
904 const Quantum y,Quantum *magick_restrict pixel)
906 pixel[image->channel_map[YPixelChannel].offset]=y;
909 static inline void SetPixelYTraits(
Image *image,
const PixelTrait traits)
911 image->channel_map[YPixelChannel].traits=traits;
914 #if defined(__cplusplus) || defined(c_plusplus)