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