]> granicus.if.org Git - imagemagick/blob - MagickCore/pixel-accessor.h
(no commit message)
[imagemagick] / MagickCore / pixel-accessor.h
1 /*
2   Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization
3   dedicated to making software imaging solutions freely available.
4
5   You may not use this file except in compliance with the License.
6   obtain a copy of the License at
7
8     http://www.imagemagick.org/script/license.php
9
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.
15
16   MagickCore pixel accessor methods.
17 */
18 #ifndef _MAGICKCORE_PIXEL_ACCESSOR_H
19 #define _MAGICKCORE_PIXEL_ACCESSOR_H
20
21 #if defined(__cplusplus) || defined(c_plusplus)
22 extern "C" {
23 #endif
24
25 #include <math.h>
26 #include <MagickCore/cache.h>
27 #include <MagickCore/cache-view.h>
28 #include <MagickCore/color.h>
29 #include <MagickCore/image.h>
30
31 #undef index
32
33 static inline Quantum GetPixelAlpha(const Image *restrict image,
34   const Quantum *restrict pixel)
35 {
36   if (image->channel_map[AlphaPixelChannel].traits == UndefinedPixelTrait)
37     return(OpaqueAlpha);
38   return(pixel[image->channel_map[AlphaPixelChannel].offset]);
39 }
40
41 static inline PixelTrait GetPixelAlphaTraits(const Image *restrict image)
42 {
43   return(image->channel_map[AlphaPixelChannel].traits);
44 }
45
46 static inline Quantum GetPixelBlack(const Image *restrict image,
47   const Quantum *restrict pixel)
48 {
49   if (image->channel_map[BlackPixelChannel].traits == UndefinedPixelTrait)
50     return(0);
51   return(pixel[image->channel_map[BlackPixelChannel].offset]);
52 }
53
54 static inline PixelTrait GetPixelBlackTraits(const Image *restrict image)
55 {
56   return(image->channel_map[BlackPixelChannel].traits);
57 }
58
59 static inline Quantum GetPixelBlue(const Image *restrict image,
60   const Quantum *restrict pixel)
61 {
62   return(pixel[image->channel_map[BluePixelChannel].offset]);
63 }
64
65 static inline PixelTrait GetPixelBlueTraits(const Image *restrict image)
66 {
67   return(image->channel_map[BluePixelChannel].traits);
68 }
69
70 static inline Quantum GetPixelCb(const Image *restrict image,
71   const Quantum *restrict pixel)
72 {
73   return(pixel[image->channel_map[CbPixelChannel].offset]);
74 }
75
76 static inline PixelTrait GetPixelCbTraits(const Image *restrict image)
77 {
78   return(image->channel_map[CbPixelChannel].traits);
79 }
80
81 static inline Quantum GetPixelChannel(const Image *restrict image,
82   const PixelChannel channel,const Quantum *restrict pixel)
83 {
84   if (image->channel_map[channel].traits == UndefinedPixelTrait)
85     return(0);
86   return(pixel[image->channel_map[channel].offset]);
87 }
88
89 static inline PixelChannel GetPixelChannelMapChannel(
90   const Image *restrict image,const ssize_t offset)
91 {
92   return(image->channel_map[offset].channel);
93 }
94
95 static inline ssize_t GetPixelChannelMapOffset(const Image *restrict image,
96   const PixelChannel channel)
97 {
98   return(image->channel_map[channel].offset);
99 }
100
101 static inline PixelTrait GetPixelChannelMapTraits(const Image *restrict image,
102   const PixelChannel channel)
103 {
104   return(image->channel_map[channel].traits);
105 }
106
107 static inline size_t GetPixelChannels(const Image *restrict image)
108 {
109   return(image->number_channels);
110 }
111
112 static inline Quantum GetPixelCr(const Image *restrict image,
113   const Quantum *restrict pixel)
114 {
115   return(pixel[image->channel_map[CrPixelChannel].offset]);
116 }
117
118 static inline PixelTrait GetPixelCrTraits(const Image *restrict image)
119 {
120   return(image->channel_map[CrPixelChannel].traits);
121 }
122
123 static inline Quantum GetPixelCyan(const Image *restrict image,
124   const Quantum *restrict pixel)
125 {
126   return(pixel[image->channel_map[CyanPixelChannel].offset]);
127 }
128
129 static inline PixelTrait GetPixelCyanTraits(const Image *restrict image)
130 {
131   return(image->channel_map[CyanPixelChannel].traits);
132 }
133
134 static inline Quantum GetPixelGray(const Image *restrict image,
135   const Quantum *restrict pixel)
136 {
137   return(pixel[image->channel_map[GrayPixelChannel].offset]);
138 }
139
140 static inline PixelTrait GetPixelGrayTraits(const Image *restrict image)
141 {
142   return(image->channel_map[GrayPixelChannel].traits);
143 }
144
145 static inline Quantum GetPixelGreen(const Image *restrict image,
146   const Quantum *restrict pixel)
147 {
148   return(pixel[image->channel_map[GreenPixelChannel].offset]);
149 }
150
151 static inline PixelTrait GetPixelGreenTraits(const Image *restrict image)
152 {
153   return(image->channel_map[GreenPixelChannel].traits);
154 }
155
156 static inline Quantum GetPixelIndex(const Image *restrict image,
157   const Quantum *restrict pixel)
158 {
159   if (image->channel_map[IndexPixelChannel].traits == UndefinedPixelTrait)
160     return(0);
161   return(pixel[image->channel_map[IndexPixelChannel].offset]);
162 }
163
164 static inline PixelTrait GetPixelIndexTraits(const Image *restrict image)
165 {
166   return(image->channel_map[IndexPixelChannel].traits);
167 }
168
169 static inline Quantum GetPixelInfoIntensity(
170   const PixelInfo *restrict pixel_info)
171 {
172 #if !defined(MAGICKCORE_HDRI_SUPPORT)
173   return((Quantum) (0.299*pixel_info->red+0.587*pixel_info->green+0.114*
174     pixel_info->blue+0.5));
175 #else
176   return((Quantum) (0.299*pixel_info->red+0.587*pixel_info->green+0.114*
177     pixel_info->blue));
178 #endif
179 }
180
181 static inline Quantum GetPixelInfoLuminance(
182   const PixelInfo *restrict pixel_info)
183 {
184   Quantum
185     luminance;
186
187 #if !defined(MAGICKCORE_HDRI_SUPPORT)
188   luminance=(Quantum) (0.21267*pixel_info->red+0.71516*pixel_info->green+
189     0.07217*pixel_info->blue+0.5);
190 #else
191   luminance=(Quantum) (0.21267*pixel_info->red+0.71516*pixel_info->green+
192     0.07217*pixel_info->blue);
193 #endif
194   return((Quantum) luminance);
195 }
196
197 static inline Quantum GetPixelIntensity(const Image *restrict image,
198   const Quantum *restrict pixel)
199 {
200 #if !defined(MAGICKCORE_HDRI_SUPPORT)
201   if (image->colorspace == GRAYColorspace)
202     return(pixel[image->channel_map[GrayPixelChannel].offset]);
203   return((Quantum) (0.299*pixel[image->channel_map[RedPixelChannel].offset]+
204     0.587*pixel[image->channel_map[GreenPixelChannel].offset]+0.114*
205     pixel[image->channel_map[BluePixelChannel].offset]+0.5));
206 #else
207   {
208     double
209       alpha,
210       beta;
211
212     alpha=pixel[image->channel_map[RedPixelChannel].offset]-(double)
213       pixel[image->channel_map[GreenPixelChannel].offset];
214     beta=pixel[image->channel_map[GreenPixelChannel].offset]-(double)
215       pixel[image->channel_map[BluePixelChannel].offset];
216     if ((fabs(alpha) <= MagickEpsilon) && (fabs(beta) <= MagickEpsilon))
217       return(pixel[image->channel_map[RedPixelChannel].offset]);
218     return((Quantum) (0.299*pixel[image->channel_map[RedPixelChannel].offset]+
219       0.587*pixel[image->channel_map[GreenPixelChannel].offset]+0.114*
220       pixel[image->channel_map[BluePixelChannel].offset]));
221   }
222 #endif
223 }
224
225 static inline Quantum GetPixelLuminance(const Image *restrict image,
226   const Quantum *restrict pixel)
227 {
228 #if !defined(MAGICKCORE_HDRI_SUPPORT)
229   return((Quantum) (0.21267*pixel[image->channel_map[RedPixelChannel].offset]+
230     0.71516*pixel[image->channel_map[GreenPixelChannel].offset]+0.07217*
231     pixel[image->channel_map[BluePixelChannel].offset]+0.5));
232 #else
233   return((Quantum) (0.21267*pixel[image->channel_map[RedPixelChannel].offset]+
234     0.71516*pixel[image->channel_map[GreenPixelChannel].offset]+0.07217*
235     pixel[image->channel_map[BluePixelChannel].offset]));
236 #endif
237 }
238
239 static inline Quantum GetPixelMagenta(const Image *restrict image,
240   const Quantum *restrict pixel)
241 {
242   return(pixel[image->channel_map[MagentaPixelChannel].offset]);
243 }
244
245 static inline PixelTrait GetPixelMagentaTraits(const Image *restrict image)
246 {
247   return(image->channel_map[MagentaPixelChannel].traits);
248 }
249
250 static inline Quantum GetPixelMask(const Image *restrict image,
251   const Quantum *restrict pixel)
252 {
253   if (image->channel_map[MaskPixelChannel].traits == UndefinedPixelTrait)
254     return(0);
255   return(pixel[image->channel_map[MaskPixelChannel].offset]);
256 }
257
258 static inline PixelTrait GetPixelMaskTraits(const Image *restrict image)
259 {
260   return(image->channel_map[MaskPixelChannel].traits);
261 }
262
263 static inline size_t GetPixelMetaChannels(const Image *restrict image)
264 {
265   return(image->number_meta_channels);
266 }
267
268 static inline size_t GetPixelMetacontentExtent(const Image *restrict image)
269 {
270   return(image->metacontent_extent);
271 }
272
273 static inline Quantum GetPixelOpacity(const Image *restrict image,
274   const Quantum *restrict pixel)
275 {
276   if (image->channel_map[AlphaPixelChannel].traits == UndefinedPixelTrait)
277     return(QuantumRange-OpaqueAlpha);
278   return(QuantumRange-pixel[image->channel_map[AlphaPixelChannel].offset]);
279 }
280
281 static inline Quantum GetPixelRed(const Image *restrict image,
282   const Quantum *restrict pixel)
283 {
284   return(pixel[image->channel_map[RedPixelChannel].offset]);
285 }
286
287 static inline PixelTrait GetPixelRedTraits(const Image *restrict image)
288 {
289   return(image->channel_map[RedPixelChannel].traits);
290 }
291
292 static inline void GetPixelInfoPixel(const Image *restrict image,
293   const Quantum *restrict pixel,PixelInfo *restrict pixel_info)
294 {
295   pixel_info->red=(double)
296     pixel[image->channel_map[RedPixelChannel].offset];
297   pixel_info->green=(double)
298     pixel[image->channel_map[GreenPixelChannel].offset];
299   pixel_info->blue=(double)
300     pixel[image->channel_map[BluePixelChannel].offset];
301   pixel_info->black=0;
302   if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
303     pixel_info->black=(double)
304       pixel[image->channel_map[BlackPixelChannel].offset];
305   pixel_info->alpha=OpaqueAlpha;
306   if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
307     pixel_info->alpha=(double)
308       pixel[image->channel_map[AlphaPixelChannel].offset];
309   pixel_info->index=0;
310   if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
311     pixel_info->index=(double)
312       pixel[image->channel_map[IndexPixelChannel].offset];
313 }
314
315 static inline PixelTrait GetPixelTraits(const Image *restrict image,
316   const PixelChannel channel)
317 {
318   return(image->channel_map[channel].traits);
319 }
320
321 static inline Quantum GetPixelY(const Image *restrict image,
322   const Quantum *restrict pixel)
323 {
324   return(pixel[image->channel_map[YPixelChannel].offset]);
325 }
326
327 static inline PixelTrait GetPixelYTraits(const Image *restrict image)
328 {
329   return(image->channel_map[YPixelChannel].traits);
330 }
331
332 static inline Quantum GetPixelYellow(const Image *restrict image,
333   const Quantum *restrict pixel)
334 {
335   return(pixel[image->channel_map[YellowPixelChannel].offset]);
336 }
337
338 static inline PixelTrait GetPixelYellowTraits(const Image *restrict image)
339 {
340   return(image->channel_map[YellowPixelChannel].traits);
341 }
342
343 static inline MagickBooleanType IsPixelEquivalent(const Image *restrict image,
344   const Quantum *restrict p,const PixelInfo *restrict q)
345 {
346   if (((double) p[image->channel_map[RedPixelChannel].offset] == q->red) &&
347       ((double) p[image->channel_map[GreenPixelChannel].offset] == q->green) &&
348       ((double) p[image->channel_map[BluePixelChannel].offset] == q->blue))
349     return(MagickTrue);
350   return(MagickFalse);
351 }
352
353 static inline MagickBooleanType IsPixelGray(const Image *restrict image,
354   const Quantum *restrict pixel)
355 {
356 #if !defined(MAGICKCORE_HDRI_SUPPORT)
357   if ((pixel[image->channel_map[RedPixelChannel].offset] ==
358        pixel[image->channel_map[GreenPixelChannel].offset]) &&
359       (pixel[image->channel_map[GreenPixelChannel].offset] ==
360        pixel[image->channel_map[BluePixelChannel].offset]))
361     return(MagickTrue);
362 #else
363   {
364     double
365       alpha,
366       beta;
367
368     alpha=pixel[image->channel_map[RedPixelChannel].offset]-(double)
369       pixel[image->channel_map[GreenPixelChannel].offset];
370     beta=pixel[image->channel_map[GreenPixelChannel].offset]-(double)
371       pixel[image->channel_map[BluePixelChannel].offset];
372     if ((fabs(alpha) <= MagickEpsilon) && (fabs(beta) <= MagickEpsilon))
373       return(MagickTrue);
374   }
375 #endif
376   return(MagickFalse);
377 }
378
379 static inline MagickBooleanType IsPixelInfoEquivalent(
380   const PixelInfo *restrict p,const PixelInfo *restrict q)
381 {
382   if ((p->matte != MagickFalse) && (q->matte == MagickFalse) &&
383       (fabs(p->alpha-OpaqueAlpha) > 0.5))
384     return(MagickFalse);
385   if ((q->matte != MagickFalse) && (p->matte == MagickFalse) &&
386       (fabs(q->alpha-OpaqueAlpha)) > 0.5)
387     return(MagickFalse);
388   if ((p->matte != MagickFalse) && (q->matte != MagickFalse))
389     {
390       if (fabs(p->alpha-q->alpha) > 0.5)
391         return(MagickFalse);
392       if (fabs(p->alpha-TransparentAlpha) <= 0.5)
393         return(MagickTrue);
394     }
395   if (fabs(p->red-q->red) > 0.5)
396     return(MagickFalse);
397   if (fabs(p->green-q->green) > 0.5)
398     return(MagickFalse);
399   if (fabs(p->blue-q->blue) > 0.5)
400     return(MagickFalse);
401   if ((p->colorspace == CMYKColorspace) && (fabs(p->black-q->black) > 0.5))
402     return(MagickFalse);
403   return(MagickTrue);
404 }
405
406 static inline MagickBooleanType IsPixelMonochrome(const Image *restrict image,
407   const Quantum *restrict pixel)
408 {
409 #if !defined(MAGICKCORE_HDRI_SUPPORT)
410   if (((pixel[image->channel_map[RedPixelChannel].offset] == 0) ||
411       (pixel[image->channel_map[RedPixelChannel].offset] == (Quantum) QuantumRange)) &&
412       (pixel[image->channel_map[RedPixelChannel].offset] ==
413        pixel[image->channel_map[GreenPixelChannel].offset]) &&
414       (pixel[image->channel_map[GreenPixelChannel].offset] ==
415        pixel[image->channel_map[BluePixelChannel].offset]))
416     return(MagickTrue);
417 #else
418   {
419     double
420       alpha,
421       beta;
422
423     alpha=pixel[image->channel_map[RedPixelChannel].offset]-(double)
424       pixel[image->channel_map[GreenPixelChannel].offset];
425     beta=pixel[image->channel_map[GreenPixelChannel].offset]-(double)
426       pixel[image->channel_map[BluePixelChannel].offset];
427     if (((fabs(pixel[image->channel_map[RedPixelChannel].offset]) <= MagickEpsilon) ||
428          (fabs(pixel[image->channel_map[RedPixelChannel].offset]-QuantumRange) <= MagickEpsilon)) &&
429         (fabs(alpha) <= MagickEpsilon) && (fabs(beta) <= MagickEpsilon))
430       return(MagickTrue);
431     }
432 #endif
433   return(MagickFalse);
434 }
435
436 static inline MagickBooleanType IsPixelInfoGray(
437   const PixelInfo *restrict pixel_info)
438 {
439 #if !defined(MAGICKCORE_HDRI_SUPPORT)
440   if ((pixel_info->red == pixel_info->green) &&
441       (pixel_info->green == pixel_info->blue))
442     return(MagickTrue);
443 #else
444   {
445     double
446       alpha,
447       beta;
448
449     alpha=pixel_info->red-(double) pixel_info->green;
450     beta=pixel_info->green-(double) pixel_info->blue;
451     if ((fabs(alpha) <= MagickEpsilon) && (fabs(beta) <= MagickEpsilon))
452       return(MagickTrue);
453   }
454 #endif
455   return(MagickFalse);
456 }
457
458 static inline MagickBooleanType IsPixelInfoMonochrome(
459   const PixelInfo *restrict pixel_info)
460 {
461 #if !defined(MAGICKCORE_HDRI_SUPPORT)
462   if (((pixel_info->red == 0) || (pixel_info->red == (Quantum) QuantumRange)) &&
463       (pixel_info->red == pixel_info->green) &&
464       (pixel_info->green == pixel_info->blue))
465     return(MagickTrue);
466 #else
467   {
468     double
469       alpha,
470       beta;
471
472     alpha=pixel_info->red-(double) pixel_info->green;
473     beta=pixel_info->green-(double) pixel_info->blue;
474     if (((fabs(pixel_info->red) <= MagickEpsilon) ||
475          (fabs(pixel_info->red-QuantumRange) <= MagickEpsilon)) &&
476         (fabs(alpha) <= MagickEpsilon) && (fabs(beta) <= MagickEpsilon))
477       return(MagickTrue);
478     }
479 #endif
480   return(MagickFalse);
481 }
482
483 static inline void SetPixelAlpha(const Image *restrict image,
484   const Quantum alpha,Quantum *restrict pixel)
485 {
486   if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
487     pixel[image->channel_map[AlphaPixelChannel].offset]=alpha;
488 }
489
490 static inline void SetPixelAlphaTraits(Image *image,const PixelTrait traits)
491 {
492   image->channel_map[AlphaPixelChannel].traits=traits;
493 }
494
495 static inline void SetPixelBlack(const Image *restrict image,
496   const Quantum black,Quantum *restrict pixel)
497 {
498   if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
499     pixel[image->channel_map[BlackPixelChannel].offset]=black;
500 }
501
502 static inline void SetPixelBlackTraits(Image *image,const PixelTrait traits)
503 {
504   image->channel_map[BlackPixelChannel].traits=traits;
505 }
506
507 static inline void SetPixelBlue(const Image *restrict image,const Quantum blue,
508   Quantum *restrict pixel)
509 {
510   pixel[image->channel_map[BluePixelChannel].offset]=blue;
511 }
512
513 static inline void SetPixelBlueTraits(Image *image,const PixelTrait traits)
514 {
515   image->channel_map[BluePixelChannel].traits=traits;
516 }
517
518 static inline void SetPixelCb(const Image *restrict image,const Quantum cb,
519   Quantum *restrict pixel)
520 {
521   pixel[image->channel_map[CbPixelChannel].offset]=cb;
522 }
523
524 static inline void SetPixelCbTraits(Image *image,const PixelTrait traits)
525 {
526   image->channel_map[CbPixelChannel].traits=traits;
527 }
528
529 static inline void SetPixelChannel(const Image *restrict image,
530   const PixelChannel channel,const Quantum quantum,Quantum *restrict pixel)
531 {
532   if (image->channel_map[channel].traits != UndefinedPixelTrait)
533     pixel[image->channel_map[channel].offset]=quantum;
534 }
535
536 static inline void SetPixelChannelMapChannel(const Image *restrict image,
537   const PixelChannel channel,const ssize_t offset)
538 {
539   image->channel_map[offset].channel=channel;
540   image->channel_map[channel].offset=offset;
541 }
542
543 static inline void SetPixelChannelMap(const Image *restrict image,
544   const PixelChannel channel,const PixelTrait traits,const ssize_t offset)
545 {
546   image->channel_map[offset].channel=channel;
547   image->channel_map[channel].offset=offset;
548   image->channel_map[channel].traits=traits;
549 }
550
551 static inline void SetPixelChannels(Image *image,const size_t number_channels)
552 {
553   image->number_channels=number_channels;
554 }
555
556 static inline void SetPixelChannelTraits(Image *image,
557   const PixelChannel channel,const PixelTrait traits)
558 {
559   image->channel_map[channel].traits=traits;
560 }
561
562 static inline void SetPixelChannelMapTraits(Image *image,
563   const PixelChannel channel,const PixelTrait traits)
564 {
565   image->channel_map[channel].traits=traits;
566 }
567
568 static inline void SetPixelCr(const Image *restrict image,const Quantum cr,
569   Quantum *restrict pixel)
570 {
571   pixel[image->channel_map[CrPixelChannel].offset]=cr;
572 }
573
574 static inline void SetPixelCrTraits(Image *image,const PixelTrait traits)
575 {
576   image->channel_map[CrPixelChannel].traits=traits;
577 }
578
579 static inline void SetPixelCyan(const Image *restrict image,const Quantum cyan,
580   Quantum *restrict pixel)
581 {
582   pixel[image->channel_map[CyanPixelChannel].offset]=cyan;
583 }
584
585 static inline void SetPixelGray(const Image *restrict image,const Quantum gray,
586   Quantum *restrict pixel)
587 {
588   pixel[image->channel_map[GrayPixelChannel].offset]=gray;
589 }
590
591 static inline void SetPixelGrayTraits(Image *image,const PixelTrait traits)
592 {
593   image->channel_map[GrayPixelChannel].traits=traits;
594 }
595
596 static inline void SetPixelGreen(const Image *restrict image,
597   const Quantum green,Quantum *restrict pixel)
598 {
599   pixel[image->channel_map[GreenPixelChannel].offset]=green;
600 }
601
602 static inline void SetPixelGreenTraits(Image *image,const PixelTrait traits)
603 {
604   image->channel_map[GreenPixelChannel].traits=traits;
605 }
606
607 static inline void SetPixelIndex(const Image *restrict image,
608   const Quantum index,Quantum *restrict pixel)
609 {
610   if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
611     pixel[image->channel_map[IndexPixelChannel].offset]=index;
612 }
613
614 static inline void SetPixelIndexTraits(Image *image,const PixelTrait traits)
615 {
616   image->channel_map[IndexPixelChannel].traits=traits;
617 }
618
619 static inline void SetPixelInfoPixel(const Image *restrict image,
620   const PixelInfo *restrict pixel_info,Quantum *restrict pixel)
621 {
622   pixel[image->channel_map[RedPixelChannel].offset]=
623     ClampToQuantum(pixel_info->red);
624   pixel[image->channel_map[GreenPixelChannel].offset]=
625     ClampToQuantum(pixel_info->green);
626   pixel[image->channel_map[BluePixelChannel].offset]=
627     ClampToQuantum(pixel_info->blue);
628   if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
629     pixel[image->channel_map[BlackPixelChannel].offset]=
630       ClampToQuantum(pixel_info->black);
631   if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
632     pixel[image->channel_map[AlphaPixelChannel].offset]=pixel_info->matte ==
633       MagickFalse ? OpaqueAlpha : ClampToQuantum(pixel_info->alpha);
634 }
635
636 static inline void SetPixelMagenta(const Image *restrict image,
637   const Quantum magenta,Quantum *restrict pixel)
638 {
639   pixel[image->channel_map[MagentaPixelChannel].offset]=magenta;
640 }
641
642 static inline void SetPixelMagentaTraits(Image *image,const PixelTrait traits)
643 {
644   image->channel_map[MagentaPixelChannel].traits=traits;
645 }
646
647 static inline void SetPixelMask(const Image *restrict image,
648   const Quantum mask,Quantum *restrict pixel)
649 {
650   if (image->channel_map[MaskPixelChannel].traits != UndefinedPixelTrait)
651     pixel[image->channel_map[MaskPixelChannel].offset]=mask;
652 }
653
654 static inline void SetPixelMetacontentExtent(Image *image,const size_t extent)
655 {
656   image->metacontent_extent=extent;
657 }
658
659 static inline void SetPixelOpacity(const Image *restrict image,
660   const Quantum alpha,Quantum *restrict pixel)
661 {
662   if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
663     pixel[image->channel_map[AlphaPixelChannel].offset]=QuantumRange-alpha;
664 }
665
666 static inline void SetPixelRed(const Image *restrict image,const Quantum red,
667   Quantum *restrict pixel)
668 {
669   pixel[image->channel_map[RedPixelChannel].offset]=red;
670 }
671
672 static inline void SetPixelRedTraits(Image *image,const PixelTrait traits)
673 {
674   image->channel_map[RedPixelChannel].traits=traits;
675 }
676
677 static inline void SetPixelYellow(const Image *restrict image,
678   const Quantum yellow,Quantum *restrict pixel)
679 {
680   pixel[image->channel_map[YellowPixelChannel].offset]=yellow;
681 }
682
683 static inline void SetPixelYellowTraits(Image *image,const PixelTrait traits)
684 {
685   image->channel_map[YellowPixelChannel].traits=traits;
686 }
687
688 static inline void SetPixelY(const Image *restrict image,const Quantum y,
689   Quantum *restrict pixel)
690 {
691   pixel[image->channel_map[YPixelChannel].offset]=y;
692 }
693
694 static inline void SetPixelYTraits(Image *image,const PixelTrait traits)
695 {
696   image->channel_map[YPixelChannel].traits=traits;
697 }
698
699 #if defined(__cplusplus) || defined(c_plusplus)
700 }
701 #endif
702
703 #endif