2 Copyright 1999-2016 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 *magick_restrict image,
48 const Quantum *magick_restrict pixel)
50 return(pixel[image->channel_map[aPixelChannel].offset]);
53 static inline Quantum GetPixelAlpha(const Image *magick_restrict image,
54 const Quantum *magick_restrict pixel)
56 if (image->channel_map[AlphaPixelChannel].traits == UndefinedPixelTrait)
58 return(pixel[image->channel_map[AlphaPixelChannel].offset]);
61 static inline PixelTrait GetPixelAlphaTraits(
62 const Image *magick_restrict image)
64 return(image->channel_map[AlphaPixelChannel].traits);
67 static inline Quantum GetPixelb(const Image *magick_restrict image,
68 const Quantum *magick_restrict pixel)
70 return(pixel[image->channel_map[bPixelChannel].offset]);
73 static 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]);
81 static inline PixelTrait GetPixelBlackTraits(
82 const Image *magick_restrict image)
84 return(image->channel_map[BlackPixelChannel].traits);
87 static inline Quantum GetPixelBlue(const Image *magick_restrict image,
88 const Quantum *magick_restrict pixel)
90 return(pixel[image->channel_map[BluePixelChannel].offset]);
93 static inline PixelTrait GetPixelBlueTraits(const Image *magick_restrict image)
95 return(image->channel_map[BluePixelChannel].traits);
98 static inline Quantum GetPixelCb(const Image *magick_restrict image,
99 const Quantum *magick_restrict pixel)
101 return(pixel[image->channel_map[CbPixelChannel].offset]);
104 static inline PixelTrait GetPixelCbTraits(const Image *magick_restrict image)
106 return(image->channel_map[CbPixelChannel].traits);
109 static inline Quantum GetPixelChannel(const Image *magick_restrict image,
110 const PixelChannel channel,const Quantum *magick_restrict pixel)
112 if (image->channel_map[channel].traits == UndefinedPixelTrait)
114 return(pixel[image->channel_map[channel].offset]);
117 static inline PixelChannel GetPixelChannelChannel(
118 const Image *magick_restrict image,const ssize_t offset)
120 return(image->channel_map[offset].channel);
123 static inline ssize_t GetPixelChannelOffset(const Image *magick_restrict image,
124 const PixelChannel channel)
126 return(image->channel_map[channel].offset);
129 static inline PixelTrait GetPixelChannelTraits(
130 const Image *magick_restrict image,const PixelChannel channel)
132 return(image->channel_map[channel].traits);
135 static inline size_t GetPixelChannels(const Image *magick_restrict image)
137 return(image->number_channels);
140 static inline Quantum GetPixelCr(const Image *magick_restrict image,
141 const Quantum *magick_restrict pixel)
143 return(pixel[image->channel_map[CrPixelChannel].offset]);
146 static inline PixelTrait GetPixelCrTraits(const Image *magick_restrict image)
148 return(image->channel_map[CrPixelChannel].traits);
151 static inline Quantum GetPixelCyan(const Image *magick_restrict image,
152 const Quantum *magick_restrict pixel)
154 return(pixel[image->channel_map[CyanPixelChannel].offset]);
157 static inline PixelTrait GetPixelCyanTraits(const Image *magick_restrict image)
159 return(image->channel_map[CyanPixelChannel].traits);
162 static inline Quantum GetPixelGray(const Image *magick_restrict image,
163 const Quantum *magick_restrict pixel)
165 return(pixel[image->channel_map[GrayPixelChannel].offset]);
168 static inline PixelTrait GetPixelGrayTraits(const Image *magick_restrict image)
170 return(image->channel_map[GrayPixelChannel].traits);
173 static inline Quantum GetPixelGreen(const Image *magick_restrict image,
174 const Quantum *magick_restrict pixel)
176 return(pixel[image->channel_map[GreenPixelChannel].offset]);
179 static inline PixelTrait GetPixelGreenTraits(
180 const Image *magick_restrict image)
182 return(image->channel_map[GreenPixelChannel].traits);
185 static inline Quantum GetPixelIndex(const Image *magick_restrict image,
186 const Quantum *magick_restrict pixel)
188 if (image->channel_map[IndexPixelChannel].traits == UndefinedPixelTrait)
190 return(pixel[image->channel_map[IndexPixelChannel].offset]);
193 static inline PixelTrait GetPixelIndexTraits(
194 const Image *magick_restrict image)
196 return(image->channel_map[IndexPixelChannel].traits);
199 static inline MagickRealType GetPixelInfoChannel(
200 const PixelInfo *magick_restrict pixel_info,const PixelChannel channel)
204 case RedPixelChannel: return(pixel_info->red);
205 case GreenPixelChannel: return(pixel_info->green);
206 case BluePixelChannel: return(pixel_info->blue);
207 case BlackPixelChannel: return(pixel_info->black);
208 case AlphaPixelChannel: return(pixel_info->alpha);
209 case IndexPixelChannel: return(pixel_info->index);
210 default: return((MagickRealType) 0.0);
214 static inline double PerceptibleReciprocal(const double x)
220 Return 1/x where x is perceptible (not unlimited or infinitesimal).
222 sign=x < 0.0 ? -1.0 : 1.0;
223 if ((sign*x) >= MagickEpsilon)
225 return(sign/MagickEpsilon);
228 static inline MagickRealType GetPixelInfoLuma(
229 const PixelInfo *magick_restrict pixel)
234 if (pixel->colorspace == sRGBColorspace)
236 intensity=(MagickRealType) (0.212656f*pixel->red+0.715158f*pixel->green+
237 0.072186f*pixel->blue);
240 intensity=(MagickRealType) (0.212656f*EncodePixelGamma(pixel->red)+
241 0.715158f*EncodePixelGamma(pixel->green)+
242 0.072186f*EncodePixelGamma(pixel->blue));
246 static inline MagickRealType GetPixelInfoLuminance(
247 const PixelInfo *magick_restrict pixel)
252 if (pixel->colorspace != sRGBColorspace)
254 intensity=(MagickRealType) (0.212656f*pixel->red+0.715158f*pixel->green+
255 0.072186f*pixel->blue);
258 intensity=(MagickRealType) (0.212656f*DecodePixelGamma(pixel->red)+
259 0.715158f*DecodePixelGamma(pixel->green)+
260 0.072186f*DecodePixelGamma(pixel->blue));
264 static inline Quantum GetPixelL(const Image *magick_restrict image,
265 const Quantum *magick_restrict pixel)
267 return(pixel[image->channel_map[LPixelChannel].offset]);
270 static inline ssize_t GetPixelLabel(const Image *magick_restrict image,
271 const Quantum *magick_restrict pixel)
273 return((ssize_t) pixel[image->channel_map[LabelPixelChannel].offset]);
276 static inline MagickRealType GetPixelLuma(const Image *magick_restrict image,
277 const Quantum *magick_restrict pixel)
282 intensity=(MagickRealType) (
283 0.212656f*pixel[image->channel_map[RedPixelChannel].offset]+
284 0.715158f*pixel[image->channel_map[GreenPixelChannel].offset]+
285 0.072186f*pixel[image->channel_map[BluePixelChannel].offset]);
289 static inline MagickRealType GetPixelLuminance(
290 const Image *magick_restrict image,const Quantum *magick_restrict pixel)
295 if (image->colorspace != sRGBColorspace)
297 intensity=(MagickRealType) (
298 0.212656f*pixel[image->channel_map[RedPixelChannel].offset]+
299 0.715158f*pixel[image->channel_map[GreenPixelChannel].offset]+
300 0.072186f*pixel[image->channel_map[BluePixelChannel].offset]);
303 intensity=(MagickRealType) (0.212656f*DecodePixelGamma((MagickRealType)
304 pixel[image->channel_map[RedPixelChannel].offset])+0.715158f*
305 DecodePixelGamma((MagickRealType)
306 pixel[image->channel_map[GreenPixelChannel].offset])+0.072186f*
307 DecodePixelGamma((MagickRealType)
308 pixel[image->channel_map[BluePixelChannel].offset]));
312 static inline Quantum GetPixelMagenta(const Image *magick_restrict image,
313 const Quantum *magick_restrict pixel)
315 return(pixel[image->channel_map[MagentaPixelChannel].offset]);
318 static inline PixelTrait GetPixelMagentaTraits(
319 const Image *magick_restrict image)
321 return(image->channel_map[MagentaPixelChannel].traits);
324 static inline Quantum GetPixelReadMask(const Image *magick_restrict image,
325 const Quantum *magick_restrict pixel)
327 if (image->channel_map[ReadMaskPixelChannel].traits == UndefinedPixelTrait)
328 return((Quantum) QuantumRange);
329 return(pixel[image->channel_map[ReadMaskPixelChannel].offset]);
332 static inline Quantum GetPixelWriteMask(const Image *magick_restrict image,
333 const Quantum *magick_restrict pixel)
335 if (image->channel_map[WriteMaskPixelChannel].traits == UndefinedPixelTrait)
336 return((Quantum) QuantumRange);
337 return(pixel[image->channel_map[WriteMaskPixelChannel].offset]);
340 static inline PixelTrait GetPixelReadMaskTraits(
341 const Image *magick_restrict image)
343 return(image->channel_map[ReadMaskPixelChannel].traits);
346 static inline size_t GetPixelMetaChannels(const Image *magick_restrict image)
348 return(image->number_meta_channels);
351 static inline size_t GetPixelMetacontentExtent(
352 const Image *magick_restrict image)
354 return(image->metacontent_extent);
357 static inline Quantum GetPixelOpacity(const Image *magick_restrict image,
358 const Quantum *magick_restrict pixel)
360 if (image->channel_map[AlphaPixelChannel].traits != BlendPixelTrait)
361 return(QuantumRange-OpaqueAlpha);
362 return(QuantumRange-pixel[image->channel_map[AlphaPixelChannel].offset]);
365 static inline Quantum GetPixelRed(const Image *magick_restrict image,
366 const Quantum *magick_restrict pixel)
368 return(pixel[image->channel_map[RedPixelChannel].offset]);
371 static inline PixelTrait GetPixelRedTraits(const Image *magick_restrict image)
373 return(image->channel_map[RedPixelChannel].traits);
376 static inline void GetPixelInfoPixel(const Image *magick_restrict image,
377 const Quantum *magick_restrict pixel,PixelInfo *magick_restrict pixel_info)
379 pixel_info->storage_class=image->storage_class;
380 pixel_info->colorspace=image->colorspace;
381 pixel_info->fuzz=image->fuzz;
382 pixel_info->depth=image->depth;
383 pixel_info->red=(MagickRealType)
384 pixel[image->channel_map[RedPixelChannel].offset];
385 pixel_info->green=(MagickRealType)
386 pixel[image->channel_map[GreenPixelChannel].offset];
387 pixel_info->blue=(MagickRealType)
388 pixel[image->channel_map[BluePixelChannel].offset];
389 pixel_info->black=0.0f;
390 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
391 pixel_info->black=(MagickRealType)
392 pixel[image->channel_map[BlackPixelChannel].offset];
393 pixel_info->alpha=(MagickRealType) OpaqueAlpha;
394 pixel_info->alpha_trait=UndefinedPixelTrait;
395 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
397 pixel_info->alpha=(MagickRealType)
398 pixel[image->channel_map[AlphaPixelChannel].offset];
399 pixel_info->alpha_trait=BlendPixelTrait;
401 pixel_info->index=0.0f;
402 if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
403 pixel_info->index=(MagickRealType)
404 pixel[image->channel_map[IndexPixelChannel].offset];
408 static inline PixelTrait GetPixelTraits(const Image *magick_restrict image,
409 const PixelChannel channel)
411 return(image->channel_map[channel].traits);
414 static inline Quantum GetPixelY(const Image *magick_restrict image,
415 const Quantum *magick_restrict pixel)
417 return(pixel[image->channel_map[YPixelChannel].offset]);
420 static inline PixelTrait GetPixelYTraits(const Image *magick_restrict image)
422 return(image->channel_map[YPixelChannel].traits);
425 static inline Quantum GetPixelYellow(const Image *magick_restrict image,
426 const Quantum *magick_restrict pixel)
428 return(pixel[image->channel_map[YellowPixelChannel].offset]);
431 static inline PixelTrait GetPixelYellowTraits(
432 const Image *magick_restrict image)
434 return(image->channel_map[YellowPixelChannel].traits);
437 static inline MagickRealType AbsolutePixelValue(const MagickRealType x)
439 return(x < 0.0f ? -x : x);
442 static inline MagickBooleanType IsPixelAtDepth(const Quantum pixel,
443 const QuantumAny range)
448 #if !defined(MAGICKCORE_HDRI_SUPPORT)
449 quantum=(Quantum) (((MagickRealType) QuantumRange*((QuantumAny)
450 (((MagickRealType) range*pixel)/QuantumRange+0.5)))/range+0.5);
452 quantum=(Quantum) (((MagickRealType) QuantumRange*((QuantumAny)
453 (((MagickRealType) range*pixel)/QuantumRange+0.5)))/range);
455 return(pixel == quantum ? MagickTrue : MagickFalse);
458 static inline MagickBooleanType IsPixelEquivalent(
459 const Image *magick_restrict image,const Quantum *magick_restrict p,
460 const PixelInfo *magick_restrict q)
465 value=(MagickRealType) p[image->channel_map[AlphaPixelChannel].offset];
466 if ((image->alpha_trait != UndefinedPixelTrait) &&
467 (q->alpha_trait == UndefinedPixelTrait) &&
468 (AbsolutePixelValue(value-OpaqueAlpha) >= MagickEpsilon))
470 if ((q->alpha_trait != UndefinedPixelTrait) &&
471 (image->alpha_trait == UndefinedPixelTrait) &&
472 (AbsolutePixelValue(q->alpha-OpaqueAlpha)) >= MagickEpsilon)
474 if ((image->alpha_trait != UndefinedPixelTrait) &&
475 (q->alpha_trait != UndefinedPixelTrait))
477 if (AbsolutePixelValue(value-q->alpha) >= MagickEpsilon)
479 if (AbsolutePixelValue(value-TransparentAlpha) < MagickEpsilon)
482 value=(MagickRealType) p[image->channel_map[RedPixelChannel].offset];
483 if (AbsolutePixelValue(value-q->red) >= MagickEpsilon)
485 value=(MagickRealType) p[image->channel_map[GreenPixelChannel].offset];
486 if (AbsolutePixelValue(value-q->green) >= MagickEpsilon)
488 value=(MagickRealType) p[image->channel_map[BluePixelChannel].offset];
489 if (AbsolutePixelValue(value-q->blue) >= MagickEpsilon)
491 if (image->colorspace == CMYKColorspace)
493 value=(MagickRealType) p[image->channel_map[BlackPixelChannel].offset];
494 if (AbsolutePixelValue(value-q->black) >= MagickEpsilon)
500 static inline MagickBooleanType IsPixelGray(const Image *magick_restrict image,
501 const Quantum *magick_restrict pixel)
507 red_green=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]-
508 pixel[image->channel_map[GreenPixelChannel].offset];
509 green_blue=(MagickRealType)
510 pixel[image->channel_map[GreenPixelChannel].offset]-
511 pixel[image->channel_map[BluePixelChannel].offset];
512 if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
513 (AbsolutePixelValue(green_blue) < MagickEpsilon))
518 static inline MagickBooleanType IsPixelInfoEquivalent(
519 const PixelInfo *magick_restrict p,const PixelInfo *magick_restrict q)
521 if ((p->alpha_trait != UndefinedPixelTrait) &&
522 (q->alpha_trait == UndefinedPixelTrait) &&
523 (AbsolutePixelValue(p->alpha-OpaqueAlpha) >= MagickEpsilon))
525 if ((q->alpha_trait != UndefinedPixelTrait) &&
526 (p->alpha_trait == UndefinedPixelTrait) &&
527 (AbsolutePixelValue(q->alpha-OpaqueAlpha)) >= MagickEpsilon)
529 if ((p->alpha_trait != UndefinedPixelTrait) &&
530 (q->alpha_trait != UndefinedPixelTrait))
532 if (AbsolutePixelValue(p->alpha-q->alpha) >= MagickEpsilon)
534 if (AbsolutePixelValue(p->alpha-TransparentAlpha) < MagickEpsilon)
537 if (AbsolutePixelValue(p->red-q->red) >= MagickEpsilon)
539 if (AbsolutePixelValue(p->green-q->green) >= MagickEpsilon)
541 if (AbsolutePixelValue(p->blue-q->blue) >= MagickEpsilon)
543 if ((p->colorspace == CMYKColorspace) &&
544 (AbsolutePixelValue(p->black-q->black) >= MagickEpsilon))
549 static inline MagickBooleanType IsPixelMonochrome(
550 const Image *magick_restrict image,const Quantum *magick_restrict pixel)
557 red=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset];
558 if ((AbsolutePixelValue(red) >= MagickEpsilon) &&
559 (AbsolutePixelValue(red-QuantumRange) >= MagickEpsilon))
561 red_green=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]-
562 pixel[image->channel_map[GreenPixelChannel].offset];
563 green_blue=(MagickRealType)
564 pixel[image->channel_map[GreenPixelChannel].offset]-
565 pixel[image->channel_map[BluePixelChannel].offset];
566 if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
567 (AbsolutePixelValue(green_blue) < MagickEpsilon))
572 static inline MagickBooleanType IsPixelInfoGray(
573 const PixelInfo *magick_restrict pixel)
575 if ((pixel->colorspace != GRAYColorspace) &&
576 (pixel->colorspace != RGBColorspace))
578 if ((AbsolutePixelValue(pixel->red-pixel->green) < MagickEpsilon) &&
579 (AbsolutePixelValue(pixel->green-pixel->blue) < MagickEpsilon))
584 static inline MagickBooleanType IsPixelInfoMonochrome(
585 const PixelInfo *magick_restrict pixel_info)
591 if ((pixel_info->colorspace != GRAYColorspace) &&
592 (pixel_info->colorspace != RGBColorspace))
594 if ((AbsolutePixelValue(pixel_info->red) >= MagickEpsilon) ||
595 (AbsolutePixelValue(pixel_info->red-QuantumRange) >= MagickEpsilon))
597 red_green=pixel_info->red-pixel_info->green;
598 green_blue=pixel_info->green-pixel_info->blue;
599 if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
600 (AbsolutePixelValue(green_blue) < MagickEpsilon))
605 static inline void SetPixela(const Image *magick_restrict image,
606 const Quantum a,Quantum *magick_restrict pixel)
608 if (image->channel_map[aPixelChannel].traits != UndefinedPixelTrait)
609 pixel[image->channel_map[aPixelChannel].offset]=a;
612 static inline void SetPixelAlpha(const Image *magick_restrict image,
613 const Quantum alpha,Quantum *magick_restrict pixel)
615 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
616 pixel[image->channel_map[AlphaPixelChannel].offset]=alpha;
619 static inline void SetPixelAlphaTraits(Image *image,const PixelTrait traits)
621 image->channel_map[AlphaPixelChannel].traits=traits;
624 static inline void SetPixelb(const Image *magick_restrict image,
625 const Quantum b,Quantum *magick_restrict pixel)
627 if (image->channel_map[bPixelChannel].traits != UndefinedPixelTrait)
628 pixel[image->channel_map[bPixelChannel].offset]=b;
631 static inline void SetPixelBackgoundColor(const Image *magick_restrict image,
632 Quantum *magick_restrict pixel)
637 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
639 pixel[image->channel_map[RedPixelChannel].offset]=
640 ClampToQuantum(image->background_color.red);
641 pixel[image->channel_map[GreenPixelChannel].offset]=
642 ClampToQuantum(image->background_color.green);
643 pixel[image->channel_map[BluePixelChannel].offset]=
644 ClampToQuantum(image->background_color.blue);
645 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
646 pixel[image->channel_map[BlackPixelChannel].offset]=
647 ClampToQuantum(image->background_color.black);
648 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
649 pixel[image->channel_map[AlphaPixelChannel].offset]=
650 image->background_color.alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
651 ClampToQuantum(image->background_color.alpha);
654 static inline void SetPixelBlack(const Image *magick_restrict image,
655 const Quantum black,Quantum *magick_restrict pixel)
657 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
658 pixel[image->channel_map[BlackPixelChannel].offset]=black;
661 static inline void SetPixelBlackTraits(Image *image,const PixelTrait traits)
663 image->channel_map[BlackPixelChannel].traits=traits;
666 static inline void SetPixelBlue(const Image *magick_restrict image,
667 const Quantum blue,Quantum *magick_restrict pixel)
669 pixel[image->channel_map[BluePixelChannel].offset]=blue;
672 static inline void SetPixelBlueTraits(Image *image,const PixelTrait traits)
674 image->channel_map[BluePixelChannel].traits=traits;
677 static inline void SetPixelCb(const Image *magick_restrict image,
678 const Quantum cb,Quantum *magick_restrict pixel)
680 pixel[image->channel_map[CbPixelChannel].offset]=cb;
683 static inline void SetPixelCbTraits(Image *image,const PixelTrait traits)
685 image->channel_map[CbPixelChannel].traits=traits;
688 static inline void SetPixelChannel(const Image *magick_restrict image,
689 const PixelChannel channel,const Quantum quantum,
690 Quantum *magick_restrict pixel)
692 if (image->channel_map[channel].traits != UndefinedPixelTrait)
693 pixel[image->channel_map[channel].offset]=quantum;
696 static inline void SetPixelChannelAttributes(
697 const Image *magick_restrict image,const PixelChannel channel,
698 const PixelTrait traits,const ssize_t offset)
700 image->channel_map[offset].channel=channel;
701 image->channel_map[channel].offset=offset;
702 image->channel_map[channel].traits=traits;
705 static inline void SetPixelChannelChannel(const Image *magick_restrict image,
706 const PixelChannel channel,const ssize_t offset)
708 image->channel_map[offset].channel=channel;
709 image->channel_map[channel].offset=offset;
712 static inline void SetPixelChannels(Image *image,const size_t number_channels)
714 image->number_channels=number_channels;
717 static inline void SetPixelChannelTraits(Image *image,
718 const PixelChannel channel,const PixelTrait traits)
720 image->channel_map[channel].traits=traits;
723 static inline void SetPixelCr(const Image *magick_restrict image,
724 const Quantum cr,Quantum *magick_restrict pixel)
726 pixel[image->channel_map[CrPixelChannel].offset]=cr;
729 static inline void SetPixelCrTraits(Image *image,const PixelTrait traits)
731 image->channel_map[CrPixelChannel].traits=traits;
734 static inline void SetPixelCyan(const Image *magick_restrict image,
735 const Quantum cyan,Quantum *magick_restrict pixel)
737 pixel[image->channel_map[CyanPixelChannel].offset]=cyan;
740 static inline void SetPixelGray(const Image *magick_restrict image,
741 const Quantum gray,Quantum *magick_restrict pixel)
743 pixel[image->channel_map[GrayPixelChannel].offset]=gray;
746 static inline void SetPixelGrayTraits(Image *image,const PixelTrait traits)
748 image->channel_map[GrayPixelChannel].traits=traits;
751 static inline void SetPixelGreen(const Image *magick_restrict image,
752 const Quantum green,Quantum *magick_restrict pixel)
754 pixel[image->channel_map[GreenPixelChannel].offset]=green;
757 static inline void SetPixelGreenTraits(Image *image,const PixelTrait traits)
759 image->channel_map[GreenPixelChannel].traits=traits;
762 static inline void SetPixelIndex(const Image *magick_restrict image,
763 const Quantum index,Quantum *magick_restrict pixel)
765 if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
766 pixel[image->channel_map[IndexPixelChannel].offset]=index;
769 static inline void SetPixelIndexTraits(Image *image,const PixelTrait traits)
771 image->channel_map[IndexPixelChannel].traits=traits;
774 static inline void SetPixelViaPixelInfo(const Image *magick_restrict image,
775 const PixelInfo *magick_restrict pixel_info,Quantum *magick_restrict pixel)
777 pixel[image->channel_map[RedPixelChannel].offset]=
778 ClampToQuantum(pixel_info->red);
779 pixel[image->channel_map[GreenPixelChannel].offset]=
780 ClampToQuantum(pixel_info->green);
781 pixel[image->channel_map[BluePixelChannel].offset]=
782 ClampToQuantum(pixel_info->blue);
783 if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
784 pixel[image->channel_map[BlackPixelChannel].offset]=
785 ClampToQuantum(pixel_info->black);
786 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
787 pixel[image->channel_map[AlphaPixelChannel].offset]=
788 pixel_info->alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
789 ClampToQuantum(pixel_info->alpha);
792 static inline void SetPixelL(const Image *magick_restrict image,const Quantum L,
793 Quantum *magick_restrict pixel)
795 if (image->channel_map[LPixelChannel].traits != UndefinedPixelTrait)
796 pixel[image->channel_map[LPixelChannel].offset]=L;
799 static inline void SetPixelMagenta(const Image *magick_restrict image,
800 const Quantum magenta,Quantum *magick_restrict pixel)
802 pixel[image->channel_map[MagentaPixelChannel].offset]=magenta;
805 static inline void SetPixelMagentaTraits(Image *image,const PixelTrait traits)
807 image->channel_map[MagentaPixelChannel].traits=traits;
810 static inline void SetPixelReadMask(const Image *magick_restrict image,
811 const Quantum mask,Quantum *magick_restrict pixel)
813 if (image->channel_map[ReadMaskPixelChannel].traits != UndefinedPixelTrait)
814 pixel[image->channel_map[ReadMaskPixelChannel].offset]=mask;
817 static inline void SetPixelWriteMask(const Image *magick_restrict image,
818 const Quantum mask,Quantum *magick_restrict pixel)
820 if (image->channel_map[WriteMaskPixelChannel].traits != UndefinedPixelTrait)
821 pixel[image->channel_map[WriteMaskPixelChannel].offset]=mask;
824 static inline void SetPixelMetacontentExtent(Image *image,const size_t extent)
826 image->metacontent_extent=extent;
829 static inline void SetPixelOpacity(const Image *magick_restrict image,
830 const Quantum alpha,Quantum *magick_restrict pixel)
832 if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
833 pixel[image->channel_map[AlphaPixelChannel].offset]=QuantumRange-alpha;
836 static inline void SetPixelRed(const Image *magick_restrict image,
837 const Quantum red,Quantum *magick_restrict pixel)
839 pixel[image->channel_map[RedPixelChannel].offset]=red;
842 static inline void SetPixelRedTraits(Image *image,const PixelTrait traits)
844 image->channel_map[RedPixelChannel].traits=traits;
847 static inline void SetPixelYellow(const Image *magick_restrict image,
848 const Quantum yellow,Quantum *magick_restrict pixel)
850 pixel[image->channel_map[YellowPixelChannel].offset]=yellow;
853 static inline void SetPixelYellowTraits(Image *image,const PixelTrait traits)
855 image->channel_map[YellowPixelChannel].traits=traits;
858 static inline void SetPixelY(const Image *magick_restrict image,
859 const Quantum y,Quantum *magick_restrict pixel)
861 pixel[image->channel_map[YPixelChannel].offset]=y;
864 static inline void SetPixelYTraits(Image *image,const PixelTrait traits)
866 image->channel_map[YPixelChannel].traits=traits;
869 #if defined(__cplusplus) || defined(c_plusplus)