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 MagickRealType GetPixelInfoLuma(const PixelInfo *restrict pixel)
217 if (pixel->colorspace == GRAYColorspace)
219 if (pixel->colorspace == sRGBColorspace)
220 return(0.212656f*pixel->red+0.715158f*pixel->green+0.072186f*pixel->blue);
221 red=EncodePixelGamma(pixel->red);
222 green=EncodePixelGamma(pixel->green);
223 blue=EncodePixelGamma(pixel->blue);
224 return(0.212656f*red+0.715158f*green+0.072186f*blue);
227 static inline MagickRealType GetPixelInfoLuminance(
228 const PixelInfo *restrict pixel)
235 if (pixel->colorspace == GRAYColorspace)
237 if (pixel->colorspace != sRGBColorspace)
238 return(0.212656f*pixel->red+0.715158f*pixel->green+0.072186f*pixel->blue);
239 red=DecodePixelGamma(pixel->red);
240 green=DecodePixelGamma(pixel->green);
241 blue=DecodePixelGamma(pixel->blue);
242 return(0.212656f*red+0.715158f*green+0.072186f*blue);
245 static inline Quantum GetPixelL(const Image *restrict image,
246 const Quantum *restrict pixel)
248 return(pixel[image->channel_map[LPixelChannel].offset]);
251 static inline MagickRealType GetPixelLuma(const Image *restrict image,
252 const Quantum *restrict pixel)
254 if (image->colorspace == GRAYColorspace)
255 return((MagickRealType) pixel[image->channel_map[GrayPixelChannel].offset]);
256 return(0.212656f*pixel[image->channel_map[RedPixelChannel].offset]+
257 0.715158f*pixel[image->channel_map[GreenPixelChannel].offset]+
258 0.072186f*pixel[image->channel_map[BluePixelChannel].offset]); /* Rec709 */
261 static inline MagickRealType GetPixelLuminance(const Image *restrict image,
262 const Quantum *restrict pixel)
269 if (image->colorspace == GRAYColorspace)
270 return((MagickRealType) pixel[image->channel_map[GrayPixelChannel].offset]);
271 if (image->colorspace != sRGBColorspace)
272 return(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]);
275 red=DecodePixelGamma((MagickRealType)
276 pixel[image->channel_map[RedPixelChannel].offset]);
277 green=DecodePixelGamma((MagickRealType)
278 pixel[image->channel_map[GreenPixelChannel].offset]);
279 blue=DecodePixelGamma((MagickRealType)
280 pixel[image->channel_map[BluePixelChannel].offset]);
281 return(0.212656f*red+0.715158f*green+0.072186f*blue); /* Rec709 */
284 static inline Quantum GetPixelMagenta(const Image *restrict image,
285 const Quantum *restrict pixel)
287 return(pixel[image->channel_map[MagentaPixelChannel].offset]);
290 static inline PixelTrait GetPixelMagentaTraits(const Image *restrict image)
292 return(image->channel_map[MagentaPixelChannel].traits);
295 static inline Quantum GetPixelReadMask(const Image *restrict image,
296 const Quantum *restrict pixel)
298 if (image->channel_map[ReadMaskPixelChannel].traits == UndefinedPixelTrait)
299 return((Quantum) QuantumRange);
300 return(pixel[image->channel_map[ReadMaskPixelChannel].offset]);
303 static inline Quantum GetPixelWriteMask(const Image *restrict image,
304 const Quantum *restrict pixel)
306 if (image->channel_map[WriteMaskPixelChannel].traits == UndefinedPixelTrait)
307 return((Quantum) QuantumRange);
308 return(pixel[image->channel_map[WriteMaskPixelChannel].offset]);
311 static inline PixelTrait GetPixelReadMaskTraits(const Image *restrict image)
313 return(image->channel_map[ReadMaskPixelChannel].traits);
316 static inline size_t GetPixelMetaChannels(const Image *restrict image)
318 return(image->number_meta_channels);
321 static inline size_t GetPixelMetacontentExtent(const Image *restrict image)
323 return(image->metacontent_extent);
326 static inline Quantum GetPixelOpacity(const Image *restrict image,
327 const Quantum *restrict pixel)
329 if (image->channel_map[AlphaPixelChannel].traits != BlendPixelTrait)
330 return(QuantumRange-OpaqueAlpha);
331 return(QuantumRange-pixel[image->channel_map[AlphaPixelChannel].offset]);
334 static inline Quantum GetPixelRed(const Image *restrict image,
335 const Quantum *restrict pixel)
337 return(pixel[image->channel_map[RedPixelChannel].offset]);
340 static inline PixelTrait GetPixelRedTraits(const Image *restrict image)
342 return(image->channel_map[RedPixelChannel].traits);
345 static inline void GetPixelInfoPixel(const Image *restrict image,
346 const Quantum *restrict pixel,PixelInfo *restrict pixel_info)
348 pixel_info->colorspace=image->colorspace;
349 pixel_info->fuzz=image->fuzz;
350 pixel_info->red=(MagickRealType)
351 pixel[image->channel_map[RedPixelChannel].offset];
352 pixel_info->green=(MagickRealType)
353 pixel[image->channel_map[GreenPixelChannel].offset];
354 pixel_info->blue=(MagickRealType)
355 pixel[image->channel_map[BluePixelChannel].offset];
356 pixel_info->black=0.0f;
357 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
358 pixel_info->black=(MagickRealType)
359 pixel[image->channel_map[BlackPixelChannel].offset];
360 pixel_info->alpha=(MagickRealType) OpaqueAlpha;
361 pixel_info->alpha_trait=UndefinedPixelTrait;
362 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
364 pixel_info->alpha=(MagickRealType)
365 pixel[image->channel_map[AlphaPixelChannel].offset];
366 pixel_info->alpha_trait=BlendPixelTrait;
368 pixel_info->index=0.0f;
369 if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
370 pixel_info->index=(MagickRealType)
371 pixel[image->channel_map[IndexPixelChannel].offset];
374 static inline PixelTrait GetPixelTraits(const Image *restrict image,
375 const PixelChannel channel)
377 return(image->channel_map[channel].traits);
380 static inline Quantum GetPixelY(const Image *restrict image,
381 const Quantum *restrict pixel)
383 return(pixel[image->channel_map[YPixelChannel].offset]);
386 static inline PixelTrait GetPixelYTraits(const Image *restrict image)
388 return(image->channel_map[YPixelChannel].traits);
391 static inline Quantum GetPixelYellow(const Image *restrict image,
392 const Quantum *restrict pixel)
394 return(pixel[image->channel_map[YellowPixelChannel].offset]);
397 static inline PixelTrait GetPixelYellowTraits(const Image *restrict image)
399 return(image->channel_map[YellowPixelChannel].traits);
402 static inline MagickRealType AbsolutePixelValue(const MagickRealType x)
404 return(x < 0.0f ? -x : x);
407 static inline MagickBooleanType IsPixelAtDepth(const Quantum pixel,
408 const QuantumAny range)
413 #if !defined(MAGICKCORE_HDRI_SUPPORT)
414 quantum=(Quantum) (((MagickRealType) QuantumRange*((QuantumAny)
415 (((MagickRealType) range*pixel)/QuantumRange+0.5)))/range+0.5);
417 quantum=(Quantum) (((MagickRealType) QuantumRange*((QuantumAny)
418 (((MagickRealType) range*pixel)/QuantumRange+0.5)))/range);
420 return(pixel == quantum ? MagickTrue : MagickFalse);
423 static inline MagickBooleanType IsPixelEquivalent(const Image *restrict image,
424 const Quantum *restrict p,const PixelInfo *restrict q)
431 red=(MagickRealType) p[image->channel_map[RedPixelChannel].offset];
432 green=(MagickRealType) p[image->channel_map[GreenPixelChannel].offset];
433 blue=(MagickRealType) p[image->channel_map[BluePixelChannel].offset];
434 if ((AbsolutePixelValue(red-q->red) < MagickEpsilon) &&
435 (AbsolutePixelValue(green-q->green) < MagickEpsilon) &&
436 (AbsolutePixelValue(blue-q->blue) < MagickEpsilon))
441 static inline MagickBooleanType IsPixelGray(const Image *restrict image,
442 const Quantum *restrict pixel)
449 red=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset];
450 green=(MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset];
451 blue=(MagickRealType) pixel[image->channel_map[BluePixelChannel].offset];
452 if ((AbsolutePixelValue(red-green) < MagickEpsilon) &&
453 (AbsolutePixelValue(green-blue) < MagickEpsilon))
458 static inline MagickBooleanType IsPixelInfoEquivalent(
459 const PixelInfo *restrict p,const PixelInfo *restrict q)
461 if ((p->alpha_trait != UndefinedPixelTrait) &&
462 (q->alpha_trait == UndefinedPixelTrait) &&
463 (AbsolutePixelValue(p->alpha-OpaqueAlpha) >= MagickEpsilon))
465 if ((q->alpha_trait != UndefinedPixelTrait) &&
466 (p->alpha_trait == UndefinedPixelTrait) &&
467 (AbsolutePixelValue(q->alpha-OpaqueAlpha)) >= MagickEpsilon)
469 if ((p->alpha_trait != UndefinedPixelTrait) &&
470 (q->alpha_trait != UndefinedPixelTrait))
472 if (AbsolutePixelValue(p->alpha-q->alpha) >= MagickEpsilon)
474 if (AbsolutePixelValue(p->alpha-TransparentAlpha) < MagickEpsilon)
477 if (AbsolutePixelValue(p->red-q->red) >= MagickEpsilon)
479 if (AbsolutePixelValue(p->green-q->green) >= MagickEpsilon)
481 if (AbsolutePixelValue(p->blue-q->blue) >= MagickEpsilon)
483 if ((p->colorspace == CMYKColorspace) &&
484 (AbsolutePixelValue(p->black-q->black) >= MagickEpsilon))
489 static inline MagickBooleanType IsPixelMonochrome(const Image *restrict image,
490 const Quantum *restrict pixel)
497 red=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset];
498 if ((AbsolutePixelValue(red) >= MagickEpsilon) ||
499 (AbsolutePixelValue(red-QuantumRange) >= MagickEpsilon))
501 green=(MagickRealType) pixel[image->channel_map[GreenPixelChannel].offset];
502 blue=(MagickRealType) pixel[image->channel_map[BluePixelChannel].offset];
503 if ((AbsolutePixelValue(red-green) < MagickEpsilon) &&
504 (AbsolutePixelValue(green-blue) < MagickEpsilon))
509 static inline MagickBooleanType IsPixelInfoGray(
510 const PixelInfo *restrict pixel_info)
512 if ((pixel_info->colorspace != GRAYColorspace) &&
513 (pixel_info->colorspace != RGBColorspace))
515 if ((AbsolutePixelValue(pixel_info->red-pixel_info->green) < MagickEpsilon) &&
516 (AbsolutePixelValue(pixel_info->green-pixel_info->blue) < MagickEpsilon))
521 static inline MagickBooleanType IsPixelInfoMonochrome(
522 const PixelInfo *restrict pixel_info)
524 if ((pixel_info->colorspace != GRAYColorspace) &&
525 (pixel_info->colorspace != RGBColorspace))
527 if ((AbsolutePixelValue(pixel_info->red) >= MagickEpsilon) ||
528 (AbsolutePixelValue(pixel_info->red-QuantumRange) >= MagickEpsilon))
530 if ((AbsolutePixelValue(pixel_info->red-pixel_info->green) < MagickEpsilon) &&
531 (AbsolutePixelValue(pixel_info->green-pixel_info->blue) < MagickEpsilon))
536 static inline void SetPixela(const Image *restrict image,
537 const Quantum a,Quantum *restrict pixel)
539 if (image->channel_map[aPixelChannel].traits != UndefinedPixelTrait)
540 pixel[image->channel_map[aPixelChannel].offset]=a;
543 static inline void SetPixelAlpha(const Image *restrict image,
544 const Quantum alpha,Quantum *restrict pixel)
546 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
547 pixel[image->channel_map[AlphaPixelChannel].offset]=alpha;
550 static inline void SetPixelAlphaTraits(Image *image,const PixelTrait traits)
552 image->channel_map[AlphaPixelChannel].traits=traits;
555 static inline void SetPixelb(const Image *restrict image,
556 const Quantum b,Quantum *restrict pixel)
558 if (image->channel_map[bPixelChannel].traits != UndefinedPixelTrait)
559 pixel[image->channel_map[bPixelChannel].offset]=b;
562 static inline void SetPixelBackgoundColor(const Image *restrict image,
563 Quantum *restrict pixel)
568 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
570 pixel[image->channel_map[RedPixelChannel].offset]=
571 ClampToQuantum(image->background_color.red);
572 pixel[image->channel_map[GreenPixelChannel].offset]=
573 ClampToQuantum(image->background_color.green);
574 pixel[image->channel_map[BluePixelChannel].offset]=
575 ClampToQuantum(image->background_color.blue);
576 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
577 pixel[image->channel_map[BlackPixelChannel].offset]=
578 ClampToQuantum(image->background_color.black);
579 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
580 pixel[image->channel_map[AlphaPixelChannel].offset]=
581 image->background_color.alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
582 ClampToQuantum(image->background_color.alpha);
585 static inline void SetPixelBlack(const Image *restrict image,
586 const Quantum black,Quantum *restrict pixel)
588 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
589 pixel[image->channel_map[BlackPixelChannel].offset]=black;
592 static inline void SetPixelBlackTraits(Image *image,const PixelTrait traits)
594 image->channel_map[BlackPixelChannel].traits=traits;
597 static inline void SetPixelBlue(const Image *restrict image,const Quantum blue,
598 Quantum *restrict pixel)
600 pixel[image->channel_map[BluePixelChannel].offset]=blue;
603 static inline void SetPixelBlueTraits(Image *image,const PixelTrait traits)
605 image->channel_map[BluePixelChannel].traits=traits;
608 static inline void SetPixelCb(const Image *restrict image,const Quantum cb,
609 Quantum *restrict pixel)
611 pixel[image->channel_map[CbPixelChannel].offset]=cb;
614 static inline void SetPixelCbTraits(Image *image,const PixelTrait traits)
616 image->channel_map[CbPixelChannel].traits=traits;
619 static inline void SetPixelChannel(const Image *restrict image,
620 const PixelChannel channel,const Quantum quantum,Quantum *restrict pixel)
622 if (image->channel_map[channel].traits != UndefinedPixelTrait)
623 pixel[image->channel_map[channel].offset]=quantum;
626 static inline void SetPixelChannelAttributes(const Image *restrict image,
627 const PixelChannel channel,const PixelTrait traits,const ssize_t offset)
629 image->channel_map[offset].channel=channel;
630 image->channel_map[channel].offset=offset;
631 image->channel_map[channel].traits=traits;
634 static inline void SetPixelChannelChannel(const Image *restrict image,
635 const PixelChannel channel,const ssize_t offset)
637 image->channel_map[offset].channel=channel;
638 image->channel_map[channel].offset=offset;
641 static inline void SetPixelChannels(Image *image,const size_t number_channels)
643 image->number_channels=number_channels;
646 static inline void SetPixelChannelTraits(Image *image,
647 const PixelChannel channel,const PixelTrait traits)
649 image->channel_map[channel].traits=traits;
652 static inline void SetPixelCr(const Image *restrict image,const Quantum cr,
653 Quantum *restrict pixel)
655 pixel[image->channel_map[CrPixelChannel].offset]=cr;
658 static inline void SetPixelCrTraits(Image *image,const PixelTrait traits)
660 image->channel_map[CrPixelChannel].traits=traits;
663 static inline void SetPixelCyan(const Image *restrict image,const Quantum cyan,
664 Quantum *restrict pixel)
666 pixel[image->channel_map[CyanPixelChannel].offset]=cyan;
669 static inline void SetPixelGray(const Image *restrict image,const Quantum gray,
670 Quantum *restrict pixel)
672 pixel[image->channel_map[GrayPixelChannel].offset]=gray;
675 static inline void SetPixelGrayTraits(Image *image,const PixelTrait traits)
677 image->channel_map[GrayPixelChannel].traits=traits;
680 static inline void SetPixelGreen(const Image *restrict image,
681 const Quantum green,Quantum *restrict pixel)
683 pixel[image->channel_map[GreenPixelChannel].offset]=green;
686 static inline void SetPixelGreenTraits(Image *image,const PixelTrait traits)
688 image->channel_map[GreenPixelChannel].traits=traits;
691 static inline void SetPixelIndex(const Image *restrict image,
692 const Quantum index,Quantum *restrict pixel)
694 if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
695 pixel[image->channel_map[IndexPixelChannel].offset]=index;
698 static inline void SetPixelIndexTraits(Image *image,const PixelTrait traits)
700 image->channel_map[IndexPixelChannel].traits=traits;
703 static inline void SetPixelViaPixelInfo(const Image *restrict image,
704 const PixelInfo *restrict pixel_info,Quantum *restrict pixel)
706 pixel[image->channel_map[RedPixelChannel].offset]=
707 ClampToQuantum(pixel_info->red);
708 pixel[image->channel_map[GreenPixelChannel].offset]=
709 ClampToQuantum(pixel_info->green);
710 pixel[image->channel_map[BluePixelChannel].offset]=
711 ClampToQuantum(pixel_info->blue);
712 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
713 pixel[image->channel_map[BlackPixelChannel].offset]=
714 ClampToQuantum(pixel_info->black);
715 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
716 pixel[image->channel_map[AlphaPixelChannel].offset]=
717 pixel_info->alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
718 ClampToQuantum(pixel_info->alpha);
721 static inline void SetPixelL(const Image *restrict image,const Quantum L,
722 Quantum *restrict pixel)
724 if (image->channel_map[LPixelChannel].traits != UndefinedPixelTrait)
725 pixel[image->channel_map[LPixelChannel].offset]=L;
728 static inline void SetPixelMagenta(const Image *restrict image,
729 const Quantum magenta,Quantum *restrict pixel)
731 pixel[image->channel_map[MagentaPixelChannel].offset]=magenta;
734 static inline void SetPixelMagentaTraits(Image *image,const PixelTrait traits)
736 image->channel_map[MagentaPixelChannel].traits=traits;
739 static inline void SetPixelReadMask(const Image *restrict image,
740 const Quantum mask,Quantum *restrict pixel)
742 if (image->channel_map[ReadMaskPixelChannel].traits != UndefinedPixelTrait)
743 pixel[image->channel_map[ReadMaskPixelChannel].offset]=mask;
746 static inline void SetPixelWriteMask(const Image *restrict image,
747 const Quantum mask,Quantum *restrict pixel)
749 if (image->channel_map[WriteMaskPixelChannel].traits != UndefinedPixelTrait)
750 pixel[image->channel_map[WriteMaskPixelChannel].offset]=mask;
753 static inline void SetPixelMetacontentExtent(Image *image,const size_t extent)
755 image->metacontent_extent=extent;
758 static inline void SetPixelOpacity(const Image *restrict image,
759 const Quantum alpha,Quantum *restrict pixel)
761 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
762 pixel[image->channel_map[AlphaPixelChannel].offset]=QuantumRange-alpha;
765 static inline void SetPixelRed(const Image *restrict image,const Quantum red,
766 Quantum *restrict pixel)
768 pixel[image->channel_map[RedPixelChannel].offset]=red;
771 static inline void SetPixelRedTraits(Image *image,const PixelTrait traits)
773 image->channel_map[RedPixelChannel].traits=traits;
776 static inline void SetPixelYellow(const Image *restrict image,
777 const Quantum yellow,Quantum *restrict pixel)
779 pixel[image->channel_map[YellowPixelChannel].offset]=yellow;
782 static inline void SetPixelYellowTraits(Image *image,const PixelTrait traits)
784 image->channel_map[YellowPixelChannel].traits=traits;
787 static inline void SetPixelY(const Image *restrict image,const Quantum y,
788 Quantum *restrict pixel)
790 pixel[image->channel_map[YPixelChannel].offset]=y;
793 static inline void SetPixelYTraits(Image *image,const PixelTrait traits)
795 image->channel_map[YPixelChannel].traits=traits;
798 #if defined(__cplusplus) || defined(c_plusplus)