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 GetPixela(const Image *restrict image,
35 const Quantum *restrict pixel)
37 return(pixel[image->channel_map[aPixelChannel].offset]);
40 static inline Quantum GetPixelAlpha(const Image *restrict image,
41 const Quantum *restrict pixel)
43 if (image->channel_map[AlphaPixelChannel].traits == UndefinedPixelTrait)
45 return(pixel[image->channel_map[AlphaPixelChannel].offset]);
48 static inline PixelTrait GetPixelAlphaTraits(const Image *restrict image)
50 return(image->channel_map[AlphaPixelChannel].traits);
53 static inline Quantum GetPixelb(const Image *restrict image,
54 const Quantum *restrict pixel)
56 return(pixel[image->channel_map[bPixelChannel].offset]);
59 static inline Quantum GetPixelBlack(const Image *restrict image,
60 const Quantum *restrict pixel)
62 if (image->channel_map[BlackPixelChannel].traits == UndefinedPixelTrait)
64 return(pixel[image->channel_map[BlackPixelChannel].offset]);
67 static inline PixelTrait GetPixelBlackTraits(const Image *restrict image)
69 return(image->channel_map[BlackPixelChannel].traits);
72 static inline Quantum GetPixelBlue(const Image *restrict image,
73 const Quantum *restrict pixel)
75 return(pixel[image->channel_map[BluePixelChannel].offset]);
78 static inline PixelTrait GetPixelBlueTraits(const Image *restrict image)
80 return(image->channel_map[BluePixelChannel].traits);
83 static inline Quantum GetPixelCb(const Image *restrict image,
84 const Quantum *restrict pixel)
86 return(pixel[image->channel_map[CbPixelChannel].offset]);
89 static inline PixelTrait GetPixelCbTraits(const Image *restrict image)
91 return(image->channel_map[CbPixelChannel].traits);
94 static inline Quantum GetPixelChannel(const Image *restrict image,
95 const PixelChannel channel,const Quantum *restrict pixel)
97 if (image->channel_map[channel].traits == UndefinedPixelTrait)
99 return(pixel[image->channel_map[channel].offset]);
102 static inline PixelChannel GetPixelChannelChannel(const Image *restrict image,
103 const ssize_t offset)
105 return(image->channel_map[offset].channel);
108 static inline ssize_t GetPixelChannelOffset(const Image *restrict image,
109 const PixelChannel channel)
111 return(image->channel_map[channel].offset);
114 static inline PixelTrait GetPixelChannelTraits(const Image *restrict image,
115 const PixelChannel channel)
117 return(image->channel_map[channel].traits);
120 static inline size_t GetPixelChannels(const Image *restrict image)
122 return(image->number_channels);
125 static inline Quantum GetPixelCr(const Image *restrict image,
126 const Quantum *restrict pixel)
128 return(pixel[image->channel_map[CrPixelChannel].offset]);
131 static inline PixelTrait GetPixelCrTraits(const Image *restrict image)
133 return(image->channel_map[CrPixelChannel].traits);
136 static inline Quantum GetPixelCyan(const Image *restrict image,
137 const Quantum *restrict pixel)
139 return(pixel[image->channel_map[CyanPixelChannel].offset]);
142 static inline PixelTrait GetPixelCyanTraits(const Image *restrict image)
144 return(image->channel_map[CyanPixelChannel].traits);
147 static inline Quantum GetPixelGray(const Image *restrict image,
148 const Quantum *restrict pixel)
150 return(pixel[image->channel_map[GrayPixelChannel].offset]);
153 static inline PixelTrait GetPixelGrayTraits(const Image *restrict image)
155 return(image->channel_map[GrayPixelChannel].traits);
158 static inline Quantum GetPixelGreen(const Image *restrict image,
159 const Quantum *restrict pixel)
161 return(pixel[image->channel_map[GreenPixelChannel].offset]);
164 static inline PixelTrait GetPixelGreenTraits(const Image *restrict image)
166 return(image->channel_map[GreenPixelChannel].traits);
169 static inline Quantum GetPixelIndex(const Image *restrict image,
170 const Quantum *restrict pixel)
172 if (image->channel_map[IndexPixelChannel].traits == UndefinedPixelTrait)
174 return(pixel[image->channel_map[IndexPixelChannel].offset]);
177 static inline PixelTrait GetPixelIndexTraits(const Image *restrict image)
179 return(image->channel_map[IndexPixelChannel].traits);
182 static inline MagickRealType GetPixelInfoChannel(
183 const PixelInfo *restrict pixel_info,const PixelChannel channel)
187 case RedPixelChannel: return(pixel_info->red);
188 case GreenPixelChannel: return(pixel_info->green);
189 case BluePixelChannel: return(pixel_info->blue);
190 case BlackPixelChannel: return(pixel_info->black);
191 case AlphaPixelChannel: return(pixel_info->alpha);
192 case IndexPixelChannel: return(pixel_info->index);
193 default: return((MagickRealType) 0.0);
197 static inline MagickRealType GetPixelInfoIntensity(
198 const PixelInfo *restrict pixel_info)
200 if (pixel_info->colorspace == GRAYColorspace)
201 return(pixel_info->red);
202 return(0.212656f*pixel_info->red+0.715158f*pixel_info->green+0.072186f*
206 static inline MagickRealType GetPixelInfoLuma(const PixelInfo *restrict pixel)
213 if (pixel->colorspace == GRAYColorspace)
215 if (pixel->colorspace == sRGBColorspace)
216 return(0.212656f*pixel->red+0.715158f*pixel->green+0.072186f*pixel->blue);
217 red=EncodePixelGamma(pixel->red);
218 green=EncodePixelGamma(pixel->green);
219 blue=EncodePixelGamma(pixel->blue);
220 return(0.212656f*red+0.715158f*green+0.072186f*blue);
223 static inline MagickRealType GetPixelInfoLuminance(
224 const PixelInfo *restrict pixel)
231 if (pixel->colorspace == GRAYColorspace)
233 if (pixel->colorspace != sRGBColorspace)
234 return(0.212656f*pixel->red+0.715158f*pixel->green+0.072186f*pixel->blue);
235 red=DecodePixelGamma(pixel->red);
236 green=DecodePixelGamma(pixel->green);
237 blue=DecodePixelGamma(pixel->blue);
238 return(0.212656f*red+0.715158f*green+0.072186f*blue);
241 static inline Quantum GetPixelL(const Image *restrict image,
242 const Quantum *restrict pixel)
244 return(pixel[image->channel_map[LPixelChannel].offset]);
247 static inline MagickRealType GetPixelLuma(const Image *restrict image,
248 const Quantum *restrict pixel)
250 if (image->colorspace == GRAYColorspace)
251 return((MagickRealType) pixel[image->channel_map[GrayPixelChannel].offset]);
252 return(0.212656f*pixel[image->channel_map[RedPixelChannel].offset]+
253 0.715158f*pixel[image->channel_map[GreenPixelChannel].offset]+
254 0.072186f*pixel[image->channel_map[BluePixelChannel].offset]); /* Rec709 */
257 static inline MagickRealType GetPixelLuminance(const Image *restrict image,
258 const Quantum *restrict pixel)
265 if (image->colorspace == GRAYColorspace)
266 return((MagickRealType) pixel[image->channel_map[GrayPixelChannel].offset]);
267 if (image->colorspace != sRGBColorspace)
268 return(0.212656f*pixel[image->channel_map[RedPixelChannel].offset]+
269 0.715158f*pixel[image->channel_map[GreenPixelChannel].offset]+
270 0.072186f*pixel[image->channel_map[BluePixelChannel].offset]);
271 red=DecodePixelGamma((MagickRealType)
272 pixel[image->channel_map[RedPixelChannel].offset]);
273 green=DecodePixelGamma((MagickRealType)
274 pixel[image->channel_map[GreenPixelChannel].offset]);
275 blue=DecodePixelGamma((MagickRealType)
276 pixel[image->channel_map[BluePixelChannel].offset]);
277 return(0.212656f*red+0.715158f*green+0.072186f*blue); /* Rec709 */
280 static inline Quantum GetPixelMagenta(const Image *restrict image,
281 const Quantum *restrict pixel)
283 return(pixel[image->channel_map[MagentaPixelChannel].offset]);
286 static inline PixelTrait GetPixelMagentaTraits(const Image *restrict image)
288 return(image->channel_map[MagentaPixelChannel].traits);
291 static inline Quantum GetPixelReadMask(const Image *restrict image,
292 const Quantum *restrict pixel)
294 if (image->channel_map[ReadMaskPixelChannel].traits == UndefinedPixelTrait)
295 return((Quantum) QuantumRange);
296 return(pixel[image->channel_map[ReadMaskPixelChannel].offset]);
299 static inline Quantum GetPixelWriteMask(const Image *restrict image,
300 const Quantum *restrict pixel)
302 if (image->channel_map[WriteMaskPixelChannel].traits == UndefinedPixelTrait)
303 return((Quantum) QuantumRange);
304 return(pixel[image->channel_map[WriteMaskPixelChannel].offset]);
307 static inline PixelTrait GetPixelReadMaskTraits(const Image *restrict image)
309 return(image->channel_map[ReadMaskPixelChannel].traits);
312 static inline size_t GetPixelMetaChannels(const Image *restrict image)
314 return(image->number_meta_channels);
317 static inline size_t GetPixelMetacontentExtent(const Image *restrict image)
319 return(image->metacontent_extent);
322 static inline Quantum GetPixelOpacity(const Image *restrict image,
323 const Quantum *restrict pixel)
325 if (image->channel_map[AlphaPixelChannel].traits == UndefinedPixelTrait)
326 return(QuantumRange-OpaqueAlpha);
327 return(QuantumRange-pixel[image->channel_map[AlphaPixelChannel].offset]);
330 static inline Quantum GetPixelRed(const Image *restrict image,
331 const Quantum *restrict pixel)
333 return(pixel[image->channel_map[RedPixelChannel].offset]);
336 static inline PixelTrait GetPixelRedTraits(const Image *restrict image)
338 return(image->channel_map[RedPixelChannel].traits);
341 static inline void GetPixelInfoPixel(const Image *restrict image,
342 const Quantum *restrict pixel,PixelInfo *restrict pixel_info)
344 pixel_info->colorspace=image->colorspace;
345 pixel_info->fuzz=image->fuzz;
346 pixel_info->red=(MagickRealType)
347 pixel[image->channel_map[RedPixelChannel].offset];
348 pixel_info->green=(MagickRealType)
349 pixel[image->channel_map[GreenPixelChannel].offset];
350 pixel_info->blue=(MagickRealType)
351 pixel[image->channel_map[BluePixelChannel].offset];
352 pixel_info->black=0.0f;
353 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
354 pixel_info->black=(MagickRealType)
355 pixel[image->channel_map[BlackPixelChannel].offset];
356 pixel_info->alpha=(MagickRealType) OpaqueAlpha;
357 pixel_info->alpha_trait=UndefinedPixelTrait;
358 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
360 pixel_info->alpha=(MagickRealType)
361 pixel[image->channel_map[AlphaPixelChannel].offset];
362 pixel_info->alpha_trait=BlendPixelTrait;
364 pixel_info->index=0.0f;
365 if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
366 pixel_info->index=(MagickRealType)
367 pixel[image->channel_map[IndexPixelChannel].offset];
370 static inline PixelTrait GetPixelTraits(const Image *restrict image,
371 const PixelChannel channel)
373 return(image->channel_map[channel].traits);
376 static inline Quantum GetPixelY(const Image *restrict image,
377 const Quantum *restrict pixel)
379 return(pixel[image->channel_map[YPixelChannel].offset]);
382 static inline PixelTrait GetPixelYTraits(const Image *restrict image)
384 return(image->channel_map[YPixelChannel].traits);
387 static inline Quantum GetPixelYellow(const Image *restrict image,
388 const Quantum *restrict pixel)
390 return(pixel[image->channel_map[YellowPixelChannel].offset]);
393 static inline PixelTrait GetPixelYellowTraits(const Image *restrict image)
395 return(image->channel_map[YellowPixelChannel].traits);
398 static inline MagickRealType AbsolutePixelValue(const MagickRealType x)
400 return(x < 0.0f ? -x : x);
403 static inline MagickBooleanType IsPixelAtDepth(const Quantum pixel,
404 const QuantumAny range)
409 #if !defined(MAGICKCORE_HDRI_SUPPORT)
410 quantum=(Quantum) (((MagickRealType) QuantumRange*((QuantumAny)
411 (((MagickRealType) range*pixel)/QuantumRange+0.5)))/range+0.5);
413 quantum=(Quantum) (((MagickRealType) QuantumRange*((QuantumAny)
414 (((MagickRealType) range*pixel)/QuantumRange+0.5)))/range);
416 return(pixel == quantum ? MagickTrue : MagickFalse);
419 static inline MagickBooleanType IsPixelEquivalent(const Image *restrict image,
420 const Quantum *restrict p,const PixelInfo *restrict q)
427 red=(MagickRealType) p[image->channel_map[RedPixelChannel].offset];
428 green=(MagickRealType) p[image->channel_map[GreenPixelChannel].offset];
429 blue=(MagickRealType) p[image->channel_map[BluePixelChannel].offset];
430 if ((AbsolutePixelValue(red-q->red) < MagickEpsilon) &&
431 (AbsolutePixelValue(green-q->green) < MagickEpsilon) &&
432 (AbsolutePixelValue(blue-q->blue) < MagickEpsilon))
437 static inline MagickBooleanType IsPixelGray(const Image *restrict image,
438 const Quantum *restrict pixel)
445 red=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset];
446 green=(MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset];
447 blue=(MagickRealType) pixel[image->channel_map[BluePixelChannel].offset];
448 if ((AbsolutePixelValue(red-green) < MagickEpsilon) &&
449 (AbsolutePixelValue(green-blue) < MagickEpsilon))
454 static inline MagickBooleanType IsPixelInfoEquivalent(
455 const PixelInfo *restrict p,const PixelInfo *restrict q)
457 if ((p->alpha_trait != UndefinedPixelTrait) &&
458 (q->alpha_trait == UndefinedPixelTrait) &&
459 (AbsolutePixelValue(p->alpha-OpaqueAlpha) >= MagickEpsilon))
461 if ((q->alpha_trait != UndefinedPixelTrait) &&
462 (p->alpha_trait == UndefinedPixelTrait) &&
463 (AbsolutePixelValue(q->alpha-OpaqueAlpha)) >= MagickEpsilon)
465 if ((p->alpha_trait != UndefinedPixelTrait) &&
466 (q->alpha_trait != UndefinedPixelTrait))
468 if (AbsolutePixelValue(p->alpha-q->alpha) >= MagickEpsilon)
470 if (AbsolutePixelValue(p->alpha-TransparentAlpha) < MagickEpsilon)
473 if (AbsolutePixelValue(p->red-q->red) >= MagickEpsilon)
475 if (AbsolutePixelValue(p->green-q->green) >= MagickEpsilon)
477 if (AbsolutePixelValue(p->blue-q->blue) >= MagickEpsilon)
479 if ((p->colorspace == CMYKColorspace) &&
480 (AbsolutePixelValue(p->black-q->black) >= MagickEpsilon))
485 static inline MagickBooleanType IsPixelMonochrome(const Image *restrict image,
486 const Quantum *restrict pixel)
493 red=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset];
494 if ((AbsolutePixelValue(red) >= MagickEpsilon) ||
495 (AbsolutePixelValue(red-QuantumRange) >= MagickEpsilon))
497 green=(MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset];
498 blue=(MagickRealType) pixel[image->channel_map[BluePixelChannel].offset];
499 if ((AbsolutePixelValue(red-green) < MagickEpsilon) &&
500 (AbsolutePixelValue(green-blue) < MagickEpsilon))
505 static inline MagickBooleanType IsPixelInfoGray(
506 const PixelInfo *restrict pixel_info)
508 if ((pixel_info->colorspace != GRAYColorspace) &&
509 (pixel_info->colorspace != RGBColorspace))
511 if ((AbsolutePixelValue(pixel_info->red-pixel_info->green) < MagickEpsilon) &&
512 (AbsolutePixelValue(pixel_info->green-pixel_info->blue) < MagickEpsilon))
517 static inline MagickBooleanType IsPixelInfoMonochrome(
518 const PixelInfo *restrict pixel_info)
520 if ((pixel_info->colorspace != GRAYColorspace) &&
521 (pixel_info->colorspace != RGBColorspace))
523 if ((AbsolutePixelValue(pixel_info->red) >= MagickEpsilon) ||
524 (AbsolutePixelValue(pixel_info->red-QuantumRange) >= MagickEpsilon))
526 if ((AbsolutePixelValue(pixel_info->red-pixel_info->green) < MagickEpsilon) &&
527 (AbsolutePixelValue(pixel_info->green-pixel_info->blue) < MagickEpsilon))
532 static inline void SetPixela(const Image *restrict image,
533 const Quantum a,Quantum *restrict pixel)
535 if (image->channel_map[aPixelChannel].traits != UndefinedPixelTrait)
536 pixel[image->channel_map[aPixelChannel].offset]=a;
539 static inline void SetPixelAlpha(const Image *restrict image,
540 const Quantum alpha,Quantum *restrict pixel)
542 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
543 pixel[image->channel_map[AlphaPixelChannel].offset]=alpha;
546 static inline void SetPixelAlphaTraits(Image *image,const PixelTrait traits)
548 image->channel_map[AlphaPixelChannel].traits=traits;
551 static inline void SetPixelb(const Image *restrict image,
552 const Quantum b,Quantum *restrict pixel)
554 if (image->channel_map[bPixelChannel].traits != UndefinedPixelTrait)
555 pixel[image->channel_map[bPixelChannel].offset]=b;
558 static inline void SetPixelBackgoundColor(const Image *restrict image,
559 Quantum *restrict pixel)
564 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
566 pixel[image->channel_map[RedPixelChannel].offset]=
567 ClampToQuantum(image->background_color.red);
568 pixel[image->channel_map[GreenPixelChannel].offset]=
569 ClampToQuantum(image->background_color.green);
570 pixel[image->channel_map[BluePixelChannel].offset]=
571 ClampToQuantum(image->background_color.blue);
572 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
573 pixel[image->channel_map[BlackPixelChannel].offset]=
574 ClampToQuantum(image->background_color.black);
575 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
576 pixel[image->channel_map[AlphaPixelChannel].offset]=
577 image->background_color.alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
578 ClampToQuantum(image->background_color.alpha);
581 static inline void SetPixelBlack(const Image *restrict image,
582 const Quantum black,Quantum *restrict pixel)
584 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
585 pixel[image->channel_map[BlackPixelChannel].offset]=black;
588 static inline void SetPixelBlackTraits(Image *image,const PixelTrait traits)
590 image->channel_map[BlackPixelChannel].traits=traits;
593 static inline void SetPixelBlue(const Image *restrict image,const Quantum blue,
594 Quantum *restrict pixel)
596 pixel[image->channel_map[BluePixelChannel].offset]=blue;
599 static inline void SetPixelBlueTraits(Image *image,const PixelTrait traits)
601 image->channel_map[BluePixelChannel].traits=traits;
604 static inline void SetPixelCb(const Image *restrict image,const Quantum cb,
605 Quantum *restrict pixel)
607 pixel[image->channel_map[CbPixelChannel].offset]=cb;
610 static inline void SetPixelCbTraits(Image *image,const PixelTrait traits)
612 image->channel_map[CbPixelChannel].traits=traits;
615 static inline void SetPixelChannel(const Image *restrict image,
616 const PixelChannel channel,const Quantum quantum,Quantum *restrict pixel)
618 if (image->channel_map[channel].traits != UndefinedPixelTrait)
619 pixel[image->channel_map[channel].offset]=quantum;
622 static inline void SetPixelChannelAttributes(const Image *restrict image,
623 const PixelChannel channel,const PixelTrait traits,const ssize_t offset)
625 image->channel_map[offset].channel=channel;
626 image->channel_map[channel].offset=offset;
627 image->channel_map[channel].traits=traits;
630 static inline void SetPixelChannelChannel(const Image *restrict image,
631 const PixelChannel channel,const ssize_t offset)
633 image->channel_map[offset].channel=channel;
634 image->channel_map[channel].offset=offset;
637 static inline void SetPixelChannels(Image *image,const size_t number_channels)
639 image->number_channels=number_channels;
642 static inline void SetPixelChannelTraits(Image *image,
643 const PixelChannel channel,const PixelTrait traits)
645 image->channel_map[channel].traits=traits;
648 static inline void SetPixelCr(const Image *restrict image,const Quantum cr,
649 Quantum *restrict pixel)
651 pixel[image->channel_map[CrPixelChannel].offset]=cr;
654 static inline void SetPixelCrTraits(Image *image,const PixelTrait traits)
656 image->channel_map[CrPixelChannel].traits=traits;
659 static inline void SetPixelCyan(const Image *restrict image,const Quantum cyan,
660 Quantum *restrict pixel)
662 pixel[image->channel_map[CyanPixelChannel].offset]=cyan;
665 static inline void SetPixelGray(const Image *restrict image,const Quantum gray,
666 Quantum *restrict pixel)
668 pixel[image->channel_map[GrayPixelChannel].offset]=gray;
671 static inline void SetPixelGrayTraits(Image *image,const PixelTrait traits)
673 image->channel_map[GrayPixelChannel].traits=traits;
676 static inline void SetPixelGreen(const Image *restrict image,
677 const Quantum green,Quantum *restrict pixel)
679 pixel[image->channel_map[GreenPixelChannel].offset]=green;
682 static inline void SetPixelGreenTraits(Image *image,const PixelTrait traits)
684 image->channel_map[GreenPixelChannel].traits=traits;
687 static inline void SetPixelIndex(const Image *restrict image,
688 const Quantum index,Quantum *restrict pixel)
690 if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
691 pixel[image->channel_map[IndexPixelChannel].offset]=index;
694 static inline void SetPixelIndexTraits(Image *image,const PixelTrait traits)
696 image->channel_map[IndexPixelChannel].traits=traits;
699 static inline void SetPixelInfoPixel(const Image *restrict image,
700 const PixelInfo *restrict pixel_info,Quantum *restrict pixel)
702 pixel[image->channel_map[RedPixelChannel].offset]=
703 ClampToQuantum(pixel_info->red);
704 pixel[image->channel_map[GreenPixelChannel].offset]=
705 ClampToQuantum(pixel_info->green);
706 pixel[image->channel_map[BluePixelChannel].offset]=
707 ClampToQuantum(pixel_info->blue);
708 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
709 pixel[image->channel_map[BlackPixelChannel].offset]=
710 ClampToQuantum(pixel_info->black);
711 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
712 pixel[image->channel_map[AlphaPixelChannel].offset]=
713 pixel_info->alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
714 ClampToQuantum(pixel_info->alpha);
717 static inline void SetPixelL(const Image *restrict image,const Quantum L,
718 Quantum *restrict pixel)
720 if (image->channel_map[LPixelChannel].traits != UndefinedPixelTrait)
721 pixel[image->channel_map[LPixelChannel].offset]=L;
724 static inline void SetPixelMagenta(const Image *restrict image,
725 const Quantum magenta,Quantum *restrict pixel)
727 pixel[image->channel_map[MagentaPixelChannel].offset]=magenta;
730 static inline void SetPixelMagentaTraits(Image *image,const PixelTrait traits)
732 image->channel_map[MagentaPixelChannel].traits=traits;
735 static inline void SetPixelReadMask(const Image *restrict image,
736 const Quantum mask,Quantum *restrict pixel)
738 if (image->channel_map[ReadMaskPixelChannel].traits != UndefinedPixelTrait)
739 pixel[image->channel_map[ReadMaskPixelChannel].offset]=mask;
742 static inline void SetPixelWriteMask(const Image *restrict image,
743 const Quantum mask,Quantum *restrict pixel)
745 if (image->channel_map[WriteMaskPixelChannel].traits != UndefinedPixelTrait)
746 pixel[image->channel_map[WriteMaskPixelChannel].offset]=mask;
749 static inline void SetPixelMetacontentExtent(Image *image,const size_t extent)
751 image->metacontent_extent=extent;
754 static inline void SetPixelOpacity(const Image *restrict image,
755 const Quantum alpha,Quantum *restrict pixel)
757 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
758 pixel[image->channel_map[AlphaPixelChannel].offset]=QuantumRange-alpha;
761 static inline void SetPixelRed(const Image *restrict image,const Quantum red,
762 Quantum *restrict pixel)
764 pixel[image->channel_map[RedPixelChannel].offset]=red;
767 static inline void SetPixelRedTraits(Image *image,const PixelTrait traits)
769 image->channel_map[RedPixelChannel].traits=traits;
772 static inline void SetPixelYellow(const Image *restrict image,
773 const Quantum yellow,Quantum *restrict pixel)
775 pixel[image->channel_map[YellowPixelChannel].offset]=yellow;
778 static inline void SetPixelYellowTraits(Image *image,const PixelTrait traits)
780 image->channel_map[YellowPixelChannel].traits=traits;
783 static inline void SetPixelY(const Image *restrict image,const Quantum y,
784 Quantum *restrict pixel)
786 pixel[image->channel_map[YPixelChannel].offset]=y;
789 static inline void SetPixelYTraits(Image *image,const PixelTrait traits)
791 image->channel_map[YPixelChannel].traits=traits;
794 #if defined(__cplusplus) || defined(c_plusplus)