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 MagickRealType GetPixelInfoLuma(
243 const PixelInfo *magick_restrict pixel)
248 if (pixel->colorspace == sRGBColorspace)
250 intensity=(MagickRealType) (0.212656*pixel->red+0.715158*pixel->green+
251 0.072186*pixel->blue);
254 intensity=(MagickRealType) (0.212656*EncodePixelGamma(pixel->red)+
255 0.715158*EncodePixelGamma(pixel->green)+
256 0.072186*EncodePixelGamma(pixel->blue));
260static inline MagickRealType GetPixelInfoLuminance(
261 const PixelInfo *magick_restrict pixel)
266 if (pixel->colorspace != sRGBColorspace)
268 intensity=(MagickRealType) (0.212656*pixel->red+0.715158*pixel->green+
269 0.072186*pixel->blue);
272 intensity=(MagickRealType) (0.212656*DecodePixelGamma(pixel->red)+
273 0.715158*DecodePixelGamma(pixel->green)+
274 0.072186*DecodePixelGamma(pixel->blue));
278static inline Quantum GetPixelL(
const Image *magick_restrict image,
279 const Quantum *magick_restrict pixel)
281 return(pixel[image->channel_map[LPixelChannel].offset]);
284static inline ssize_t GetPixelLabel(
const Image *magick_restrict image,
285 const Quantum *magick_restrict pixel)
287 return((ssize_t) pixel[image->channel_map[LabelPixelChannel].offset]);
290static inline MagickRealType GetPixelLuma(
291 const Image *magick_restrict image,
const Quantum *magick_restrict pixel)
297 0.212656*(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]+
298 0.715158*(MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset]+
299 0.072186*(MagickRealType) pixel[image->channel_map[BluePixelChannel].offset];
303static inline MagickRealType GetPixelLuminance(
304 const Image *magick_restrict image,
const Quantum *magick_restrict pixel)
309 if (image->colorspace != sRGBColorspace)
312 0.212656*(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]+
313 0.715158*(MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset]+
314 0.072186*(MagickRealType) pixel[image->channel_map[BluePixelChannel].offset];
317 intensity=(MagickRealType) (0.212656*DecodePixelGamma((MagickRealType)
318 pixel[image->channel_map[RedPixelChannel].offset])+0.715158*
319 DecodePixelGamma((MagickRealType)
320 pixel[image->channel_map[GreenPixelChannel].offset])+0.072186*
321 DecodePixelGamma((MagickRealType)
322 pixel[image->channel_map[BluePixelChannel].offset]));
326static inline Quantum GetPixelMagenta(
const Image *magick_restrict image,
327 const Quantum *magick_restrict pixel)
329 return(pixel[image->channel_map[MagentaPixelChannel].offset]);
332static inline PixelTrait GetPixelMagentaTraits(
333 const Image *magick_restrict image)
335 return(image->channel_map[MagentaPixelChannel].traits);
338static inline Quantum GetPixelMeta(
const Image *magick_restrict image,
339 const Quantum *magick_restrict pixel)
341 if (image->channel_map[MetaPixelChannels].traits == UndefinedPixelTrait)
343 return(pixel[image->channel_map[MetaPixelChannels].offset]);
346static inline PixelTrait GetPixelMetaTraits(
const Image *magick_restrict image)
348 return(image->channel_map[MetaPixelChannels].traits);
351static inline Quantum GetPixelReadMask(
const Image *magick_restrict image,
352 const Quantum *magick_restrict pixel)
354 if (image->channel_map[ReadMaskPixelChannel].traits == UndefinedPixelTrait)
355 return((Quantum) QuantumRange);
356 return(pixel[image->channel_map[ReadMaskPixelChannel].offset]);
359static inline void GetPixelInfoRGBA(
const Quantum red,
const Quantum green,
360 const Quantum blue,
const Quantum alpha,PixelInfo *magick_restrict pixel)
362 GetPixelInfo((Image *) NULL,pixel);
369static inline Quantum GetPixelWriteMask(
370 const Image *magick_restrict image,
const Quantum *magick_restrict pixel)
372 if (image->channel_map[WriteMaskPixelChannel].traits == UndefinedPixelTrait)
373 return((Quantum) QuantumRange);
374 return(pixel[image->channel_map[WriteMaskPixelChannel].offset]);
377static inline PixelTrait GetPixelReadMaskTraits(
378 const Image *magick_restrict image)
380 return(image->channel_map[ReadMaskPixelChannel].traits);
383static inline size_t GetPixelMetaChannels(
const Image *magick_restrict image)
385 return(image->number_meta_channels);
388static inline size_t GetPixelMetacontentExtent(
389 const Image *magick_restrict image)
391 return(image->metacontent_extent);
394static inline Quantum GetPixelOpacity(
const Image *magick_restrict image,
395 const Quantum *magick_restrict pixel)
397 if (image->channel_map[AlphaPixelChannel].traits != BlendPixelTrait)
398 return(QuantumRange-OpaqueAlpha);
399 return(QuantumRange-pixel[image->channel_map[AlphaPixelChannel].offset]);
402static inline Quantum GetPixelRed(
const Image *magick_restrict image,
403 const Quantum *magick_restrict pixel)
405 return(pixel[image->channel_map[RedPixelChannel].offset]);
408static inline PixelTrait GetPixelRedTraits(
const Image *magick_restrict image)
410 return(image->channel_map[RedPixelChannel].traits);
413static inline void GetPixelInfoPixel(
const Image *magick_restrict image,
414 const Quantum *magick_restrict pixel,PixelInfo *magick_restrict pixel_info)
416 (void) ResetMagickMemory(pixel_info,0,
sizeof(*pixel_info));
417 pixel_info->storage_class=DirectClass;
418 pixel_info->colorspace=sRGBColorspace;
419 pixel_info->depth=MAGICKCORE_QUANTUM_DEPTH;
420 pixel_info->alpha_trait=UndefinedPixelTrait;
421 pixel_info->alpha=(MagickRealType) OpaqueAlpha;
422 if (image != (Image *) NULL)
424 pixel_info->storage_class=image->storage_class;
425 pixel_info->colorspace=image->colorspace;
426 pixel_info->fuzz=image->fuzz;
427 pixel_info->depth=image->depth;
428 pixel_info->alpha_trait=image->alpha_trait;
429 if (pixel != (Quantum *) NULL)
431 pixel_info->red=(MagickRealType)
432 pixel[image->channel_map[RedPixelChannel].offset];
433 pixel_info->green=(MagickRealType)
434 pixel[image->channel_map[GreenPixelChannel].offset];
435 pixel_info->blue=(MagickRealType)
436 pixel[image->channel_map[BluePixelChannel].offset];
437 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
438 pixel_info->black=(MagickRealType)
439 pixel[image->channel_map[BlackPixelChannel].offset];
440 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
441 pixel_info->alpha=(MagickRealType)
442 pixel[image->channel_map[AlphaPixelChannel].offset];
443 if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
444 pixel_info->index=(MagickRealType)
445 pixel[image->channel_map[IndexPixelChannel].offset];
450static inline PixelTrait GetPixelTraits(
const Image *magick_restrict image,
451 const PixelChannel channel)
453 if ((
size_t) channel >= MaxPixelChannels)
454 return(UndefinedPixelTrait);
455 return(image->channel_map[channel].traits);
458static inline PixelTrait GetPixelWriteMaskTraits(
459 const Image *magick_restrict image)
461 return(image->channel_map[WriteMaskPixelChannel].traits);
464static inline Quantum GetPixelY(
const Image *magick_restrict image,
465 const Quantum *magick_restrict pixel)
467 return(pixel[image->channel_map[YPixelChannel].offset]);
470static inline PixelTrait GetPixelYTraits(
const Image *magick_restrict image)
472 return(image->channel_map[YPixelChannel].traits);
475static inline Quantum GetPixelYellow(
const Image *magick_restrict image,
476 const Quantum *magick_restrict pixel)
478 return(pixel[image->channel_map[YellowPixelChannel].offset]);
481static inline PixelTrait GetPixelYellowTraits(
482 const Image *magick_restrict image)
484 return(image->channel_map[YellowPixelChannel].traits);
487static inline MagickRealType AbsolutePixelValue(
const MagickRealType x)
489 return(x < 0.0 ? -x : x);
492static inline MagickBooleanType IsPixelAtDepth(
const Quantum pixel,
493 const QuantumAny range)
500#if !defined(MAGICKCORE_HDRI_SUPPORT)
501 quantum=(Quantum) (((
double) QuantumRange*((QuantumAny) (((
double) range*
502 pixel)/(
double) QuantumRange+0.5)))/(
double) range+0.5);
504 quantum=(Quantum) (((
double) QuantumRange*((QuantumAny) (((
double) range*
505 (
double) pixel)/(
double) QuantumRange+0.5)))/(
double) range);
507 return(pixel == quantum ? MagickTrue : MagickFalse);
510static inline MagickBooleanType IsPixelEquivalent(
511 const Image *magick_restrict image,
const Quantum *magick_restrict p,
512 const PixelInfo *magick_restrict q)
519 color=(MagickRealType) p[image->channel_map[AlphaPixelChannel].offset];
520 alpha=image->alpha_trait == UndefinedPixelTrait ? (MagickRealType)
522 beta=q->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
524 if (AbsolutePixelValue(alpha-beta) >= MagickEpsilon)
526 if ((AbsolutePixelValue(alpha-(MagickRealType) TransparentAlpha) < MagickEpsilon) ||
527 (AbsolutePixelValue(beta-(MagickRealType) TransparentAlpha) < MagickEpsilon))
529 color=(MagickRealType) p[image->channel_map[RedPixelChannel].offset];
530 if (AbsolutePixelValue(color-q->red) >= MagickEpsilon)
532 color=(MagickRealType) p[image->channel_map[GreenPixelChannel].offset];
533 if (AbsolutePixelValue(color-q->green) >= MagickEpsilon)
535 color=(MagickRealType) p[image->channel_map[BluePixelChannel].offset];
536 if (AbsolutePixelValue(color-q->blue) >= MagickEpsilon)
538 if (image->colorspace == CMYKColorspace)
540 color=(MagickRealType) p[image->channel_map[BlackPixelChannel].offset];
541 if (AbsolutePixelValue(color-q->black) >= MagickEpsilon)
547static inline MagickBooleanType IsPixelGray(
const Image *magick_restrict image,
548 const Quantum *magick_restrict pixel)
555 (MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]-
556 (MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset];
558 (MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset]-
559 (MagickRealType) pixel[image->channel_map[BluePixelChannel].offset];
560 if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
561 (AbsolutePixelValue(green_blue) < MagickEpsilon))
566static inline MagickBooleanType IsPixelInfoEquivalent(
567 const PixelInfo *magick_restrict p,
const PixelInfo *magick_restrict q)
573 alpha=p->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
575 beta=q->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
577 if (AbsolutePixelValue(alpha-beta) >= MagickEpsilon)
579 if ((AbsolutePixelValue(alpha-(MagickRealType) TransparentAlpha) < MagickEpsilon) ||
580 (AbsolutePixelValue(beta-(MagickRealType) TransparentAlpha) < MagickEpsilon))
582 if (AbsolutePixelValue(p->red-q->red) >= MagickEpsilon)
584 if (AbsolutePixelValue(p->green-q->green) >= MagickEpsilon)
586 if (AbsolutePixelValue(p->blue-q->blue) >= MagickEpsilon)
588 if (p->colorspace == CMYKColorspace)
590 if (AbsolutePixelValue(p->black-q->black) >= MagickEpsilon)
596static inline MagickBooleanType IsPixelMonochrome(
597 const Image *magick_restrict image,
const Quantum *magick_restrict pixel)
604 red=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset];
605 if ((AbsolutePixelValue(red) >= MagickEpsilon) &&
606 (AbsolutePixelValue(red-(MagickRealType) QuantumRange) >= MagickEpsilon))
609 (MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]-
610 (MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset];
612 (MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset]-
613 (MagickRealType) pixel[image->channel_map[BluePixelChannel].offset];
614 if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
615 (AbsolutePixelValue(green_blue) < MagickEpsilon))
620static inline MagickBooleanType IsPixelInfoGray(
621 const PixelInfo *magick_restrict pixel)
623 if ((AbsolutePixelValue(pixel->red-pixel->green) < MagickEpsilon) &&
624 (AbsolutePixelValue(pixel->green-pixel->blue) < MagickEpsilon))
629static inline MagickBooleanType IsPixelInfoMonochrome(
630 const PixelInfo *magick_restrict pixel_info)
636 if ((AbsolutePixelValue(pixel_info->red) >= MagickEpsilon) ||
637 (AbsolutePixelValue(pixel_info->red-(MagickRealType) QuantumRange) >= MagickEpsilon))
639 red_green=pixel_info->red-pixel_info->green;
640 green_blue=pixel_info->green-pixel_info->blue;
641 if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
642 (AbsolutePixelValue(green_blue) < MagickEpsilon))
647static inline void SetPixela(
const Image *magick_restrict image,
648 const Quantum a,Quantum *magick_restrict pixel)
650 if (image->channel_map[aPixelChannel].traits != UndefinedPixelTrait)
651 pixel[image->channel_map[aPixelChannel].offset]=a;
654static inline void SetPixelAlpha(
const Image *magick_restrict image,
655 const Quantum alpha,Quantum *magick_restrict pixel)
657 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
658 pixel[image->channel_map[AlphaPixelChannel].offset]=alpha;
661static inline void SetPixelAlphaTraits(Image *image,
const PixelTrait traits)
663 image->channel_map[AlphaPixelChannel].traits=traits;
666static inline void SetPixelb(
const Image *magick_restrict image,
667 const Quantum b,Quantum *magick_restrict pixel)
669 if (image->channel_map[bPixelChannel].traits != UndefinedPixelTrait)
670 pixel[image->channel_map[bPixelChannel].offset]=b;
673static inline void SetPixelBackgroundColor(
const Image *magick_restrict image,
674 Quantum *magick_restrict pixel)
679 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
680 pixel[i]=(Quantum) 0;
681 pixel[image->channel_map[RedPixelChannel].offset]=
682 ClampToQuantum(image->background_color.red);
683 pixel[image->channel_map[GreenPixelChannel].offset]=
684 ClampToQuantum(image->background_color.green);
685 pixel[image->channel_map[BluePixelChannel].offset]=
686 ClampToQuantum(image->background_color.blue);
687 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
688 pixel[image->channel_map[BlackPixelChannel].offset]=
689 ClampToQuantum(image->background_color.black);
690 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
691 pixel[image->channel_map[AlphaPixelChannel].offset]=
692 image->background_color.alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
693 ClampToQuantum(image->background_color.alpha);
696static inline void SetPixelBackgoundColor(
const Image *magick_restrict image,
697 Quantum *magick_restrict pixel) magick_attribute((deprecated));
699static inline void SetPixelBackgoundColor(
const Image *magick_restrict image,
700 Quantum *magick_restrict pixel)
702 SetPixelBackgroundColor(image,pixel);
705static inline void SetPixelBlack(
const Image *magick_restrict image,
706 const Quantum black,Quantum *magick_restrict pixel)
708 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
709 pixel[image->channel_map[BlackPixelChannel].offset]=black;
712static inline void SetPixelBlackTraits(Image *image,
const PixelTrait traits)
714 image->channel_map[BlackPixelChannel].traits=traits;
717static inline void SetPixelBlue(
const Image *magick_restrict image,
718 const Quantum blue,Quantum *magick_restrict pixel)
720 pixel[image->channel_map[BluePixelChannel].offset]=blue;
723static inline void SetPixelBlueTraits(Image *image,
const PixelTrait traits)
725 image->channel_map[BluePixelChannel].traits=traits;
728static inline void SetPixelCb(
const Image *magick_restrict image,
729 const Quantum cb,Quantum *magick_restrict pixel)
731 pixel[image->channel_map[CbPixelChannel].offset]=cb;
734static inline void SetPixelCbTraits(Image *image,
const PixelTrait traits)
736 image->channel_map[CbPixelChannel].traits=traits;
739static inline void SetPixelChannel(
const Image *magick_restrict image,
740 const PixelChannel channel,
const Quantum quantum,
741 Quantum *magick_restrict pixel)
743 if ((
size_t) channel >= MaxPixelChannels)
745 if (image->channel_map[channel].traits != UndefinedPixelTrait)
746 pixel[image->channel_map[channel].offset]=quantum;
749static inline void SetPixelChannelAttributes(
750 const Image *magick_restrict image,
const PixelChannel channel,
751 const PixelTrait traits,
const ssize_t offset)
753 if ((offset < 0) || (offset >= MaxPixelChannels))
755 if ((
size_t) channel >= MaxPixelChannels)
757 image->channel_map[offset].channel=channel;
758 image->channel_map[channel].offset=offset;
759 image->channel_map[channel].traits=traits;
762static inline void SetPixelChannelChannel(
const Image *magick_restrict image,
763 const PixelChannel channel,
const ssize_t offset)
765 if ((offset < 0) || (offset >= MaxPixelChannels))
767 if ((
size_t) channel >= MaxPixelChannels)
769 image->channel_map[offset].channel=channel;
770 image->channel_map[channel].offset=offset;
773static inline void SetPixelChannels(Image *image,
const size_t number_channels)
775 image->number_channels=number_channels;
778static inline void SetPixelChannelTraits(Image *image,
779 const PixelChannel channel,
const PixelTrait traits)
781 if ((
size_t) channel >= MaxPixelChannels)
783 image->channel_map[channel].traits=traits;
786static inline void SetPixelCompositeMask(
const Image *magick_restrict image,
787 const Quantum mask,Quantum *magick_restrict pixel)
789 if (image->channel_map[CompositeMaskPixelChannel].traits != UndefinedPixelTrait)
790 pixel[image->channel_map[CompositeMaskPixelChannel].offset]=mask;
793static inline void SetPixelCr(
const Image *magick_restrict image,
794 const Quantum cr,Quantum *magick_restrict pixel)
796 pixel[image->channel_map[CrPixelChannel].offset]=cr;
799static inline void SetPixelCrTraits(Image *image,
const PixelTrait traits)
801 image->channel_map[CrPixelChannel].traits=traits;
804static inline void SetPixelCyan(
const Image *magick_restrict image,
805 const Quantum cyan,Quantum *magick_restrict pixel)
807 pixel[image->channel_map[CyanPixelChannel].offset]=cyan;
810static inline void SetPixelGray(
const Image *magick_restrict image,
811 const Quantum gray,Quantum *magick_restrict pixel)
813 pixel[image->channel_map[GrayPixelChannel].offset]=gray;
816static inline void SetPixelGrayTraits(Image *image,
const PixelTrait traits)
818 image->channel_map[GrayPixelChannel].traits=traits;
821static inline void SetPixelGreen(
const Image *magick_restrict image,
822 const Quantum green,Quantum *magick_restrict pixel)
824 pixel[image->channel_map[GreenPixelChannel].offset]=green;
827static inline void SetPixelGreenTraits(Image *image,
const PixelTrait traits)
829 image->channel_map[GreenPixelChannel].traits=traits;
832static inline void SetPixelIndex(
const Image *magick_restrict image,
833 const Quantum index,Quantum *magick_restrict pixel)
835 if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
836 pixel[image->channel_map[IndexPixelChannel].offset]=index;
839static inline void SetPixelIndexTraits(Image *image,
const PixelTrait traits)
841 image->channel_map[IndexPixelChannel].traits=traits;
844static inline void SetPixelViaPixelInfo(
const Image *magick_restrict image,
845 const PixelInfo *magick_restrict pixel_info,Quantum *magick_restrict pixel)
847 pixel[image->channel_map[RedPixelChannel].offset]=
848 ClampToQuantum(pixel_info->red);
849 pixel[image->channel_map[GreenPixelChannel].offset]=
850 ClampToQuantum(pixel_info->green);
851 pixel[image->channel_map[BluePixelChannel].offset]=
852 ClampToQuantum(pixel_info->blue);
853 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
854 pixel[image->channel_map[BlackPixelChannel].offset]=
855 ClampToQuantum(pixel_info->black);
856 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
857 pixel[image->channel_map[AlphaPixelChannel].offset]=
858 pixel_info->alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
859 ClampToQuantum(pixel_info->alpha);
862static inline void SetPixelL(
const Image *magick_restrict image,
const Quantum L,
863 Quantum *magick_restrict pixel)
865 if (image->channel_map[LPixelChannel].traits != UndefinedPixelTrait)
866 pixel[image->channel_map[LPixelChannel].offset]=L;
869static inline void SetPixelMagenta(
const Image *magick_restrict image,
870 const Quantum magenta,Quantum *magick_restrict pixel)
872 pixel[image->channel_map[MagentaPixelChannel].offset]=magenta;
875static inline void SetPixelMagentaTraits(Image *image,
const PixelTrait traits)
877 image->channel_map[MagentaPixelChannel].traits=traits;
880static inline void SetPixelMeta(
const Image *magick_restrict image,
881 const Quantum red,Quantum *magick_restrict pixel)
883 pixel[image->channel_map[MetaPixelChannels].offset]=red;
886static inline void SetPixelMetaTraits(Image *image,
const PixelTrait traits)
888 image->channel_map[MetaPixelChannels].traits=traits;
891static inline void SetPixelReadMask(
const Image *magick_restrict image,
892 const Quantum mask,Quantum *magick_restrict pixel)
894 if (image->channel_map[ReadMaskPixelChannel].traits != UndefinedPixelTrait)
895 pixel[image->channel_map[ReadMaskPixelChannel].offset]=mask;
898static inline void SetPixelMetacontentExtent(Image *image,
const size_t extent)
900 image->metacontent_extent=extent;
903static inline void SetPixelOpacity(
const Image *magick_restrict image,
904 const Quantum alpha,Quantum *magick_restrict pixel)
906 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
907 pixel[image->channel_map[AlphaPixelChannel].offset]=QuantumRange-alpha;
910static inline void SetPixelRed(
const Image *magick_restrict image,
911 const Quantum red,Quantum *magick_restrict pixel)
913 pixel[image->channel_map[RedPixelChannel].offset]=red;
916static inline void SetPixelRedTraits(Image *image,
const PixelTrait traits)
918 image->channel_map[RedPixelChannel].traits=traits;
921static inline void SetPixelWriteMask(
const Image *magick_restrict image,
922 const Quantum mask,Quantum *magick_restrict pixel)
924 if (image->channel_map[WriteMaskPixelChannel].traits != UndefinedPixelTrait)
925 pixel[image->channel_map[WriteMaskPixelChannel].offset]=mask;
928static inline void SetPixelYellow(
const Image *magick_restrict image,
929 const Quantum yellow,Quantum *magick_restrict pixel)
931 pixel[image->channel_map[YellowPixelChannel].offset]=yellow;
934static inline void SetPixelYellowTraits(Image *image,
const PixelTrait traits)
936 image->channel_map[YellowPixelChannel].traits=traits;
939static inline void SetPixelY(
const Image *magick_restrict image,
940 const Quantum y,Quantum *magick_restrict pixel)
942 pixel[image->channel_map[YPixelChannel].offset]=y;
945static inline void SetPixelYTraits(Image *image,
const PixelTrait traits)
947 image->channel_map[YPixelChannel].traits=traits;
950#if defined(__cplusplus) || defined(c_plusplus)