2 Copyright 1999-2015 ImageMagick Studio LLC, a non-profit organization
3 dedicated to making software imaging solutions freely available.
5 You may not use this file except in compliance with the License.
6 obtain a copy of the License at
8 http://www.imagemagick.org/script/license.php
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
16 MagickCore pixel accessor methods.
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"
28 #if defined(__cplusplus) || defined(c_plusplus)
34 static inline Quantum ClampPixel(const MagickRealType value)
38 if (value >= (MagickRealType) QuantumRange)
39 return((Quantum) QuantumRange);
40 #if !defined(MAGICKCORE_HDRI_SUPPORT)
41 return((Quantum) (value+0.5f));
43 return((Quantum) value);
47 static inline Quantum GetPixela(const Image *restrict image,
48 const Quantum *restrict pixel)
50 return(pixel[image->channel_map[aPixelChannel].offset]);
53 static inline Quantum GetPixelAlpha(const Image *restrict image,
54 const Quantum *restrict pixel)
56 if (image->channel_map[AlphaPixelChannel].traits == UndefinedPixelTrait)
58 return(pixel[image->channel_map[AlphaPixelChannel].offset]);
61 static inline PixelTrait GetPixelAlphaTraits(const Image *restrict image)
63 return(image->channel_map[AlphaPixelChannel].traits);
66 static inline Quantum GetPixelb(const Image *restrict image,
67 const Quantum *restrict pixel)
69 return(pixel[image->channel_map[bPixelChannel].offset]);
72 static inline Quantum GetPixelBlack(const Image *restrict image,
73 const Quantum *restrict pixel)
75 if (image->channel_map[BlackPixelChannel].traits == UndefinedPixelTrait)
77 return(pixel[image->channel_map[BlackPixelChannel].offset]);
80 static inline PixelTrait GetPixelBlackTraits(const Image *restrict image)
82 return(image->channel_map[BlackPixelChannel].traits);
85 static inline Quantum GetPixelBlue(const Image *restrict image,
86 const Quantum *restrict pixel)
88 return(pixel[image->channel_map[BluePixelChannel].offset]);
91 static inline PixelTrait GetPixelBlueTraits(const Image *restrict image)
93 return(image->channel_map[BluePixelChannel].traits);
96 static inline Quantum GetPixelCb(const Image *restrict image,
97 const Quantum *restrict pixel)
99 return(pixel[image->channel_map[CbPixelChannel].offset]);
102 static inline PixelTrait GetPixelCbTraits(const Image *restrict image)
104 return(image->channel_map[CbPixelChannel].traits);
107 static inline Quantum GetPixelChannel(const Image *restrict image,
108 const PixelChannel channel,const Quantum *restrict pixel)
110 if (image->channel_map[channel].traits == UndefinedPixelTrait)
112 return(pixel[image->channel_map[channel].offset]);
115 static inline PixelChannel GetPixelChannelChannel(const Image *restrict image,
116 const ssize_t offset)
118 return(image->channel_map[offset].channel);
121 static inline ssize_t GetPixelChannelOffset(const Image *restrict image,
122 const PixelChannel channel)
124 return(image->channel_map[channel].offset);
127 static inline PixelTrait GetPixelChannelTraits(const Image *restrict image,
128 const PixelChannel channel)
130 return(image->channel_map[channel].traits);
133 static inline size_t GetPixelChannels(const Image *restrict image)
135 return(image->number_channels);
138 static inline Quantum GetPixelCr(const Image *restrict image,
139 const Quantum *restrict pixel)
141 return(pixel[image->channel_map[CrPixelChannel].offset]);
144 static inline PixelTrait GetPixelCrTraits(const Image *restrict image)
146 return(image->channel_map[CrPixelChannel].traits);
149 static inline Quantum GetPixelCyan(const Image *restrict image,
150 const Quantum *restrict pixel)
152 return(pixel[image->channel_map[CyanPixelChannel].offset]);
155 static inline PixelTrait GetPixelCyanTraits(const Image *restrict image)
157 return(image->channel_map[CyanPixelChannel].traits);
160 static inline Quantum GetPixelGray(const Image *restrict image,
161 const Quantum *restrict pixel)
163 return(pixel[image->channel_map[GrayPixelChannel].offset]);
166 static inline PixelTrait GetPixelGrayTraits(const Image *restrict image)
168 return(image->channel_map[GrayPixelChannel].traits);
171 static inline Quantum GetPixelGreen(const Image *restrict image,
172 const Quantum *restrict pixel)
174 return(pixel[image->channel_map[GreenPixelChannel].offset]);
177 static inline PixelTrait GetPixelGreenTraits(const Image *restrict image)
179 return(image->channel_map[GreenPixelChannel].traits);
182 static inline Quantum GetPixelIndex(const Image *restrict image,
183 const Quantum *restrict pixel)
185 if (image->channel_map[IndexPixelChannel].traits == UndefinedPixelTrait)
187 return(pixel[image->channel_map[IndexPixelChannel].offset]);
190 static inline PixelTrait GetPixelIndexTraits(const Image *restrict image)
192 return(image->channel_map[IndexPixelChannel].traits);
195 static inline MagickRealType GetPixelInfoChannel(
196 const PixelInfo *restrict pixel_info,const PixelChannel channel)
200 case RedPixelChannel: return(pixel_info->red);
201 case GreenPixelChannel: return(pixel_info->green);
202 case BluePixelChannel: return(pixel_info->blue);
203 case BlackPixelChannel: return(pixel_info->black);
204 case AlphaPixelChannel: return(pixel_info->alpha);
205 case IndexPixelChannel: return(pixel_info->index);
206 default: return((MagickRealType) 0.0);
210 static inline double PerceptibleReciprocal(const double x)
216 Return 1/x where x is perceptible (not unlimited or infinitesimal).
218 sign=x < 0.0 ? -1.0 : 1.0;
219 if ((sign*x) >= MagickEpsilon)
221 return(sign/MagickEpsilon);
224 static inline MagickRealType GetPixelInfoLuma(const PixelInfo *restrict pixel)
229 if (pixel->colorspace == sRGBColorspace)
231 intensity=(MagickRealType) (0.212656f*pixel->red+0.715158f*pixel->green+
232 0.072186f*pixel->blue);
235 intensity=(MagickRealType) (0.212656f*EncodePixelGamma(pixel->red)+
236 0.715158f*EncodePixelGamma(pixel->green)+
237 0.072186f*EncodePixelGamma(pixel->blue));
241 static inline MagickRealType GetPixelInfoLuminance(
242 const PixelInfo *restrict pixel)
247 if (pixel->colorspace != sRGBColorspace)
249 intensity=(MagickRealType) (0.212656f*pixel->red+0.715158f*pixel->green+
250 0.072186f*pixel->blue);
253 intensity=(MagickRealType) (0.212656f*DecodePixelGamma(pixel->red)+
254 0.715158f*DecodePixelGamma(pixel->green)+
255 0.072186f*DecodePixelGamma(pixel->blue));
259 static inline Quantum GetPixelL(const Image *restrict image,
260 const Quantum *restrict pixel)
262 return(pixel[image->channel_map[LPixelChannel].offset]);
265 static inline MagickRealType GetPixelLuma(const Image *restrict image,
266 const Quantum *restrict pixel)
271 intensity=(MagickRealType) (
272 0.212656f*pixel[image->channel_map[RedPixelChannel].offset]+
273 0.715158f*pixel[image->channel_map[GreenPixelChannel].offset]+
274 0.072186f*pixel[image->channel_map[BluePixelChannel].offset]);
278 static inline MagickRealType GetPixelLuminance(const Image *restrict image,
279 const Quantum *restrict pixel)
284 if (image->colorspace != sRGBColorspace)
286 intensity=(MagickRealType) (
287 0.212656f*pixel[image->channel_map[RedPixelChannel].offset]+
288 0.715158f*pixel[image->channel_map[GreenPixelChannel].offset]+
289 0.072186f*pixel[image->channel_map[BluePixelChannel].offset]);
292 intensity=(MagickRealType) (0.212656f*DecodePixelGamma((MagickRealType)
293 pixel[image->channel_map[RedPixelChannel].offset])+0.715158f*
294 DecodePixelGamma((MagickRealType)
295 pixel[image->channel_map[GreenPixelChannel].offset])+0.072186f*
296 DecodePixelGamma((MagickRealType)
297 pixel[image->channel_map[BluePixelChannel].offset]));
301 static inline Quantum GetPixelMagenta(const Image *restrict image,
302 const Quantum *restrict pixel)
304 return(pixel[image->channel_map[MagentaPixelChannel].offset]);
307 static inline PixelTrait GetPixelMagentaTraits(const Image *restrict image)
309 return(image->channel_map[MagentaPixelChannel].traits);
312 static inline Quantum GetPixelReadMask(const Image *restrict image,
313 const Quantum *restrict pixel)
315 if (image->channel_map[ReadMaskPixelChannel].traits == UndefinedPixelTrait)
316 return((Quantum) QuantumRange);
317 return(pixel[image->channel_map[ReadMaskPixelChannel].offset]);
320 static inline Quantum GetPixelWriteMask(const Image *restrict image,
321 const Quantum *restrict pixel)
323 if (image->channel_map[WriteMaskPixelChannel].traits == UndefinedPixelTrait)
324 return((Quantum) QuantumRange);
325 return(pixel[image->channel_map[WriteMaskPixelChannel].offset]);
328 static inline PixelTrait GetPixelReadMaskTraits(const Image *restrict image)
330 return(image->channel_map[ReadMaskPixelChannel].traits);
333 static inline size_t GetPixelMetaChannels(const Image *restrict image)
335 return(image->number_meta_channels);
338 static inline size_t GetPixelMetacontentExtent(const Image *restrict image)
340 return(image->metacontent_extent);
343 static inline Quantum GetPixelOpacity(const Image *restrict image,
344 const Quantum *restrict pixel)
346 if (image->channel_map[AlphaPixelChannel].traits != BlendPixelTrait)
347 return(QuantumRange-OpaqueAlpha);
348 return(QuantumRange-pixel[image->channel_map[AlphaPixelChannel].offset]);
351 static inline Quantum GetPixelRed(const Image *restrict image,
352 const Quantum *restrict pixel)
354 return(pixel[image->channel_map[RedPixelChannel].offset]);
357 static inline PixelTrait GetPixelRedTraits(const Image *restrict image)
359 return(image->channel_map[RedPixelChannel].traits);
362 static inline void GetPixelInfoPixel(const Image *restrict image,
363 const Quantum *restrict pixel,PixelInfo *restrict pixel_info)
365 pixel_info->storage_class=image->storage_class;
366 pixel_info->colorspace=image->colorspace;
367 pixel_info->fuzz=image->fuzz;
368 pixel_info->depth=image->depth;
369 pixel_info->red=(MagickRealType)
370 pixel[image->channel_map[RedPixelChannel].offset];
371 pixel_info->green=(MagickRealType)
372 pixel[image->channel_map[GreenPixelChannel].offset];
373 pixel_info->blue=(MagickRealType)
374 pixel[image->channel_map[BluePixelChannel].offset];
375 pixel_info->black=0.0f;
376 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
377 pixel_info->black=(MagickRealType)
378 pixel[image->channel_map[BlackPixelChannel].offset];
379 pixel_info->alpha=(MagickRealType) OpaqueAlpha;
380 pixel_info->alpha_trait=UndefinedPixelTrait;
381 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
383 pixel_info->alpha=(MagickRealType)
384 pixel[image->channel_map[AlphaPixelChannel].offset];
385 pixel_info->alpha_trait=BlendPixelTrait;
387 pixel_info->index=0.0f;
388 if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
389 pixel_info->index=(MagickRealType)
390 pixel[image->channel_map[IndexPixelChannel].offset];
394 static inline PixelTrait GetPixelTraits(const Image *restrict image,
395 const PixelChannel channel)
397 return(image->channel_map[channel].traits);
400 static inline Quantum GetPixelY(const Image *restrict image,
401 const Quantum *restrict pixel)
403 return(pixel[image->channel_map[YPixelChannel].offset]);
406 static inline PixelTrait GetPixelYTraits(const Image *restrict image)
408 return(image->channel_map[YPixelChannel].traits);
411 static inline Quantum GetPixelYellow(const Image *restrict image,
412 const Quantum *restrict pixel)
414 return(pixel[image->channel_map[YellowPixelChannel].offset]);
417 static inline PixelTrait GetPixelYellowTraits(const Image *restrict image)
419 return(image->channel_map[YellowPixelChannel].traits);
422 static inline MagickRealType AbsolutePixelValue(const MagickRealType x)
424 return(x < 0.0f ? -x : x);
427 static inline MagickBooleanType IsPixelAtDepth(const Quantum pixel,
428 const QuantumAny range)
433 #if !defined(MAGICKCORE_HDRI_SUPPORT)
434 quantum=(Quantum) (((MagickRealType) QuantumRange*((QuantumAny)
435 (((MagickRealType) range*pixel)/QuantumRange+0.5)))/range+0.5);
437 quantum=(Quantum) (((MagickRealType) QuantumRange*((QuantumAny)
438 (((MagickRealType) range*pixel)/QuantumRange+0.5)))/range);
440 return(pixel == quantum ? MagickTrue : MagickFalse);
443 static inline MagickBooleanType IsPixelEquivalent(const Image *restrict image,
444 const Quantum *restrict p,const PixelInfo *restrict q)
449 value=(MagickRealType) p[image->channel_map[RedPixelChannel].offset];
450 if (AbsolutePixelValue(value-q->red) >= MagickEpsilon)
452 value=(MagickRealType) p[image->channel_map[GreenPixelChannel].offset];
453 if (AbsolutePixelValue(value-q->green) >= MagickEpsilon)
455 value=(MagickRealType) p[image->channel_map[BluePixelChannel].offset];
456 if (AbsolutePixelValue(value-q->blue) >= MagickEpsilon)
461 static inline MagickBooleanType IsPixelGray(const Image *restrict image,
462 const Quantum *restrict pixel)
468 red_green=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]-
469 pixel[image->channel_map[GreenPixelChannel].offset];
470 green_blue=(MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset]-
471 pixel[image->channel_map[BluePixelChannel].offset];
472 if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
473 (AbsolutePixelValue(green_blue) < MagickEpsilon))
478 static inline MagickBooleanType IsPixelInfoEquivalent(
479 const PixelInfo *restrict p,const PixelInfo *restrict q)
481 if ((p->alpha_trait != UndefinedPixelTrait) &&
482 (q->alpha_trait == UndefinedPixelTrait) &&
483 (AbsolutePixelValue(p->alpha-OpaqueAlpha) >= MagickEpsilon))
485 if ((q->alpha_trait != UndefinedPixelTrait) &&
486 (p->alpha_trait == UndefinedPixelTrait) &&
487 (AbsolutePixelValue(q->alpha-OpaqueAlpha)) >= MagickEpsilon)
489 if ((p->alpha_trait != UndefinedPixelTrait) &&
490 (q->alpha_trait != UndefinedPixelTrait))
492 if (AbsolutePixelValue(p->alpha-q->alpha) >= MagickEpsilon)
494 if (AbsolutePixelValue(p->alpha-TransparentAlpha) < MagickEpsilon)
497 if (AbsolutePixelValue(p->red-q->red) >= MagickEpsilon)
499 if (AbsolutePixelValue(p->green-q->green) >= MagickEpsilon)
501 if (AbsolutePixelValue(p->blue-q->blue) >= MagickEpsilon)
503 if ((p->colorspace == CMYKColorspace) &&
504 (AbsolutePixelValue(p->black-q->black) >= MagickEpsilon))
509 static inline MagickBooleanType IsPixelMonochrome(const Image *restrict image,
510 const Quantum *restrict pixel)
517 red=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset];
518 if ((AbsolutePixelValue(red) >= MagickEpsilon) &&
519 (AbsolutePixelValue(red-QuantumRange) >= MagickEpsilon))
521 red_green=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]-
522 pixel[image->channel_map[GreenPixelChannel].offset];
523 green_blue=(MagickRealType)
524 pixel[image->channel_map[GreenPixelChannel].offset]-
525 pixel[image->channel_map[BluePixelChannel].offset];
526 if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
527 (AbsolutePixelValue(green_blue) < MagickEpsilon))
532 static inline MagickBooleanType IsPixelInfoGray(
533 const PixelInfo *restrict pixel_info)
535 if ((pixel_info->colorspace != GRAYColorspace) &&
536 (pixel_info->colorspace != RGBColorspace))
538 if ((AbsolutePixelValue(pixel_info->red-pixel_info->green) < MagickEpsilon) &&
539 (AbsolutePixelValue(pixel_info->green-pixel_info->blue) < MagickEpsilon))
544 static inline MagickBooleanType IsPixelInfoMonochrome(
545 const PixelInfo *restrict pixel_info)
551 if ((pixel_info->colorspace != GRAYColorspace) &&
552 (pixel_info->colorspace != RGBColorspace))
554 if ((AbsolutePixelValue(pixel_info->red) >= MagickEpsilon) ||
555 (AbsolutePixelValue(pixel_info->red-QuantumRange) >= MagickEpsilon))
557 red_green=pixel_info->red-pixel_info->green;
558 green_blue=pixel_info->green-pixel_info->blue;
559 if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
560 (AbsolutePixelValue(green_blue) < MagickEpsilon))
565 static inline void SetPixela(const Image *restrict image,
566 const Quantum a,Quantum *restrict pixel)
568 if (image->channel_map[aPixelChannel].traits != UndefinedPixelTrait)
569 pixel[image->channel_map[aPixelChannel].offset]=a;
572 static inline void SetPixelAlpha(const Image *restrict image,
573 const Quantum alpha,Quantum *restrict pixel)
575 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
576 pixel[image->channel_map[AlphaPixelChannel].offset]=alpha;
579 static inline void SetPixelAlphaTraits(Image *image,const PixelTrait traits)
581 image->channel_map[AlphaPixelChannel].traits=traits;
584 static inline void SetPixelb(const Image *restrict image,const Quantum b,
585 Quantum *restrict pixel)
587 if (image->channel_map[bPixelChannel].traits != UndefinedPixelTrait)
588 pixel[image->channel_map[bPixelChannel].offset]=b;
591 static inline void SetPixelBackgoundColor(const Image *restrict image,
592 Quantum *restrict pixel)
597 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
599 pixel[image->channel_map[RedPixelChannel].offset]=
600 ClampToQuantum(image->background_color.red);
601 pixel[image->channel_map[GreenPixelChannel].offset]=
602 ClampToQuantum(image->background_color.green);
603 pixel[image->channel_map[BluePixelChannel].offset]=
604 ClampToQuantum(image->background_color.blue);
605 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
606 pixel[image->channel_map[BlackPixelChannel].offset]=
607 ClampToQuantum(image->background_color.black);
608 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
609 pixel[image->channel_map[AlphaPixelChannel].offset]=
610 image->background_color.alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
611 ClampToQuantum(image->background_color.alpha);
614 static inline void SetPixelBlack(const Image *restrict image,
615 const Quantum black,Quantum *restrict pixel)
617 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
618 pixel[image->channel_map[BlackPixelChannel].offset]=black;
621 static inline void SetPixelBlackTraits(Image *image,const PixelTrait traits)
623 image->channel_map[BlackPixelChannel].traits=traits;
626 static inline void SetPixelBlue(const Image *restrict image,const Quantum blue,
627 Quantum *restrict pixel)
629 pixel[image->channel_map[BluePixelChannel].offset]=blue;
632 static inline void SetPixelBlueTraits(Image *image,const PixelTrait traits)
634 image->channel_map[BluePixelChannel].traits=traits;
637 static inline void SetPixelCb(const Image *restrict image,const Quantum cb,
638 Quantum *restrict pixel)
640 pixel[image->channel_map[CbPixelChannel].offset]=cb;
643 static inline void SetPixelCbTraits(Image *image,const PixelTrait traits)
645 image->channel_map[CbPixelChannel].traits=traits;
648 static inline void SetPixelChannel(const Image *restrict image,
649 const PixelChannel channel,const Quantum quantum,Quantum *restrict pixel)
651 if (image->channel_map[channel].traits != UndefinedPixelTrait)
652 pixel[image->channel_map[channel].offset]=quantum;
655 static inline void SetPixelChannelAttributes(const Image *restrict image,
656 const PixelChannel channel,const PixelTrait traits,const ssize_t offset)
658 image->channel_map[offset].channel=channel;
659 image->channel_map[channel].offset=offset;
660 image->channel_map[channel].traits=traits;
663 static inline void SetPixelChannelChannel(const Image *restrict image,
664 const PixelChannel channel,const ssize_t offset)
666 image->channel_map[offset].channel=channel;
667 image->channel_map[channel].offset=offset;
670 static inline void SetPixelChannels(Image *image,const size_t number_channels)
672 image->number_channels=number_channels;
675 static inline void SetPixelChannelTraits(Image *image,
676 const PixelChannel channel,const PixelTrait traits)
678 image->channel_map[channel].traits=traits;
681 static inline void SetPixelCr(const Image *restrict image,const Quantum cr,
682 Quantum *restrict pixel)
684 pixel[image->channel_map[CrPixelChannel].offset]=cr;
687 static inline void SetPixelCrTraits(Image *image,const PixelTrait traits)
689 image->channel_map[CrPixelChannel].traits=traits;
692 static inline void SetPixelCyan(const Image *restrict image,const Quantum cyan,
693 Quantum *restrict pixel)
695 pixel[image->channel_map[CyanPixelChannel].offset]=cyan;
698 static inline void SetPixelGray(const Image *restrict image,const Quantum gray,
699 Quantum *restrict pixel)
701 pixel[image->channel_map[GrayPixelChannel].offset]=gray;
704 static inline void SetPixelGrayTraits(Image *image,const PixelTrait traits)
706 image->channel_map[GrayPixelChannel].traits=traits;
709 static inline void SetPixelGreen(const Image *restrict image,
710 const Quantum green,Quantum *restrict pixel)
712 pixel[image->channel_map[GreenPixelChannel].offset]=green;
715 static inline void SetPixelGreenTraits(Image *image,const PixelTrait traits)
717 image->channel_map[GreenPixelChannel].traits=traits;
720 static inline void SetPixelIndex(const Image *restrict image,
721 const Quantum index,Quantum *restrict pixel)
723 if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
724 pixel[image->channel_map[IndexPixelChannel].offset]=index;
727 static inline void SetPixelIndexTraits(Image *image,const PixelTrait traits)
729 image->channel_map[IndexPixelChannel].traits=traits;
732 static inline void SetPixelViaPixelInfo(const Image *restrict image,
733 const PixelInfo *restrict pixel_info,Quantum *restrict pixel)
735 pixel[image->channel_map[RedPixelChannel].offset]=
736 ClampToQuantum(pixel_info->red);
737 pixel[image->channel_map[GreenPixelChannel].offset]=
738 ClampToQuantum(pixel_info->green);
739 pixel[image->channel_map[BluePixelChannel].offset]=
740 ClampToQuantum(pixel_info->blue);
741 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
742 pixel[image->channel_map[BlackPixelChannel].offset]=
743 ClampToQuantum(pixel_info->black);
744 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
745 pixel[image->channel_map[AlphaPixelChannel].offset]=
746 pixel_info->alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
747 ClampToQuantum(pixel_info->alpha);
750 static inline void SetPixelL(const Image *restrict image,const Quantum L,
751 Quantum *restrict pixel)
753 if (image->channel_map[LPixelChannel].traits != UndefinedPixelTrait)
754 pixel[image->channel_map[LPixelChannel].offset]=L;
757 static inline void SetPixelMagenta(const Image *restrict image,
758 const Quantum magenta,Quantum *restrict pixel)
760 pixel[image->channel_map[MagentaPixelChannel].offset]=magenta;
763 static inline void SetPixelMagentaTraits(Image *image,const PixelTrait traits)
765 image->channel_map[MagentaPixelChannel].traits=traits;
768 static inline void SetPixelReadMask(const Image *restrict image,
769 const Quantum mask,Quantum *restrict pixel)
771 if (image->channel_map[ReadMaskPixelChannel].traits != UndefinedPixelTrait)
772 pixel[image->channel_map[ReadMaskPixelChannel].offset]=mask;
775 static inline void SetPixelWriteMask(const Image *restrict image,
776 const Quantum mask,Quantum *restrict pixel)
778 if (image->channel_map[WriteMaskPixelChannel].traits != UndefinedPixelTrait)
779 pixel[image->channel_map[WriteMaskPixelChannel].offset]=mask;
782 static inline void SetPixelMetacontentExtent(Image *image,const size_t extent)
784 image->metacontent_extent=extent;
787 static inline void SetPixelOpacity(const Image *restrict image,
788 const Quantum alpha,Quantum *restrict pixel)
790 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
791 pixel[image->channel_map[AlphaPixelChannel].offset]=QuantumRange-alpha;
794 static inline void SetPixelRed(const Image *restrict image,const Quantum red,
795 Quantum *restrict pixel)
797 pixel[image->channel_map[RedPixelChannel].offset]=red;
800 static inline void SetPixelRedTraits(Image *image,const PixelTrait traits)
802 image->channel_map[RedPixelChannel].traits=traits;
805 static inline void SetPixelYellow(const Image *restrict image,
806 const Quantum yellow,Quantum *restrict pixel)
808 pixel[image->channel_map[YellowPixelChannel].offset]=yellow;
811 static inline void SetPixelYellowTraits(Image *image,const PixelTrait traits)
813 image->channel_map[YellowPixelChannel].traits=traits;
816 static inline void SetPixelY(const Image *restrict image,const Quantum y,
817 Quantum *restrict pixel)
819 pixel[image->channel_map[YPixelChannel].offset]=y;
822 static inline void SetPixelYTraits(Image *image,const PixelTrait traits)
824 image->channel_map[YPixelChannel].traits=traits;
827 #if defined(__cplusplus) || defined(c_plusplus)