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#if defined(MAGICKCORE_HDRI_SUPPORT)
209 if (pixel[image->channel_map[IndexPixelChannel].offset] < 0)
212 return(pixel[image->channel_map[IndexPixelChannel].offset]);
215static inline PixelTrait GetPixelIndexTraits(
const Image *magick_restrict image)
217 return(image->channel_map[IndexPixelChannel].traits);
220static inline MagickRealType GetPixelInfoChannel(
221 const PixelInfo *magick_restrict pixel_info,
const PixelChannel channel)
225 case RedPixelChannel:
return(pixel_info->red);
226 case GreenPixelChannel:
return(pixel_info->green);
227 case BluePixelChannel:
return(pixel_info->blue);
228 case BlackPixelChannel:
230 if (pixel_info->colorspace != CMYKColorspace)
232 return(pixel_info->black);
234 case AlphaPixelChannel:
236 if (pixel_info->alpha_trait == UndefinedPixelTrait)
238 return(pixel_info->alpha);
240 case IndexPixelChannel:
return(pixel_info->index);
243 return((MagickRealType) 0.0);
246static inline MagickRealType GetPixelInfoLuma(
247 const PixelInfo *magick_restrict pixel)
252 if (pixel->colorspace == sRGBColorspace)
254 intensity=(MagickRealType) (0.212656*pixel->red+0.715158*pixel->green+
255 0.072186*pixel->blue);
258 intensity=(MagickRealType) (0.212656*EncodePixelGamma(pixel->red)+
259 0.715158*EncodePixelGamma(pixel->green)+
260 0.072186*EncodePixelGamma(pixel->blue));
264static inline MagickRealType GetPixelInfoLuminance(
265 const PixelInfo *magick_restrict pixel)
270 if (pixel->colorspace != sRGBColorspace)
272 intensity=(MagickRealType) (0.212656*pixel->red+0.715158*pixel->green+
273 0.072186*pixel->blue);
276 intensity=(MagickRealType) (0.212656*DecodePixelGamma(pixel->red)+
277 0.715158*DecodePixelGamma(pixel->green)+
278 0.072186*DecodePixelGamma(pixel->blue));
282static inline Quantum GetPixelL(
const Image *magick_restrict image,
283 const Quantum *magick_restrict pixel)
285 return(pixel[image->channel_map[LPixelChannel].offset]);
288static inline ssize_t GetPixelLabel(
const Image *magick_restrict image,
289 const Quantum *magick_restrict pixel)
291 return((ssize_t) pixel[image->channel_map[LabelPixelChannel].offset]);
294static inline MagickRealType GetPixelLuma(
295 const Image *magick_restrict image,
const Quantum *magick_restrict pixel)
301 0.212656*(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]+
302 0.715158*(MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset]+
303 0.072186*(MagickRealType) pixel[image->channel_map[BluePixelChannel].offset];
307static inline MagickRealType GetPixelLuminance(
308 const Image *magick_restrict image,
const Quantum *magick_restrict pixel)
313 if (image->colorspace != sRGBColorspace)
316 0.212656*(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]+
317 0.715158*(MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset]+
318 0.072186*(MagickRealType) pixel[image->channel_map[BluePixelChannel].offset];
321 intensity=(MagickRealType) (0.212656*DecodePixelGamma((MagickRealType)
322 pixel[image->channel_map[RedPixelChannel].offset])+0.715158*
323 DecodePixelGamma((MagickRealType)
324 pixel[image->channel_map[GreenPixelChannel].offset])+0.072186*
325 DecodePixelGamma((MagickRealType)
326 pixel[image->channel_map[BluePixelChannel].offset]));
330static inline Quantum GetPixelMagenta(
const Image *magick_restrict image,
331 const Quantum *magick_restrict pixel)
333 return(pixel[image->channel_map[MagentaPixelChannel].offset]);
336static inline PixelTrait GetPixelMagentaTraits(
337 const Image *magick_restrict image)
339 return(image->channel_map[MagentaPixelChannel].traits);
342static inline Quantum GetPixelMeta(
const Image *magick_restrict image,
343 const Quantum *magick_restrict pixel)
345 if (image->channel_map[MetaPixelChannels].traits == UndefinedPixelTrait)
347 return(pixel[image->channel_map[MetaPixelChannels].offset]);
350static inline PixelTrait GetPixelMetaTraits(
const Image *magick_restrict image)
352 return(image->channel_map[MetaPixelChannels].traits);
355static inline Quantum GetPixelReadMask(
const Image *magick_restrict image,
356 const Quantum *magick_restrict pixel)
358 if (image->channel_map[ReadMaskPixelChannel].traits == UndefinedPixelTrait)
359 return((Quantum) QuantumRange);
360 return(pixel[image->channel_map[ReadMaskPixelChannel].offset]);
363static inline void GetPixelInfoRGBA(
const Quantum red,
const Quantum green,
364 const Quantum blue,
const Quantum alpha,PixelInfo *magick_restrict pixel)
366 GetPixelInfo((Image *) NULL,pixel);
373static inline Quantum GetPixelWriteMask(
374 const Image *magick_restrict image,
const Quantum *magick_restrict pixel)
376 if (image->channel_map[WriteMaskPixelChannel].traits == UndefinedPixelTrait)
377 return((Quantum) QuantumRange);
378 return(pixel[image->channel_map[WriteMaskPixelChannel].offset]);
381static inline PixelTrait GetPixelReadMaskTraits(
382 const Image *magick_restrict image)
384 return(image->channel_map[ReadMaskPixelChannel].traits);
387static inline size_t GetPixelMetaChannels(
const Image *magick_restrict image)
389 return(image->number_meta_channels);
392static inline size_t GetPixelMetacontentExtent(
393 const Image *magick_restrict image)
395 return(image->metacontent_extent);
398static inline Quantum GetPixelOpacity(
const Image *magick_restrict image,
399 const Quantum *magick_restrict pixel)
401 if (image->channel_map[AlphaPixelChannel].traits != BlendPixelTrait)
402 return(QuantumRange-OpaqueAlpha);
403 return(QuantumRange-pixel[image->channel_map[AlphaPixelChannel].offset]);
406static inline Quantum GetPixelRed(
const Image *magick_restrict image,
407 const Quantum *magick_restrict pixel)
409 return(pixel[image->channel_map[RedPixelChannel].offset]);
412static inline PixelTrait GetPixelRedTraits(
const Image *magick_restrict image)
414 return(image->channel_map[RedPixelChannel].traits);
417static inline void GetPixelInfoPixel(
const Image *magick_restrict image,
418 const Quantum *magick_restrict pixel,PixelInfo *magick_restrict pixel_info)
420 (void) ResetMagickMemory(pixel_info,0,
sizeof(*pixel_info));
421 pixel_info->storage_class=DirectClass;
422 pixel_info->colorspace=sRGBColorspace;
423 pixel_info->depth=MAGICKCORE_QUANTUM_DEPTH;
424 pixel_info->alpha_trait=UndefinedPixelTrait;
425 pixel_info->alpha=(MagickRealType) OpaqueAlpha;
426 if (image != (Image *) NULL)
428 pixel_info->storage_class=image->storage_class;
429 pixel_info->colorspace=image->colorspace;
430 pixel_info->fuzz=image->fuzz;
431 pixel_info->depth=image->depth;
432 pixel_info->alpha_trait=image->alpha_trait;
433 if (pixel != (Quantum *) NULL)
435 pixel_info->red=(MagickRealType)
436 pixel[image->channel_map[RedPixelChannel].offset];
437 pixel_info->green=(MagickRealType)
438 pixel[image->channel_map[GreenPixelChannel].offset];
439 pixel_info->blue=(MagickRealType)
440 pixel[image->channel_map[BluePixelChannel].offset];
441 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
442 pixel_info->black=(MagickRealType)
443 pixel[image->channel_map[BlackPixelChannel].offset];
444 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
445 pixel_info->alpha=(MagickRealType)
446 pixel[image->channel_map[AlphaPixelChannel].offset];
447 if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
448 pixel_info->index=(MagickRealType)
449 pixel[image->channel_map[IndexPixelChannel].offset];
454static inline PixelTrait GetPixelTraits(
const Image *magick_restrict image,
455 const PixelChannel channel)
457 if ((
size_t) channel >= MaxPixelChannels)
458 return(UndefinedPixelTrait);
459 return(image->channel_map[channel].traits);
462static inline PixelTrait GetPixelWriteMaskTraits(
463 const Image *magick_restrict image)
465 return(image->channel_map[WriteMaskPixelChannel].traits);
468static inline Quantum GetPixelY(
const Image *magick_restrict image,
469 const Quantum *magick_restrict pixel)
471 return(pixel[image->channel_map[YPixelChannel].offset]);
474static inline PixelTrait GetPixelYTraits(
const Image *magick_restrict image)
476 return(image->channel_map[YPixelChannel].traits);
479static inline Quantum GetPixelYellow(
const Image *magick_restrict image,
480 const Quantum *magick_restrict pixel)
482 return(pixel[image->channel_map[YellowPixelChannel].offset]);
485static inline PixelTrait GetPixelYellowTraits(
486 const Image *magick_restrict image)
488 return(image->channel_map[YellowPixelChannel].traits);
491static inline MagickRealType AbsolutePixelValue(
const MagickRealType x)
493 return(x < 0.0 ? -x : x);
496static inline MagickBooleanType IsPixelAtDepth(
const Quantum pixel,
497 const QuantumAny range)
504#if !defined(MAGICKCORE_HDRI_SUPPORT)
505 quantum=(Quantum) (((
double) QuantumRange*((QuantumAny) (((
double) range*
506 pixel)/(
double) QuantumRange+0.5)))/(
double) range+0.5);
508 quantum=(Quantum) (((
double) QuantumRange*((QuantumAny) (((
double) range*
509 (
double) pixel)/(
double) QuantumRange+0.5)))/(
double) range);
511 return(pixel == quantum ? MagickTrue : MagickFalse);
514static inline MagickBooleanType IsPixelEquivalent(
515 const Image *magick_restrict image,
const Quantum *magick_restrict p,
516 const PixelInfo *magick_restrict q)
523 color=(MagickRealType) p[image->channel_map[AlphaPixelChannel].offset];
524 alpha=image->alpha_trait == UndefinedPixelTrait ? (MagickRealType)
526 beta=q->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
528 if (AbsolutePixelValue(alpha-beta) >= MagickEpsilon)
530 if ((AbsolutePixelValue(alpha-(MagickRealType) TransparentAlpha) < MagickEpsilon) ||
531 (AbsolutePixelValue(beta-(MagickRealType) TransparentAlpha) < MagickEpsilon))
533 color=(MagickRealType) p[image->channel_map[RedPixelChannel].offset];
534 if (AbsolutePixelValue(color-q->red) >= MagickEpsilon)
536 color=(MagickRealType) p[image->channel_map[GreenPixelChannel].offset];
537 if (AbsolutePixelValue(color-q->green) >= MagickEpsilon)
539 color=(MagickRealType) p[image->channel_map[BluePixelChannel].offset];
540 if (AbsolutePixelValue(color-q->blue) >= MagickEpsilon)
542 if (image->colorspace == CMYKColorspace)
544 color=(MagickRealType) p[image->channel_map[BlackPixelChannel].offset];
545 if (AbsolutePixelValue(color-q->black) >= MagickEpsilon)
551static inline MagickBooleanType IsPixelGray(
const Image *magick_restrict image,
552 const Quantum *magick_restrict pixel)
559 (MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]-
560 (MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset];
562 (MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset]-
563 (MagickRealType) pixel[image->channel_map[BluePixelChannel].offset];
564 if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
565 (AbsolutePixelValue(green_blue) < MagickEpsilon))
570static inline MagickBooleanType IsPixelInfoEquivalent(
571 const PixelInfo *magick_restrict p,
const PixelInfo *magick_restrict q)
577 alpha=p->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
579 beta=q->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
581 if (AbsolutePixelValue(alpha-beta) >= MagickEpsilon)
583 if ((AbsolutePixelValue(alpha-(MagickRealType) TransparentAlpha) < MagickEpsilon) ||
584 (AbsolutePixelValue(beta-(MagickRealType) TransparentAlpha) < MagickEpsilon))
586 if (AbsolutePixelValue(p->red-q->red) >= MagickEpsilon)
588 if (AbsolutePixelValue(p->green-q->green) >= MagickEpsilon)
590 if (AbsolutePixelValue(p->blue-q->blue) >= MagickEpsilon)
592 if (p->colorspace == CMYKColorspace)
594 if (AbsolutePixelValue(p->black-q->black) >= MagickEpsilon)
600static inline MagickBooleanType IsPixelMonochrome(
601 const Image *magick_restrict image,
const Quantum *magick_restrict pixel)
608 red=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset];
609 if ((AbsolutePixelValue(red) >= MagickEpsilon) &&
610 (AbsolutePixelValue(red-(MagickRealType) QuantumRange) >= MagickEpsilon))
613 (MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]-
614 (MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset];
616 (MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset]-
617 (MagickRealType) pixel[image->channel_map[BluePixelChannel].offset];
618 if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
619 (AbsolutePixelValue(green_blue) < MagickEpsilon))
624static inline MagickBooleanType IsPixelInfoGray(
625 const PixelInfo *magick_restrict pixel)
627 if ((AbsolutePixelValue(pixel->red-pixel->green) < MagickEpsilon) &&
628 (AbsolutePixelValue(pixel->green-pixel->blue) < MagickEpsilon))
633static inline MagickBooleanType IsPixelInfoMonochrome(
634 const PixelInfo *magick_restrict pixel_info)
640 if ((AbsolutePixelValue(pixel_info->red) >= MagickEpsilon) ||
641 (AbsolutePixelValue(pixel_info->red-(MagickRealType) QuantumRange) >= MagickEpsilon))
643 red_green=pixel_info->red-pixel_info->green;
644 green_blue=pixel_info->green-pixel_info->blue;
645 if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
646 (AbsolutePixelValue(green_blue) < MagickEpsilon))
651static inline void SetPixela(
const Image *magick_restrict image,
652 const Quantum a,Quantum *magick_restrict pixel)
654 if (image->channel_map[aPixelChannel].traits != UndefinedPixelTrait)
655 pixel[image->channel_map[aPixelChannel].offset]=a;
658static inline void SetPixelAlpha(
const Image *magick_restrict image,
659 const Quantum alpha,Quantum *magick_restrict pixel)
661 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
662 pixel[image->channel_map[AlphaPixelChannel].offset]=alpha;
665static inline void SetPixelAlphaTraits(Image *image,
const PixelTrait traits)
667 image->channel_map[AlphaPixelChannel].traits=traits;
670static inline void SetPixelb(
const Image *magick_restrict image,
671 const Quantum b,Quantum *magick_restrict pixel)
673 if (image->channel_map[bPixelChannel].traits != UndefinedPixelTrait)
674 pixel[image->channel_map[bPixelChannel].offset]=b;
677static inline void SetPixelBackgroundColor(
const Image *magick_restrict image,
678 Quantum *magick_restrict pixel)
683 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
684 pixel[i]=(Quantum) 0;
685 pixel[image->channel_map[RedPixelChannel].offset]=
686 ClampToQuantum(image->background_color.red);
687 pixel[image->channel_map[GreenPixelChannel].offset]=
688 ClampToQuantum(image->background_color.green);
689 pixel[image->channel_map[BluePixelChannel].offset]=
690 ClampToQuantum(image->background_color.blue);
691 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
692 pixel[image->channel_map[BlackPixelChannel].offset]=
693 ClampToQuantum(image->background_color.black);
694 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
695 pixel[image->channel_map[AlphaPixelChannel].offset]=
696 image->background_color.alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
697 ClampToQuantum(image->background_color.alpha);
700static inline void SetPixelBackgoundColor(
const Image *magick_restrict image,
701 Quantum *magick_restrict pixel) magick_attribute((deprecated));
703static inline void SetPixelBackgoundColor(
const Image *magick_restrict image,
704 Quantum *magick_restrict pixel)
706 SetPixelBackgroundColor(image,pixel);
709static inline void SetPixelBlack(
const Image *magick_restrict image,
710 const Quantum black,Quantum *magick_restrict pixel)
712 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
713 pixel[image->channel_map[BlackPixelChannel].offset]=black;
716static inline void SetPixelBlackTraits(Image *image,
const PixelTrait traits)
718 image->channel_map[BlackPixelChannel].traits=traits;
721static inline void SetPixelBlue(
const Image *magick_restrict image,
722 const Quantum blue,Quantum *magick_restrict pixel)
724 pixel[image->channel_map[BluePixelChannel].offset]=blue;
727static inline void SetPixelBlueTraits(Image *image,
const PixelTrait traits)
729 image->channel_map[BluePixelChannel].traits=traits;
732static inline void SetPixelCb(
const Image *magick_restrict image,
733 const Quantum cb,Quantum *magick_restrict pixel)
735 pixel[image->channel_map[CbPixelChannel].offset]=cb;
738static inline void SetPixelCbTraits(Image *image,
const PixelTrait traits)
740 image->channel_map[CbPixelChannel].traits=traits;
743static inline void SetPixelChannel(
const Image *magick_restrict image,
744 const PixelChannel channel,
const Quantum quantum,
745 Quantum *magick_restrict pixel)
747 if ((
size_t) channel >= MaxPixelChannels)
749 if (image->channel_map[channel].traits != UndefinedPixelTrait)
750 pixel[image->channel_map[channel].offset]=quantum;
753static inline void SetPixelChannelAttributes(
754 const Image *magick_restrict image,
const PixelChannel channel,
755 const PixelTrait traits,
const ssize_t offset)
757 if ((offset < 0) || (offset >= MaxPixelChannels))
759 if ((
size_t) channel >= MaxPixelChannels)
761 image->channel_map[offset].channel=channel;
762 image->channel_map[channel].offset=offset;
763 image->channel_map[channel].traits=traits;
766static inline void SetPixelChannelChannel(
const Image *magick_restrict image,
767 const PixelChannel channel,
const ssize_t offset)
769 if ((offset < 0) || (offset >= MaxPixelChannels))
771 if ((
size_t) channel >= MaxPixelChannels)
773 image->channel_map[offset].channel=channel;
774 image->channel_map[channel].offset=offset;
777static inline void SetPixelChannels(Image *image,
const size_t number_channels)
779 image->number_channels=number_channels;
782static inline void SetPixelChannelTraits(Image *image,
783 const PixelChannel channel,
const PixelTrait traits)
785 if ((
size_t) channel >= MaxPixelChannels)
787 image->channel_map[channel].traits=traits;
790static inline void SetPixelCompositeMask(
const Image *magick_restrict image,
791 const Quantum mask,Quantum *magick_restrict pixel)
793 if (image->channel_map[CompositeMaskPixelChannel].traits != UndefinedPixelTrait)
794 pixel[image->channel_map[CompositeMaskPixelChannel].offset]=mask;
797static inline void SetPixelCr(
const Image *magick_restrict image,
798 const Quantum cr,Quantum *magick_restrict pixel)
800 pixel[image->channel_map[CrPixelChannel].offset]=cr;
803static inline void SetPixelCrTraits(Image *image,
const PixelTrait traits)
805 image->channel_map[CrPixelChannel].traits=traits;
808static inline void SetPixelCyan(
const Image *magick_restrict image,
809 const Quantum cyan,Quantum *magick_restrict pixel)
811 pixel[image->channel_map[CyanPixelChannel].offset]=cyan;
814static inline void SetPixelGray(
const Image *magick_restrict image,
815 const Quantum gray,Quantum *magick_restrict pixel)
817 pixel[image->channel_map[GrayPixelChannel].offset]=gray;
820static inline void SetPixelGrayTraits(Image *image,
const PixelTrait traits)
822 image->channel_map[GrayPixelChannel].traits=traits;
825static inline void SetPixelGreen(
const Image *magick_restrict image,
826 const Quantum green,Quantum *magick_restrict pixel)
828 pixel[image->channel_map[GreenPixelChannel].offset]=green;
831static inline void SetPixelGreenTraits(Image *image,
const PixelTrait traits)
833 image->channel_map[GreenPixelChannel].traits=traits;
836static inline void SetPixelIndex(
const Image *magick_restrict image,
837 const Quantum index,Quantum *magick_restrict pixel)
839 if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
840 pixel[image->channel_map[IndexPixelChannel].offset]=index;
843static inline void SetPixelIndexTraits(Image *image,
const PixelTrait traits)
845 image->channel_map[IndexPixelChannel].traits=traits;
848static inline void SetPixelViaPixelInfo(
const Image *magick_restrict image,
849 const PixelInfo *magick_restrict pixel_info,Quantum *magick_restrict pixel)
851 pixel[image->channel_map[RedPixelChannel].offset]=
852 ClampToQuantum(pixel_info->red);
853 pixel[image->channel_map[GreenPixelChannel].offset]=
854 ClampToQuantum(pixel_info->green);
855 pixel[image->channel_map[BluePixelChannel].offset]=
856 ClampToQuantum(pixel_info->blue);
857 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
858 pixel[image->channel_map[BlackPixelChannel].offset]=
859 ClampToQuantum(pixel_info->black);
860 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
861 pixel[image->channel_map[AlphaPixelChannel].offset]=
862 pixel_info->alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
863 ClampToQuantum(pixel_info->alpha);
866static inline void SetPixelL(
const Image *magick_restrict image,
const Quantum L,
867 Quantum *magick_restrict pixel)
869 if (image->channel_map[LPixelChannel].traits != UndefinedPixelTrait)
870 pixel[image->channel_map[LPixelChannel].offset]=L;
873static inline void SetPixelMagenta(
const Image *magick_restrict image,
874 const Quantum magenta,Quantum *magick_restrict pixel)
876 pixel[image->channel_map[MagentaPixelChannel].offset]=magenta;
879static inline void SetPixelMagentaTraits(Image *image,
const PixelTrait traits)
881 image->channel_map[MagentaPixelChannel].traits=traits;
884static inline void SetPixelMeta(
const Image *magick_restrict image,
885 const Quantum red,Quantum *magick_restrict pixel)
887 pixel[image->channel_map[MetaPixelChannels].offset]=red;
890static inline void SetPixelMetaTraits(Image *image,
const PixelTrait traits)
892 image->channel_map[MetaPixelChannels].traits=traits;
895static inline void SetPixelReadMask(
const Image *magick_restrict image,
896 const Quantum mask,Quantum *magick_restrict pixel)
898 if (image->channel_map[ReadMaskPixelChannel].traits != UndefinedPixelTrait)
899 pixel[image->channel_map[ReadMaskPixelChannel].offset]=mask;
902static inline void SetPixelMetacontentExtent(Image *image,
const size_t extent)
904 image->metacontent_extent=extent;
907static inline void SetPixelOpacity(
const Image *magick_restrict image,
908 const Quantum alpha,Quantum *magick_restrict pixel)
910 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
911 pixel[image->channel_map[AlphaPixelChannel].offset]=QuantumRange-alpha;
914static inline void SetPixelRed(
const Image *magick_restrict image,
915 const Quantum red,Quantum *magick_restrict pixel)
917 pixel[image->channel_map[RedPixelChannel].offset]=red;
920static inline void SetPixelRedTraits(Image *image,
const PixelTrait traits)
922 image->channel_map[RedPixelChannel].traits=traits;
925static inline void SetPixelWriteMask(
const Image *magick_restrict image,
926 const Quantum mask,Quantum *magick_restrict pixel)
928 if (image->channel_map[WriteMaskPixelChannel].traits != UndefinedPixelTrait)
929 pixel[image->channel_map[WriteMaskPixelChannel].offset]=mask;
932static inline void SetPixelYellow(
const Image *magick_restrict image,
933 const Quantum yellow,Quantum *magick_restrict pixel)
935 pixel[image->channel_map[YellowPixelChannel].offset]=yellow;
938static inline void SetPixelYellowTraits(Image *image,
const PixelTrait traits)
940 image->channel_map[YellowPixelChannel].traits=traits;
943static inline void SetPixelY(
const Image *magick_restrict image,
944 const Quantum y,Quantum *magick_restrict pixel)
946 pixel[image->channel_map[YPixelChannel].offset]=y;
949static inline void SetPixelYTraits(Image *image,
const PixelTrait traits)
951 image->channel_map[YPixelChannel].traits=traits;
954#if defined(__cplusplus) || defined(c_plusplus)