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