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)
35static 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);
48static inline Quantum GetPixela(
const Image *magick_restrict image,
49 const Quantum *magick_restrict pixel)
51 return(pixel[image->channel_map[aPixelChannel].offset]);
54static 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]);
62static inline PixelTrait GetPixelAlphaTraits(
const Image *magick_restrict image)
64 return(image->channel_map[AlphaPixelChannel].traits);
67static inline Quantum GetPixelb(
const Image *magick_restrict image,
68 const Quantum *magick_restrict pixel)
70 return(pixel[image->channel_map[bPixelChannel].offset]);
73static 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]);
81static inline PixelTrait GetPixelBlackTraits(
const Image *magick_restrict image)
83 return(image->channel_map[BlackPixelChannel].traits);
86static inline Quantum GetPixelBlue(
const Image *magick_restrict image,
87 const Quantum *magick_restrict pixel)
89 return(pixel[image->channel_map[BluePixelChannel].offset]);
92static inline PixelTrait GetPixelBlueTraits(
const Image *magick_restrict image)
94 return(image->channel_map[BluePixelChannel].traits);
97static inline Quantum GetPixelCb(
const Image *magick_restrict image,
98 const Quantum *magick_restrict pixel)
100 return(pixel[image->channel_map[CbPixelChannel].offset]);
103static inline PixelTrait GetPixelCbTraits(
const Image *magick_restrict image)
105 return(image->channel_map[CbPixelChannel].traits);
108static inline Quantum GetPixelChannel(
const Image *magick_restrict image,
109 const PixelChannel channel,
const Quantum *magick_restrict pixel)
111 if ((
size_t) channel >= MaxPixelChannels)
113 if (image->channel_map[channel].traits == UndefinedPixelTrait)
115 return(pixel[image->channel_map[channel].offset]);
118static inline PixelChannel GetPixelChannelChannel(
119 const Image *magick_restrict image,
const ssize_t offset)
121 if ((offset < 0) || (offset >= MaxPixelChannels))
122 return(UndefinedPixelChannel);
123 return(image->channel_map[offset].channel);
126static inline ssize_t GetPixelChannelOffset(
const Image *magick_restrict image,
127 const PixelChannel channel)
129 return(image->channel_map[channel].offset);
132static inline PixelTrait GetPixelChannelTraits(
133 const Image *magick_restrict image,
const PixelChannel channel)
135 if ((
size_t) channel >= MaxPixelChannels)
136 return(UndefinedPixelTrait);
137 return(image->channel_map[channel].traits);
140static inline size_t GetPixelChannels(
const Image *magick_restrict image)
142 return(image->number_channels);
145static inline Quantum GetPixelCompositeMask(
146 const Image *magick_restrict image,
const Quantum *magick_restrict pixel)
148 if (image->channel_map[CompositeMaskPixelChannel].traits == UndefinedPixelTrait)
149 return((Quantum) QuantumRange);
150 return(pixel[image->channel_map[CompositeMaskPixelChannel].offset]);
153static inline PixelTrait GetPixelCompositeMaskTraits(
154 const Image *magick_restrict image)
156 return(image->channel_map[CompositeMaskPixelChannel].traits);
159static inline Quantum GetPixelCr(
const Image *magick_restrict image,
160 const Quantum *magick_restrict pixel)
162 return(pixel[image->channel_map[CrPixelChannel].offset]);
165static inline PixelTrait GetPixelCrTraits(
const Image *magick_restrict image)
167 return(image->channel_map[CrPixelChannel].traits);
170static inline Quantum GetPixelCyan(
const Image *magick_restrict image,
171 const Quantum *magick_restrict pixel)
173 return(pixel[image->channel_map[CyanPixelChannel].offset]);
176static inline PixelTrait GetPixelCyanTraits(
const Image *magick_restrict image)
178 return(image->channel_map[CyanPixelChannel].traits);
181static inline Quantum GetPixelGray(
const Image *magick_restrict image,
182 const Quantum *magick_restrict pixel)
184 return(pixel[image->channel_map[GrayPixelChannel].offset]);
187static inline PixelTrait GetPixelGrayTraits(
const Image *magick_restrict image)
189 return(image->channel_map[GrayPixelChannel].traits);
192static inline Quantum GetPixelGreen(
const Image *magick_restrict image,
193 const Quantum *magick_restrict pixel)
195 return(pixel[image->channel_map[GreenPixelChannel].offset]);
198static inline PixelTrait GetPixelGreenTraits(
const Image *magick_restrict image)
200 return(image->channel_map[GreenPixelChannel].traits);
203static inline Quantum GetPixelIndex(
const Image *magick_restrict image,
204 const Quantum *magick_restrict pixel)
206 if (image->channel_map[IndexPixelChannel].traits == UndefinedPixelTrait)
208 return(pixel[image->channel_map[IndexPixelChannel].offset]);
211static inline PixelTrait GetPixelIndexTraits(
const Image *magick_restrict image)
213 return(image->channel_map[IndexPixelChannel].traits);
216static inline MagickRealType GetPixelInfoChannel(
217 const PixelInfo *magick_restrict pixel_info,
const PixelChannel channel)
221 case RedPixelChannel:
return(pixel_info->red);
222 case GreenPixelChannel:
return(pixel_info->green);
223 case BluePixelChannel:
return(pixel_info->blue);
224 case BlackPixelChannel:
226 if (pixel_info->colorspace != CMYKColorspace)
228 return(pixel_info->black);
230 case AlphaPixelChannel:
232 if (pixel_info->alpha_trait == UndefinedPixelTrait)
234 return(pixel_info->alpha);
236 case IndexPixelChannel:
return(pixel_info->index);
239 return((MagickRealType) 0.0);
242static inline double PerceptibleReciprocal(
const double x)
250 sign=x < 0.0 ? -1.0 : 1.0;
251 if ((sign*x) >= MagickEpsilon)
253 return(sign/MagickEpsilon);
256static inline MagickRealType GetPixelInfoLuma(
262 if (pixel->colorspace == sRGBColorspace)
264 intensity=(MagickRealType) (0.212656*pixel->red+0.715158*pixel->green+
265 0.072186*pixel->blue);
268 intensity=(MagickRealType) (0.212656*EncodePixelGamma(pixel->red)+
269 0.715158*EncodePixelGamma(pixel->green)+
270 0.072186*EncodePixelGamma(pixel->blue));
274static inline MagickRealType GetPixelInfoLuminance(
280 if (pixel->colorspace != sRGBColorspace)
282 intensity=(MagickRealType) (0.212656*pixel->red+0.715158*pixel->green+
283 0.072186*pixel->blue);
286 intensity=(MagickRealType) (0.212656*DecodePixelGamma(pixel->red)+
287 0.715158*DecodePixelGamma(pixel->green)+
288 0.072186*DecodePixelGamma(pixel->blue));
292static inline Quantum GetPixelL(
const Image *magick_restrict image,
293 const Quantum *magick_restrict pixel)
295 return(pixel[image->channel_map[LPixelChannel].offset]);
298static inline ssize_t GetPixelLabel(
const Image *magick_restrict image,
299 const Quantum *magick_restrict pixel)
301 return((ssize_t) pixel[image->channel_map[LabelPixelChannel].offset]);
304static inline MagickRealType GetPixelLuma(
305 const Image *magick_restrict image,
const Quantum *magick_restrict pixel)
311 0.212656*(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]+
312 0.715158*(MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset]+
313 0.072186*(MagickRealType) pixel[image->channel_map[BluePixelChannel].offset];
317static inline MagickRealType GetPixelLuminance(
318 const Image *magick_restrict image,
const Quantum *magick_restrict pixel)
323 if (image->colorspace != sRGBColorspace)
326 0.212656*(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]+
327 0.715158*(MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset]+
328 0.072186*(MagickRealType) pixel[image->channel_map[BluePixelChannel].offset];
331 intensity=(MagickRealType) (0.212656*DecodePixelGamma((MagickRealType)
332 pixel[image->channel_map[RedPixelChannel].offset])+0.715158*
333 DecodePixelGamma((MagickRealType)
334 pixel[image->channel_map[GreenPixelChannel].offset])+0.072186*
335 DecodePixelGamma((MagickRealType)
336 pixel[image->channel_map[BluePixelChannel].offset]));
340static inline Quantum GetPixelMagenta(
const Image *magick_restrict image,
341 const Quantum *magick_restrict pixel)
343 return(pixel[image->channel_map[MagentaPixelChannel].offset]);
346static inline PixelTrait GetPixelMagentaTraits(
347 const Image *magick_restrict image)
349 return(image->channel_map[MagentaPixelChannel].traits);
352static inline Quantum GetPixelMeta(
const Image *magick_restrict image,
353 const Quantum *magick_restrict pixel)
355 if (image->channel_map[MetaPixelChannels].traits == UndefinedPixelTrait)
357 return(pixel[image->channel_map[MetaPixelChannels].offset]);
360static inline PixelTrait GetPixelMetaTraits(
const Image *magick_restrict image)
362 return(image->channel_map[MetaPixelChannels].traits);
365static inline Quantum GetPixelReadMask(
const Image *magick_restrict image,
366 const Quantum *magick_restrict pixel)
368 if (image->channel_map[ReadMaskPixelChannel].traits == UndefinedPixelTrait)
369 return((Quantum) QuantumRange);
370 return(pixel[image->channel_map[ReadMaskPixelChannel].offset]);
373static inline void GetPixelInfoRGBA(
const Quantum red,
const Quantum green,
374 const Quantum blue,
const Quantum alpha,
PixelInfo *magick_restrict pixel)
376 GetPixelInfo((
Image *) NULL,pixel);
383static inline Quantum GetPixelWriteMask(
384 const Image *magick_restrict image,
const Quantum *magick_restrict pixel)
386 if (image->channel_map[WriteMaskPixelChannel].traits == UndefinedPixelTrait)
387 return((Quantum) QuantumRange);
388 return(pixel[image->channel_map[WriteMaskPixelChannel].offset]);
391static inline PixelTrait GetPixelReadMaskTraits(
392 const Image *magick_restrict image)
394 return(image->channel_map[ReadMaskPixelChannel].traits);
397static inline size_t GetPixelMetaChannels(
const Image *magick_restrict image)
399 return(image->number_meta_channels);
402static inline size_t GetPixelMetacontentExtent(
403 const Image *magick_restrict image)
405 return(image->metacontent_extent);
408static inline Quantum GetPixelOpacity(
const Image *magick_restrict image,
409 const Quantum *magick_restrict pixel)
411 if (image->channel_map[AlphaPixelChannel].traits != BlendPixelTrait)
412 return(QuantumRange-OpaqueAlpha);
413 return(QuantumRange-pixel[image->channel_map[AlphaPixelChannel].offset]);
416static inline Quantum GetPixelRed(
const Image *magick_restrict image,
417 const Quantum *magick_restrict pixel)
419 return(pixel[image->channel_map[RedPixelChannel].offset]);
422static inline PixelTrait GetPixelRedTraits(
const Image *magick_restrict image)
424 return(image->channel_map[RedPixelChannel].traits);
427static inline void GetPixelInfoPixel(
const Image *magick_restrict image,
428 const Quantum *magick_restrict pixel,
PixelInfo *magick_restrict pixel_info)
430 (void) ResetMagickMemory(pixel_info,0,
sizeof(*pixel_info));
431 pixel_info->storage_class=DirectClass;
432 pixel_info->colorspace=sRGBColorspace;
433 pixel_info->depth=MAGICKCORE_QUANTUM_DEPTH;
434 pixel_info->alpha_trait=UndefinedPixelTrait;
435 pixel_info->alpha=(MagickRealType) OpaqueAlpha;
436 if (image != (
Image *) NULL)
438 pixel_info->storage_class=image->storage_class;
439 pixel_info->colorspace=image->colorspace;
440 pixel_info->fuzz=image->fuzz;
441 pixel_info->depth=image->depth;
442 pixel_info->alpha_trait=image->alpha_trait;
443 if (pixel != (Quantum *) NULL)
445 pixel_info->red=(MagickRealType)
446 pixel[image->channel_map[RedPixelChannel].offset];
447 pixel_info->green=(MagickRealType)
448 pixel[image->channel_map[GreenPixelChannel].offset];
449 pixel_info->blue=(MagickRealType)
450 pixel[image->channel_map[BluePixelChannel].offset];
451 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
452 pixel_info->black=(MagickRealType)
453 pixel[image->channel_map[BlackPixelChannel].offset];
454 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
455 pixel_info->alpha=(MagickRealType)
456 pixel[image->channel_map[AlphaPixelChannel].offset];
457 if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
458 pixel_info->index=(MagickRealType)
459 pixel[image->channel_map[IndexPixelChannel].offset];
464static inline PixelTrait GetPixelTraits(
const Image *magick_restrict image,
465 const PixelChannel channel)
467 if ((
size_t) channel >= MaxPixelChannels)
468 return(UndefinedPixelTrait);
469 return(image->channel_map[channel].traits);
472static inline PixelTrait GetPixelWriteMaskTraits(
473 const Image *magick_restrict image)
475 return(image->channel_map[WriteMaskPixelChannel].traits);
478static inline Quantum GetPixelY(
const Image *magick_restrict image,
479 const Quantum *magick_restrict pixel)
481 return(pixel[image->channel_map[YPixelChannel].offset]);
484static inline PixelTrait GetPixelYTraits(
const Image *magick_restrict image)
486 return(image->channel_map[YPixelChannel].traits);
489static inline Quantum GetPixelYellow(
const Image *magick_restrict image,
490 const Quantum *magick_restrict pixel)
492 return(pixel[image->channel_map[YellowPixelChannel].offset]);
495static inline PixelTrait GetPixelYellowTraits(
496 const Image *magick_restrict image)
498 return(image->channel_map[YellowPixelChannel].traits);
501static inline MagickRealType AbsolutePixelValue(
const MagickRealType x)
503 return(x < 0.0 ? -x : x);
506static inline MagickBooleanType IsPixelAtDepth(
const Quantum pixel,
507 const QuantumAny range)
514#if !defined(MAGICKCORE_HDRI_SUPPORT)
515 quantum=(Quantum) (((
double) QuantumRange*((QuantumAny) (((
double) range*
516 pixel)/(
double) QuantumRange+0.5)))/(
double) range+0.5);
518 quantum=(Quantum) (((
double) QuantumRange*((QuantumAny) (((
double) range*
519 (
double) pixel)/(
double) QuantumRange+0.5)))/(
double) range);
521 return(pixel == quantum ? MagickTrue : MagickFalse);
524static inline MagickBooleanType IsPixelEquivalent(
525 const Image *magick_restrict image,
const Quantum *magick_restrict p,
533 color=(MagickRealType) p[image->channel_map[AlphaPixelChannel].offset];
534 alpha=image->alpha_trait == UndefinedPixelTrait ? (MagickRealType)
536 beta=q->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
538 if (AbsolutePixelValue(alpha-beta) >= MagickEpsilon)
540 if ((AbsolutePixelValue(alpha-(MagickRealType) TransparentAlpha) < MagickEpsilon) ||
541 (AbsolutePixelValue(beta-(MagickRealType) TransparentAlpha) < MagickEpsilon))
543 color=(MagickRealType) p[image->channel_map[RedPixelChannel].offset];
544 if (AbsolutePixelValue(color-q->red) >= MagickEpsilon)
546 color=(MagickRealType) p[image->channel_map[GreenPixelChannel].offset];
547 if (AbsolutePixelValue(color-q->green) >= MagickEpsilon)
549 color=(MagickRealType) p[image->channel_map[BluePixelChannel].offset];
550 if (AbsolutePixelValue(color-q->blue) >= MagickEpsilon)
552 if (image->colorspace == CMYKColorspace)
554 color=(MagickRealType) p[image->channel_map[BlackPixelChannel].offset];
555 if (AbsolutePixelValue(color-q->black) >= MagickEpsilon)
561static inline MagickBooleanType IsPixelGray(
const Image *magick_restrict image,
562 const Quantum *magick_restrict pixel)
569 (MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]-
570 (MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset];
572 (MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset]-
573 (MagickRealType) pixel[image->channel_map[BluePixelChannel].offset];
574 if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
575 (AbsolutePixelValue(green_blue) < MagickEpsilon))
580static inline MagickBooleanType IsPixelInfoEquivalent(
587 alpha=p->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
589 beta=q->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
591 if (AbsolutePixelValue(alpha-beta) >= MagickEpsilon)
593 if ((AbsolutePixelValue(alpha-(MagickRealType) TransparentAlpha) < MagickEpsilon) ||
594 (AbsolutePixelValue(beta-(MagickRealType) TransparentAlpha) < MagickEpsilon))
596 if (AbsolutePixelValue(p->red-q->red) >= MagickEpsilon)
598 if (AbsolutePixelValue(p->green-q->green) >= MagickEpsilon)
600 if (AbsolutePixelValue(p->blue-q->blue) >= MagickEpsilon)
602 if (p->colorspace == CMYKColorspace)
604 if (AbsolutePixelValue(p->black-q->black) >= MagickEpsilon)
610static inline MagickBooleanType IsPixelMonochrome(
611 const Image *magick_restrict image,
const Quantum *magick_restrict pixel)
618 red=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset];
619 if ((AbsolutePixelValue(red) >= MagickEpsilon) &&
620 (AbsolutePixelValue(red-(MagickRealType) QuantumRange) >= MagickEpsilon))
623 (MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]-
624 (MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset];
626 (MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset]-
627 (MagickRealType) pixel[image->channel_map[BluePixelChannel].offset];
628 if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
629 (AbsolutePixelValue(green_blue) < MagickEpsilon))
634static inline MagickBooleanType IsPixelInfoGray(
637 if ((AbsolutePixelValue(pixel->red-pixel->green) < MagickEpsilon) &&
638 (AbsolutePixelValue(pixel->green-pixel->blue) < MagickEpsilon))
643static inline MagickBooleanType IsPixelInfoMonochrome(
644 const PixelInfo *magick_restrict pixel_info)
650 if ((AbsolutePixelValue(pixel_info->red) >= MagickEpsilon) ||
651 (AbsolutePixelValue(pixel_info->red-(MagickRealType) QuantumRange) >= MagickEpsilon))
653 red_green=pixel_info->red-pixel_info->green;
654 green_blue=pixel_info->green-pixel_info->blue;
655 if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
656 (AbsolutePixelValue(green_blue) < MagickEpsilon))
661static inline void SetPixela(
const Image *magick_restrict image,
662 const Quantum a,Quantum *magick_restrict pixel)
664 if (image->channel_map[aPixelChannel].traits != UndefinedPixelTrait)
665 pixel[image->channel_map[aPixelChannel].offset]=a;
668static inline void SetPixelAlpha(
const Image *magick_restrict image,
669 const Quantum alpha,Quantum *magick_restrict pixel)
671 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
672 pixel[image->channel_map[AlphaPixelChannel].offset]=alpha;
675static inline void SetPixelAlphaTraits(
Image *image,
const PixelTrait traits)
677 image->channel_map[AlphaPixelChannel].traits=traits;
680static inline void SetPixelb(
const Image *magick_restrict image,
681 const Quantum b,Quantum *magick_restrict pixel)
683 if (image->channel_map[bPixelChannel].traits != UndefinedPixelTrait)
684 pixel[image->channel_map[bPixelChannel].offset]=b;
687static inline void SetPixelBackgroundColor(
const Image *magick_restrict image,
688 Quantum *magick_restrict pixel)
693 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
694 pixel[i]=(Quantum) 0;
695 pixel[image->channel_map[RedPixelChannel].offset]=
696 ClampToQuantum(image->background_color.red);
697 pixel[image->channel_map[GreenPixelChannel].offset]=
698 ClampToQuantum(image->background_color.green);
699 pixel[image->channel_map[BluePixelChannel].offset]=
700 ClampToQuantum(image->background_color.blue);
701 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
702 pixel[image->channel_map[BlackPixelChannel].offset]=
703 ClampToQuantum(image->background_color.black);
704 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
705 pixel[image->channel_map[AlphaPixelChannel].offset]=
706 image->background_color.alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
707 ClampToQuantum(image->background_color.alpha);
710static inline void SetPixelBackgoundColor(
const Image *magick_restrict image,
711 Quantum *magick_restrict pixel) magick_attribute((deprecated));
713static inline void SetPixelBackgoundColor(
const Image *magick_restrict image,
714 Quantum *magick_restrict pixel)
716 SetPixelBackgroundColor(image,pixel);
719static inline void SetPixelBlack(
const Image *magick_restrict image,
720 const Quantum black,Quantum *magick_restrict pixel)
722 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
723 pixel[image->channel_map[BlackPixelChannel].offset]=black;
726static inline void SetPixelBlackTraits(
Image *image,
const PixelTrait traits)
728 image->channel_map[BlackPixelChannel].traits=traits;
731static inline void SetPixelBlue(
const Image *magick_restrict image,
732 const Quantum blue,Quantum *magick_restrict pixel)
734 pixel[image->channel_map[BluePixelChannel].offset]=blue;
737static inline void SetPixelBlueTraits(
Image *image,
const PixelTrait traits)
739 image->channel_map[BluePixelChannel].traits=traits;
742static inline void SetPixelCb(
const Image *magick_restrict image,
743 const Quantum cb,Quantum *magick_restrict pixel)
745 pixel[image->channel_map[CbPixelChannel].offset]=cb;
748static inline void SetPixelCbTraits(
Image *image,
const PixelTrait traits)
750 image->channel_map[CbPixelChannel].traits=traits;
753static inline void SetPixelChannel(
const Image *magick_restrict image,
754 const PixelChannel channel,
const Quantum quantum,
755 Quantum *magick_restrict pixel)
757 if ((
size_t) channel >= MaxPixelChannels)
759 if (image->channel_map[channel].traits != UndefinedPixelTrait)
760 pixel[image->channel_map[channel].offset]=quantum;
763static inline void SetPixelChannelAttributes(
764 const Image *magick_restrict image,
const PixelChannel channel,
765 const PixelTrait traits,
const ssize_t offset)
767 if ((offset < 0) || (offset >= MaxPixelChannels))
769 if ((
size_t) channel >= MaxPixelChannels)
771 image->channel_map[offset].channel=channel;
772 image->channel_map[channel].offset=offset;
773 image->channel_map[channel].traits=traits;
776static inline void SetPixelChannelChannel(
const Image *magick_restrict image,
777 const PixelChannel channel,
const ssize_t offset)
779 if ((offset < 0) || (offset >= MaxPixelChannels))
781 if ((
size_t) channel >= MaxPixelChannels)
783 image->channel_map[offset].channel=channel;
784 image->channel_map[channel].offset=offset;
787static inline void SetPixelChannels(
Image *image,
const size_t number_channels)
789 image->number_channels=number_channels;
792static inline void SetPixelChannelTraits(
Image *image,
793 const PixelChannel channel,
const PixelTrait traits)
795 if ((
size_t) channel >= MaxPixelChannels)
797 image->channel_map[channel].traits=traits;
800static inline void SetPixelCompositeMask(
const Image *magick_restrict image,
801 const Quantum mask,Quantum *magick_restrict pixel)
803 if (image->channel_map[CompositeMaskPixelChannel].traits != UndefinedPixelTrait)
804 pixel[image->channel_map[CompositeMaskPixelChannel].offset]=mask;
807static inline void SetPixelCr(
const Image *magick_restrict image,
808 const Quantum cr,Quantum *magick_restrict pixel)
810 pixel[image->channel_map[CrPixelChannel].offset]=cr;
813static inline void SetPixelCrTraits(
Image *image,
const PixelTrait traits)
815 image->channel_map[CrPixelChannel].traits=traits;
818static inline void SetPixelCyan(
const Image *magick_restrict image,
819 const Quantum cyan,Quantum *magick_restrict pixel)
821 pixel[image->channel_map[CyanPixelChannel].offset]=cyan;
824static inline void SetPixelGray(
const Image *magick_restrict image,
825 const Quantum gray,Quantum *magick_restrict pixel)
827 pixel[image->channel_map[GrayPixelChannel].offset]=gray;
830static inline void SetPixelGrayTraits(
Image *image,
const PixelTrait traits)
832 image->channel_map[GrayPixelChannel].traits=traits;
835static inline void SetPixelGreen(
const Image *magick_restrict image,
836 const Quantum green,Quantum *magick_restrict pixel)
838 pixel[image->channel_map[GreenPixelChannel].offset]=green;
841static inline void SetPixelGreenTraits(
Image *image,
const PixelTrait traits)
843 image->channel_map[GreenPixelChannel].traits=traits;
846static inline void SetPixelIndex(
const Image *magick_restrict image,
847 const Quantum index,Quantum *magick_restrict pixel)
849 if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
850 pixel[image->channel_map[IndexPixelChannel].offset]=index;
853static inline void SetPixelIndexTraits(
Image *image,
const PixelTrait traits)
855 image->channel_map[IndexPixelChannel].traits=traits;
858static inline void SetPixelViaPixelInfo(
const Image *magick_restrict image,
859 const PixelInfo *magick_restrict pixel_info,Quantum *magick_restrict pixel)
861 pixel[image->channel_map[RedPixelChannel].offset]=
862 ClampToQuantum(pixel_info->red);
863 pixel[image->channel_map[GreenPixelChannel].offset]=
864 ClampToQuantum(pixel_info->green);
865 pixel[image->channel_map[BluePixelChannel].offset]=
866 ClampToQuantum(pixel_info->blue);
867 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
868 pixel[image->channel_map[BlackPixelChannel].offset]=
869 ClampToQuantum(pixel_info->black);
870 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
871 pixel[image->channel_map[AlphaPixelChannel].offset]=
872 pixel_info->alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
873 ClampToQuantum(pixel_info->alpha);
876static inline void SetPixelL(
const Image *magick_restrict image,
const Quantum L,
877 Quantum *magick_restrict pixel)
879 if (image->channel_map[LPixelChannel].traits != UndefinedPixelTrait)
880 pixel[image->channel_map[LPixelChannel].offset]=L;
883static inline void SetPixelMagenta(
const Image *magick_restrict image,
884 const Quantum magenta,Quantum *magick_restrict pixel)
886 pixel[image->channel_map[MagentaPixelChannel].offset]=magenta;
889static inline void SetPixelMagentaTraits(
Image *image,
const PixelTrait traits)
891 image->channel_map[MagentaPixelChannel].traits=traits;
894static inline void SetPixelMeta(
const Image *magick_restrict image,
895 const Quantum red,Quantum *magick_restrict pixel)
897 pixel[image->channel_map[MetaPixelChannels].offset]=red;
900static inline void SetPixelMetaTraits(
Image *image,
const PixelTrait traits)
902 image->channel_map[MetaPixelChannels].traits=traits;
905static inline void SetPixelReadMask(
const Image *magick_restrict image,
906 const Quantum mask,Quantum *magick_restrict pixel)
908 if (image->channel_map[ReadMaskPixelChannel].traits != UndefinedPixelTrait)
909 pixel[image->channel_map[ReadMaskPixelChannel].offset]=mask;
912static inline void SetPixelMetacontentExtent(
Image *image,
const size_t extent)
914 image->metacontent_extent=extent;
917static inline void SetPixelOpacity(
const Image *magick_restrict image,
918 const Quantum alpha,Quantum *magick_restrict pixel)
920 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
921 pixel[image->channel_map[AlphaPixelChannel].offset]=QuantumRange-alpha;
924static inline void SetPixelRed(
const Image *magick_restrict image,
925 const Quantum red,Quantum *magick_restrict pixel)
927 pixel[image->channel_map[RedPixelChannel].offset]=red;
930static inline void SetPixelRedTraits(
Image *image,
const PixelTrait traits)
932 image->channel_map[RedPixelChannel].traits=traits;
935static inline void SetPixelWriteMask(
const Image *magick_restrict image,
936 const Quantum mask,Quantum *magick_restrict pixel)
938 if (image->channel_map[WriteMaskPixelChannel].traits != UndefinedPixelTrait)
939 pixel[image->channel_map[WriteMaskPixelChannel].offset]=mask;
942static inline void SetPixelYellow(
const Image *magick_restrict image,
943 const Quantum yellow,Quantum *magick_restrict pixel)
945 pixel[image->channel_map[YellowPixelChannel].offset]=yellow;
948static inline void SetPixelYellowTraits(
Image *image,
const PixelTrait traits)
950 image->channel_map[YellowPixelChannel].traits=traits;
953static inline void SetPixelY(
const Image *magick_restrict image,
954 const Quantum y,Quantum *magick_restrict pixel)
956 pixel[image->channel_map[YPixelChannel].offset]=y;
959static inline void SetPixelYTraits(
Image *image,
const PixelTrait traits)
961 image->channel_map[YPixelChannel].traits=traits;
964#if defined(__cplusplus) || defined(c_plusplus)