MagickCore  7.0.7
Convert, Edit, Or Compose Bitmap Images
pixel-accessor.h
Go to the documentation of this file.
1 /*
2  Copyright 1999-2018 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  https://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 #include <assert.h>
22 #include "MagickCore/cache.h"
23 #include "MagickCore/cache-view.h"
24 #include "MagickCore/color.h"
25 #include "MagickCore/colorspace.h"
26 #include "MagickCore/gem.h"
27 #include "MagickCore/image.h"
28 
29 #if defined(__cplusplus) || defined(c_plusplus)
30 extern "C" {
31 #endif
32 
33 #undef index
34 
35 static inline Quantum ClampPixel(const MagickRealType pixel)
36 {
37  if (pixel < 0.0f)
38  return((Quantum) 0);
39  if (pixel >= (MagickRealType) QuantumRange)
40  return((Quantum) QuantumRange);
41 #if !defined(MAGICKCORE_HDRI_SUPPORT)
42  return((Quantum) (pixel+0.5f));
43 #else
44  return((Quantum) pixel);
45 #endif
46 }
47 
48 static inline Quantum GetPixela(const Image *magick_restrict image,
49  const Quantum *magick_restrict pixel)
50 {
51  return(pixel[image->channel_map[aPixelChannel].offset]);
52 }
53 
54 static inline Quantum GetPixelAlpha(const Image *magick_restrict image,
55  const Quantum *magick_restrict pixel)
56 {
57  if (image->channel_map[AlphaPixelChannel].traits == UndefinedPixelTrait)
58  return(OpaqueAlpha);
59  return(pixel[image->channel_map[AlphaPixelChannel].offset]);
60 }
61 
63  const Image *magick_restrict image)
64 {
65  return(image->channel_map[AlphaPixelChannel].traits);
66 }
67 
68 static inline Quantum GetPixelb(const Image *magick_restrict image,
69  const Quantum *magick_restrict pixel)
70 {
71  return(pixel[image->channel_map[bPixelChannel].offset]);
72 }
73 
74 static inline Quantum GetPixelBlack(const Image *magick_restrict image,
75  const Quantum *magick_restrict pixel)
76 {
77  if (image->channel_map[BlackPixelChannel].traits == UndefinedPixelTrait)
78  return((Quantum) 0);
79  return(pixel[image->channel_map[BlackPixelChannel].offset]);
80 }
81 
83  const Image *magick_restrict image)
84 {
85  return(image->channel_map[BlackPixelChannel].traits);
86 }
87 
88 static inline Quantum GetPixelBlue(const Image *magick_restrict image,
89  const Quantum *magick_restrict pixel)
90 {
91  return(pixel[image->channel_map[BluePixelChannel].offset]);
92 }
93 
95 {
96  return(image->channel_map[BluePixelChannel].traits);
97 }
98 
99 static inline Quantum GetPixelCb(const Image *magick_restrict image,
100  const Quantum *magick_restrict pixel)
101 {
102  return(pixel[image->channel_map[CbPixelChannel].offset]);
103 }
104 
106 {
107  return(image->channel_map[CbPixelChannel].traits);
108 }
109 
110 static inline Quantum GetPixelChannel(const Image *magick_restrict image,
111  const PixelChannel channel,const Quantum *magick_restrict pixel)
112 {
113  if (image->channel_map[channel].traits == UndefinedPixelTrait)
114  return((Quantum) 0);
115  return(pixel[image->channel_map[channel].offset]);
116 }
117 
119  const Image *magick_restrict image,const ssize_t offset)
120 {
121  return(image->channel_map[offset].channel);
122 }
123 
124 static inline ssize_t GetPixelChannelOffset(const Image *magick_restrict image,
125  const PixelChannel channel)
126 {
127  return(image->channel_map[channel].offset);
128 }
129 
131  const Image *magick_restrict image,const PixelChannel channel)
132 {
133  return(image->channel_map[channel].traits);
134 }
135 
136 static inline size_t GetPixelChannels(const Image *magick_restrict image)
137 {
138  return(image->number_channels);
139 }
140 
141 static inline Quantum GetPixelCr(const Image *magick_restrict image,
142  const Quantum *magick_restrict pixel)
143 {
144  return(pixel[image->channel_map[CrPixelChannel].offset]);
145 }
146 
148 {
149  return(image->channel_map[CrPixelChannel].traits);
150 }
151 
152 static inline Quantum GetPixelCyan(const Image *magick_restrict image,
153  const Quantum *magick_restrict pixel)
154 {
155  return(pixel[image->channel_map[CyanPixelChannel].offset]);
156 }
157 
159 {
160  return(image->channel_map[CyanPixelChannel].traits);
161 }
162 
163 static inline Quantum GetPixelGray(const Image *magick_restrict image,
164  const Quantum *magick_restrict pixel)
165 {
166  return(pixel[image->channel_map[GrayPixelChannel].offset]);
167 }
168 
170 {
171  return(image->channel_map[GrayPixelChannel].traits);
172 }
173 
174 static inline Quantum GetPixelGreen(const Image *magick_restrict image,
175  const Quantum *magick_restrict pixel)
176 {
177  return(pixel[image->channel_map[GreenPixelChannel].offset]);
178 }
179 
181  const Image *magick_restrict image)
182 {
183  return(image->channel_map[GreenPixelChannel].traits);
184 }
185 
186 static inline Quantum GetPixelIndex(const Image *magick_restrict image,
187  const Quantum *magick_restrict pixel)
188 {
189  if (image->channel_map[IndexPixelChannel].traits == UndefinedPixelTrait)
190  return((Quantum) 0);
191  return(pixel[image->channel_map[IndexPixelChannel].offset]);
192 }
193 
195  const Image *magick_restrict image)
196 {
197  return(image->channel_map[IndexPixelChannel].traits);
198 }
199 
201  const PixelInfo *magick_restrict pixel_info,const PixelChannel channel)
202 {
203  switch (channel)
204  {
205  case RedPixelChannel: return(pixel_info->red);
206  case GreenPixelChannel: return(pixel_info->green);
207  case BluePixelChannel: return(pixel_info->blue);
208  case BlackPixelChannel: return(pixel_info->black);
209  case AlphaPixelChannel: return(pixel_info->alpha);
210  case IndexPixelChannel: return(pixel_info->index);
211  default: return((MagickRealType) 0.0);
212  }
213 }
214 
215 static inline double PerceptibleReciprocal(const double x)
216 {
217  double
218  sign;
219 
220  /*
221  Return 1/x where x is perceptible (not unlimited or infinitesimal).
222  */
223  sign=x < 0.0 ? -1.0 : 1.0;
224  if ((sign*x) >= MagickEpsilon)
225  return(1.0/x);
226  return(sign/MagickEpsilon);
227 }
228 
230  const PixelInfo *magick_restrict pixel)
231 {
233  intensity;
234 
235  if (pixel->colorspace == sRGBColorspace)
236  {
237  intensity=(MagickRealType) (0.212656f*pixel->red+0.715158f*pixel->green+
238  0.072186f*pixel->blue);
239  return(intensity);
240  }
241  intensity=(MagickRealType) (0.212656f*EncodePixelGamma(pixel->red)+
242  0.715158f*EncodePixelGamma(pixel->green)+
243  0.072186f*EncodePixelGamma(pixel->blue));
244  return(intensity);
245 }
246 
248  const PixelInfo *magick_restrict pixel)
249 {
251  intensity;
252 
253  if (pixel->colorspace != sRGBColorspace)
254  {
255  intensity=(MagickRealType) (0.212656f*pixel->red+0.715158f*pixel->green+
256  0.072186f*pixel->blue);
257  return(intensity);
258  }
259  intensity=(MagickRealType) (0.212656f*DecodePixelGamma(pixel->red)+
260  0.715158f*DecodePixelGamma(pixel->green)+
261  0.072186f*DecodePixelGamma(pixel->blue));
262  return(intensity);
263 }
264 
265 static inline Quantum GetPixelL(const Image *magick_restrict image,
266  const Quantum *magick_restrict pixel)
267 {
268  return(pixel[image->channel_map[LPixelChannel].offset]);
269 }
270 
271 static inline ssize_t GetPixelLabel(const Image *magick_restrict image,
272  const Quantum *magick_restrict pixel)
273 {
274  return((ssize_t) pixel[image->channel_map[LabelPixelChannel].offset]);
275 }
276 
278  const Quantum *magick_restrict pixel)
279 {
281  intensity;
282 
283  intensity=(MagickRealType) (
284  0.212656f*pixel[image->channel_map[RedPixelChannel].offset]+
285  0.715158f*pixel[image->channel_map[GreenPixelChannel].offset]+
286  0.072186f*pixel[image->channel_map[BluePixelChannel].offset]);
287  return(intensity);
288 }
289 
291  const Image *magick_restrict image,const Quantum *magick_restrict pixel)
292 {
294  intensity;
295 
296  if (image->colorspace != sRGBColorspace)
297  {
298  intensity=(MagickRealType) (
299  0.212656f*pixel[image->channel_map[RedPixelChannel].offset]+
300  0.715158f*pixel[image->channel_map[GreenPixelChannel].offset]+
301  0.072186f*pixel[image->channel_map[BluePixelChannel].offset]);
302  return(intensity);
303  }
304  intensity=(MagickRealType) (0.212656f*DecodePixelGamma((MagickRealType)
305  pixel[image->channel_map[RedPixelChannel].offset])+0.715158f*
307  pixel[image->channel_map[GreenPixelChannel].offset])+0.072186f*
309  pixel[image->channel_map[BluePixelChannel].offset]));
310  return(intensity);
311 }
312 
313 static inline Quantum GetPixelMagenta(const Image *magick_restrict image,
314  const Quantum *magick_restrict pixel)
315 {
316  return(pixel[image->channel_map[MagentaPixelChannel].offset]);
317 }
318 
320  const Image *magick_restrict image)
321 {
322  return(image->channel_map[MagentaPixelChannel].traits);
323 }
324 
325 static inline Quantum GetPixelReadMask(const Image *magick_restrict image,
326  const Quantum *magick_restrict pixel)
327 {
328  if (image->channel_map[ReadMaskPixelChannel].traits == UndefinedPixelTrait)
329  return((Quantum) QuantumRange);
330  return(pixel[image->channel_map[ReadMaskPixelChannel].offset]);
331 }
332 
333 static inline Quantum GetPixelWriteMask(const Image *magick_restrict image,
334  const Quantum *magick_restrict pixel)
335 {
336  if (image->channel_map[WriteMaskPixelChannel].traits == UndefinedPixelTrait)
337  return((Quantum) QuantumRange);
338  return(pixel[image->channel_map[WriteMaskPixelChannel].offset]);
339 }
340 
342  const Image *magick_restrict image)
343 {
344  return(image->channel_map[ReadMaskPixelChannel].traits);
345 }
346 
347 static inline size_t GetPixelMetaChannels(const Image *magick_restrict image)
348 {
349  return(image->number_meta_channels);
350 }
351 
352 static inline size_t GetPixelMetacontentExtent(
353  const Image *magick_restrict image)
354 {
355  return(image->metacontent_extent);
356 }
357 
358 static inline Quantum GetPixelOpacity(const Image *magick_restrict image,
359  const Quantum *magick_restrict pixel)
360 {
361  if (image->channel_map[AlphaPixelChannel].traits != BlendPixelTrait)
362  return(QuantumRange-OpaqueAlpha);
363  return(QuantumRange-pixel[image->channel_map[AlphaPixelChannel].offset]);
364 }
365 
366 static inline Quantum GetPixelRed(const Image *magick_restrict image,
367  const Quantum *magick_restrict pixel)
368 {
369  return(pixel[image->channel_map[RedPixelChannel].offset]);
370 }
371 
373 {
374  return(image->channel_map[RedPixelChannel].traits);
375 }
376 
377 static inline void GetPixelInfoPixel(const Image *magick_restrict image,
378  const Quantum *magick_restrict pixel,PixelInfo *magick_restrict pixel_info)
379 {
380  pixel_info->storage_class=image->storage_class;
381  pixel_info->colorspace=image->colorspace;
382  pixel_info->fuzz=image->fuzz;
383  pixel_info->depth=image->depth;
384  pixel_info->red=(MagickRealType)
385  pixel[image->channel_map[RedPixelChannel].offset];
386  pixel_info->green=(MagickRealType)
387  pixel[image->channel_map[GreenPixelChannel].offset];
388  pixel_info->blue=(MagickRealType)
389  pixel[image->channel_map[BluePixelChannel].offset];
390  pixel_info->black=0.0f;
391  if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
392  pixel_info->black=(MagickRealType)
393  pixel[image->channel_map[BlackPixelChannel].offset];
394  pixel_info->alpha=(MagickRealType) OpaqueAlpha;
395  pixel_info->alpha_trait=UndefinedPixelTrait;
396  if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
397  {
398  pixel_info->alpha=(MagickRealType)
399  pixel[image->channel_map[AlphaPixelChannel].offset];
400  pixel_info->alpha_trait=BlendPixelTrait;
401  }
402  pixel_info->index=0.0f;
403  if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
404  pixel_info->index=(MagickRealType)
405  pixel[image->channel_map[IndexPixelChannel].offset];
406  pixel_info->count=0;
407 }
408 
409 static inline PixelTrait GetPixelTraits(const Image *magick_restrict image,
410  const PixelChannel channel)
411 {
412  return(image->channel_map[channel].traits);
413 }
414 
415 static inline Quantum GetPixelY(const Image *magick_restrict image,
416  const Quantum *magick_restrict pixel)
417 {
418  return(pixel[image->channel_map[YPixelChannel].offset]);
419 }
420 
421 static inline PixelTrait GetPixelYTraits(const Image *magick_restrict image)
422 {
423  return(image->channel_map[YPixelChannel].traits);
424 }
425 
426 static inline Quantum GetPixelYellow(const Image *magick_restrict image,
427  const Quantum *magick_restrict pixel)
428 {
429  return(pixel[image->channel_map[YellowPixelChannel].offset]);
430 }
431 
433  const Image *magick_restrict image)
434 {
435  return(image->channel_map[YellowPixelChannel].traits);
436 }
437 
439 {
440  return(x < 0.0f ? -x : x);
441 }
442 
443 static inline MagickBooleanType IsPixelAtDepth(const Quantum pixel,
444  const QuantumAny range)
445 {
446  Quantum
447  quantum;
448 
449 #if !defined(MAGICKCORE_HDRI_SUPPORT)
451  (((MagickRealType) range*pixel)/QuantumRange+0.5)))/range+0.5);
452 #else
454  (((MagickRealType) range*pixel)/QuantumRange+0.5)))/range);
455 #endif
456  return(pixel == quantum ? MagickTrue : MagickFalse);
457 }
458 
460  const Image *magick_restrict image,const Quantum *magick_restrict p,
461  const PixelInfo *magick_restrict q)
462 {
464  alpha,
465  beta,
466  color;
467 
468  color=(MagickRealType) p[image->channel_map[AlphaPixelChannel].offset];
469  alpha=image->alpha_trait == UndefinedPixelTrait ? (MagickRealType)
470  OpaqueAlpha : color;
471  beta=q->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
472  q->alpha;
473  if (AbsolutePixelValue(alpha-beta) >= MagickEpsilon)
474  return(MagickFalse);
477  return(MagickTrue); /* no color component if pixel is transparent */
478  color=(MagickRealType) p[image->channel_map[RedPixelChannel].offset];
479  if (AbsolutePixelValue(color-q->red) >= MagickEpsilon)
480  return(MagickFalse);
481  color=(MagickRealType) p[image->channel_map[GreenPixelChannel].offset];
482  if (AbsolutePixelValue(color-q->green) >= MagickEpsilon)
483  return(MagickFalse);
484  color=(MagickRealType) p[image->channel_map[BluePixelChannel].offset];
485  if (AbsolutePixelValue(color-q->blue) >= MagickEpsilon)
486  return(MagickFalse);
487  if (image->colorspace == CMYKColorspace)
488  {
489  color=(MagickRealType) p[image->channel_map[BlackPixelChannel].offset];
490  if (AbsolutePixelValue(color-q->black) >= MagickEpsilon)
491  return(MagickFalse);
492  }
493  return(MagickTrue);
494 }
495 
497  const Quantum *magick_restrict pixel)
498 {
500  green_blue,
501  red_green;
502 
503  red_green=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]-
504  pixel[image->channel_map[GreenPixelChannel].offset];
505  green_blue=(MagickRealType)
506  pixel[image->channel_map[GreenPixelChannel].offset]-
507  pixel[image->channel_map[BluePixelChannel].offset];
508  if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
509  (AbsolutePixelValue(green_blue) < MagickEpsilon))
510  return(MagickTrue);
511  return(MagickFalse);
512 }
513 
516 {
518  alpha,
519  beta;
520 
521  alpha=p->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
522  p->alpha;
523  beta=q->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
524  q->alpha;
525  if (AbsolutePixelValue(alpha-beta) >= MagickEpsilon)
526  return(MagickFalse);
529  return(MagickTrue); /* no color component if pixel is transparent */
530  if (AbsolutePixelValue(p->red-q->red) >= MagickEpsilon)
531  return(MagickFalse);
532  if (AbsolutePixelValue(p->green-q->green) >= MagickEpsilon)
533  return(MagickFalse);
534  if (AbsolutePixelValue(p->blue-q->blue) >= MagickEpsilon)
535  return(MagickFalse);
536  if (p->colorspace == CMYKColorspace)
537  {
538  if (AbsolutePixelValue(p->black-q->black) >= MagickEpsilon)
539  return(MagickFalse);
540  }
541  return(MagickTrue);
542 }
543 
545  const Image *magick_restrict image,const Quantum *magick_restrict pixel)
546 {
548  green_blue,
549  red,
550  red_green;
551 
552  red=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset];
553  if ((AbsolutePixelValue(red) >= MagickEpsilon) &&
555  return(MagickFalse);
556  red_green=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]-
557  pixel[image->channel_map[GreenPixelChannel].offset];
558  green_blue=(MagickRealType)
559  pixel[image->channel_map[GreenPixelChannel].offset]-
560  pixel[image->channel_map[BluePixelChannel].offset];
561  if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
562  (AbsolutePixelValue(green_blue) < MagickEpsilon))
563  return(MagickTrue);
564  return(MagickFalse);
565 }
566 
568  const PixelInfo *magick_restrict pixel)
569 {
570  if ((AbsolutePixelValue(pixel->red-pixel->green) < MagickEpsilon) &&
571  (AbsolutePixelValue(pixel->green-pixel->blue) < MagickEpsilon))
572  return(MagickTrue);
573  return(MagickFalse);
574 }
575 
577  const PixelInfo *magick_restrict pixel_info)
578 {
580  green_blue,
581  red_green;
582 
583  if ((AbsolutePixelValue(pixel_info->red) >= MagickEpsilon) ||
584  (AbsolutePixelValue(pixel_info->red-QuantumRange) >= MagickEpsilon))
585  return(MagickFalse);
586  red_green=pixel_info->red-pixel_info->green;
587  green_blue=pixel_info->green-pixel_info->blue;
588  if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
589  (AbsolutePixelValue(green_blue) < MagickEpsilon))
590  return(MagickTrue);
591  return(MagickFalse);
592 }
593 
594 static inline void SetPixela(const Image *magick_restrict image,
595  const Quantum a,Quantum *magick_restrict pixel)
596 {
597  if (image->channel_map[aPixelChannel].traits != UndefinedPixelTrait)
598  pixel[image->channel_map[aPixelChannel].offset]=a;
599 }
600 
601 static inline void SetPixelAlpha(const Image *magick_restrict image,
602  const Quantum alpha,Quantum *magick_restrict pixel)
603 {
604  if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
605  pixel[image->channel_map[AlphaPixelChannel].offset]=alpha;
606 }
607 
608 static inline void SetPixelAlphaTraits(Image *image,const PixelTrait traits)
609 {
610  image->channel_map[AlphaPixelChannel].traits=traits;
611 }
612 
613 static inline void SetPixelb(const Image *magick_restrict image,
614  const Quantum b,Quantum *magick_restrict pixel)
615 {
616  if (image->channel_map[bPixelChannel].traits != UndefinedPixelTrait)
617  pixel[image->channel_map[bPixelChannel].offset]=b;
618 }
619 
620 static inline void SetPixelBackgoundColor(const Image *magick_restrict image,
621  Quantum *magick_restrict pixel)
622 {
623  register ssize_t
624  i;
625 
626  for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
627  pixel[i]=(Quantum) 0;
628  pixel[image->channel_map[RedPixelChannel].offset]=
629  ClampToQuantum(image->background_color.red);
630  pixel[image->channel_map[GreenPixelChannel].offset]=
631  ClampToQuantum(image->background_color.green);
632  pixel[image->channel_map[BluePixelChannel].offset]=
633  ClampToQuantum(image->background_color.blue);
634  if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
635  pixel[image->channel_map[BlackPixelChannel].offset]=
636  ClampToQuantum(image->background_color.black);
637  if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
638  pixel[image->channel_map[AlphaPixelChannel].offset]=
639  image->background_color.alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
640  ClampToQuantum(image->background_color.alpha);
641 }
642 
643 static inline void SetPixelBlack(const Image *magick_restrict image,
644  const Quantum black,Quantum *magick_restrict pixel)
645 {
646  if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
647  pixel[image->channel_map[BlackPixelChannel].offset]=black;
648 }
649 
650 static inline void SetPixelBlackTraits(Image *image,const PixelTrait traits)
651 {
652  image->channel_map[BlackPixelChannel].traits=traits;
653 }
654 
655 static inline void SetPixelBlue(const Image *magick_restrict image,
656  const Quantum blue,Quantum *magick_restrict pixel)
657 {
658  pixel[image->channel_map[BluePixelChannel].offset]=blue;
659 }
660 
661 static inline void SetPixelBlueTraits(Image *image,const PixelTrait traits)
662 {
663  image->channel_map[BluePixelChannel].traits=traits;
664 }
665 
666 static inline void SetPixelCb(const Image *magick_restrict image,
667  const Quantum cb,Quantum *magick_restrict pixel)
668 {
669  pixel[image->channel_map[CbPixelChannel].offset]=cb;
670 }
671 
672 static inline void SetPixelCbTraits(Image *image,const PixelTrait traits)
673 {
674  image->channel_map[CbPixelChannel].traits=traits;
675 }
676 
677 static inline void SetPixelChannel(const Image *magick_restrict image,
678  const PixelChannel channel,const Quantum quantum,
679  Quantum *magick_restrict pixel)
680 {
681  if (image->channel_map[channel].traits != UndefinedPixelTrait)
682  pixel[image->channel_map[channel].offset]=quantum;
683 }
684 
685 static inline void SetPixelChannelAttributes(
686  const Image *magick_restrict image,const PixelChannel channel,
687  const PixelTrait traits,const ssize_t offset)
688 {
689  assert((ssize_t) channel < MaxPixelChannels);
690  assert(offset < MaxPixelChannels);
691  image->channel_map[offset].channel=channel;
692  image->channel_map[channel].offset=offset;
693  image->channel_map[channel].traits=traits;
694 }
695 
696 static inline void SetPixelChannelChannel(const Image *magick_restrict image,
697  const PixelChannel channel,const ssize_t offset)
698 {
699  image->channel_map[offset].channel=channel;
700  image->channel_map[channel].offset=offset;
701 }
702 
703 static inline void SetPixelChannels(Image *image,const size_t number_channels)
704 {
705  image->number_channels=number_channels;
706 }
707 
708 static inline void SetPixelChannelTraits(Image *image,
709  const PixelChannel channel,const PixelTrait traits)
710 {
711  image->channel_map[channel].traits=traits;
712 }
713 
714 static inline void SetPixelCr(const Image *magick_restrict image,
715  const Quantum cr,Quantum *magick_restrict pixel)
716 {
717  pixel[image->channel_map[CrPixelChannel].offset]=cr;
718 }
719 
720 static inline void SetPixelCrTraits(Image *image,const PixelTrait traits)
721 {
722  image->channel_map[CrPixelChannel].traits=traits;
723 }
724 
725 static inline void SetPixelCyan(const Image *magick_restrict image,
726  const Quantum cyan,Quantum *magick_restrict pixel)
727 {
728  pixel[image->channel_map[CyanPixelChannel].offset]=cyan;
729 }
730 
731 static inline void SetPixelGray(const Image *magick_restrict image,
732  const Quantum gray,Quantum *magick_restrict pixel)
733 {
734  pixel[image->channel_map[GrayPixelChannel].offset]=gray;
735 }
736 
737 static inline void SetPixelGrayTraits(Image *image,const PixelTrait traits)
738 {
739  image->channel_map[GrayPixelChannel].traits=traits;
740 }
741 
742 static inline void SetPixelGreen(const Image *magick_restrict image,
743  const Quantum green,Quantum *magick_restrict pixel)
744 {
745  pixel[image->channel_map[GreenPixelChannel].offset]=green;
746 }
747 
748 static inline void SetPixelGreenTraits(Image *image,const PixelTrait traits)
749 {
750  image->channel_map[GreenPixelChannel].traits=traits;
751 }
752 
753 static inline void SetPixelIndex(const Image *magick_restrict image,
754  const Quantum index,Quantum *magick_restrict pixel)
755 {
756  if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
757  pixel[image->channel_map[IndexPixelChannel].offset]=index;
758 }
759 
760 static inline void SetPixelIndexTraits(Image *image,const PixelTrait traits)
761 {
762  image->channel_map[IndexPixelChannel].traits=traits;
763 }
764 
765 static inline void SetPixelViaPixelInfo(const Image *magick_restrict image,
766  const PixelInfo *magick_restrict pixel_info,Quantum *magick_restrict pixel)
767 {
768  pixel[image->channel_map[RedPixelChannel].offset]=
769  ClampToQuantum(pixel_info->red);
770  pixel[image->channel_map[GreenPixelChannel].offset]=
771  ClampToQuantum(pixel_info->green);
772  pixel[image->channel_map[BluePixelChannel].offset]=
773  ClampToQuantum(pixel_info->blue);
774  if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
775  pixel[image->channel_map[BlackPixelChannel].offset]=
776  ClampToQuantum(pixel_info->black);
777  if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
778  pixel[image->channel_map[AlphaPixelChannel].offset]=
779  pixel_info->alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
780  ClampToQuantum(pixel_info->alpha);
781 }
782 
783 static inline void SetPixelL(const Image *magick_restrict image,const Quantum L,
784  Quantum *magick_restrict pixel)
785 {
786  if (image->channel_map[LPixelChannel].traits != UndefinedPixelTrait)
787  pixel[image->channel_map[LPixelChannel].offset]=L;
788 }
789 
790 static inline void SetPixelMagenta(const Image *magick_restrict image,
791  const Quantum magenta,Quantum *magick_restrict pixel)
792 {
793  pixel[image->channel_map[MagentaPixelChannel].offset]=magenta;
794 }
795 
796 static inline void SetPixelMagentaTraits(Image *image,const PixelTrait traits)
797 {
798  image->channel_map[MagentaPixelChannel].traits=traits;
799 }
800 
801 static inline void SetPixelReadMask(const Image *magick_restrict image,
802  const Quantum mask,Quantum *magick_restrict pixel)
803 {
804  if (image->channel_map[ReadMaskPixelChannel].traits != UndefinedPixelTrait)
805  pixel[image->channel_map[ReadMaskPixelChannel].offset]=mask;
806 }
807 
808 static inline void SetPixelWriteMask(const Image *magick_restrict image,
809  const Quantum mask,Quantum *magick_restrict pixel)
810 {
811  if (image->channel_map[WriteMaskPixelChannel].traits != UndefinedPixelTrait)
812  pixel[image->channel_map[WriteMaskPixelChannel].offset]=mask;
813 }
814 
815 static inline void SetPixelMetacontentExtent(Image *image,const size_t extent)
816 {
817  image->metacontent_extent=extent;
818 }
819 
820 static inline void SetPixelOpacity(const Image *magick_restrict image,
821  const Quantum alpha,Quantum *magick_restrict pixel)
822 {
823  if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
824  pixel[image->channel_map[AlphaPixelChannel].offset]=QuantumRange-alpha;
825 }
826 
827 static inline void SetPixelRed(const Image *magick_restrict image,
828  const Quantum red,Quantum *magick_restrict pixel)
829 {
830  pixel[image->channel_map[RedPixelChannel].offset]=red;
831 }
832 
833 static inline void SetPixelRedTraits(Image *image,const PixelTrait traits)
834 {
835  image->channel_map[RedPixelChannel].traits=traits;
836 }
837 
838 static inline void SetPixelYellow(const Image *magick_restrict image,
839  const Quantum yellow,Quantum *magick_restrict pixel)
840 {
841  pixel[image->channel_map[YellowPixelChannel].offset]=yellow;
842 }
843 
844 static inline void SetPixelYellowTraits(Image *image,const PixelTrait traits)
845 {
846  image->channel_map[YellowPixelChannel].traits=traits;
847 }
848 
849 static inline void SetPixelY(const Image *magick_restrict image,
850  const Quantum y,Quantum *magick_restrict pixel)
851 {
852  pixel[image->channel_map[YPixelChannel].offset]=y;
853 }
854 
855 static inline void SetPixelYTraits(Image *image,const PixelTrait traits)
856 {
857  image->channel_map[YPixelChannel].traits=traits;
858 }
859 
860 #if defined(__cplusplus) || defined(c_plusplus)
861 }
862 #endif
863 
864 #endif
static void SetPixelChannelChannel(const Image *magick_restrict image, const PixelChannel channel, const ssize_t offset)
#define magick_restrict
Definition: MagickCore.h:41
MagickExport MagickRealType EncodePixelGamma(const MagickRealType pixel)
Definition: pixel.c:446
static size_t GetPixelMetacontentExtent(const Image *magick_restrict image)
MagickDoubleType MagickRealType
Definition: magick-type.h:118
static void SetPixelChannelAttributes(const Image *magick_restrict image, const PixelChannel channel, const PixelTrait traits, const ssize_t offset)
static Quantum GetPixelCyan(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
#define TransparentAlpha
Definition: image.h:26
static ssize_t GetPixelChannelOffset(const Image *magick_restrict image, const PixelChannel channel)
static PixelTrait GetPixelYTraits(const Image *magick_restrict image)
static void SetPixelBlackTraits(Image *image, const PixelTrait traits)
static void SetPixelY(const Image *magick_restrict image, const Quantum y, Quantum *magick_restrict pixel)
static void SetPixelYTraits(Image *image, const PixelTrait traits)
static PixelTrait GetPixelBlackTraits(const Image *magick_restrict image)
static void SetPixelBackgoundColor(const Image *magick_restrict image, Quantum *magick_restrict pixel)
static Quantum GetPixelAlpha(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static PixelTrait GetPixelRedTraits(const Image *magick_restrict image)
static Quantum GetPixelCr(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void SetPixelMetacontentExtent(Image *image, const size_t extent)
static void SetPixelOpacity(const Image *magick_restrict image, const Quantum alpha, Quantum *magick_restrict pixel)
static PixelTrait GetPixelIndexTraits(const Image *magick_restrict image)
static PixelTrait GetPixelAlphaTraits(const Image *magick_restrict image)
static Quantum GetPixelRed(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void SetPixelGrayTraits(Image *image, const PixelTrait traits)
static Quantum GetPixelGray(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void SetPixelYellowTraits(Image *image, const PixelTrait traits)
static void SetPixelGray(const Image *magick_restrict image, const Quantum gray, Quantum *magick_restrict pixel)
#define OpaqueAlpha
Definition: image.h:25
static Quantum GetPixelChannel(const Image *magick_restrict image, const PixelChannel channel, const Quantum *magick_restrict pixel)
static PixelTrait GetPixelChannelTraits(const Image *magick_restrict image, const PixelChannel channel)
static MagickRealType AbsolutePixelValue(const MagickRealType x)
static void SetPixelViaPixelInfo(const Image *magick_restrict image, const PixelInfo *magick_restrict pixel_info, Quantum *magick_restrict pixel)
static Quantum GetPixelReadMask(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static MagickBooleanType IsPixelMonochrome(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static Quantum GetPixela(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void SetPixela(const Image *magick_restrict image, const Quantum a, Quantum *magick_restrict pixel)
static PixelTrait GetPixelCbTraits(const Image *magick_restrict image)
static Quantum GetPixelb(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static MagickRealType GetPixelLuma(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
#define MagickEpsilon
Definition: magick-type.h:110
static MagickBooleanType IsPixelInfoEquivalent(const PixelInfo *magick_restrict p, const PixelInfo *magick_restrict q)
Definition: image.h:151
MagickExport MagickRealType DecodePixelGamma(const MagickRealType pixel)
Definition: pixel.c:319
static void SetPixelChannelTraits(Image *image, const PixelChannel channel, const PixelTrait traits)
static MagickBooleanType IsPixelEquivalent(const Image *magick_restrict image, const Quantum *magick_restrict p, const PixelInfo *magick_restrict q)
static Quantum ClampPixel(const MagickRealType pixel)
static void SetPixelRedTraits(Image *image, const PixelTrait traits)
static MagickBooleanType IsPixelInfoMonochrome(const PixelInfo *magick_restrict pixel_info)
static Quantum GetPixelY(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void SetPixelAlphaTraits(Image *image, const PixelTrait traits)
MagickBooleanType
Definition: magick-type.h:156
static double PerceptibleReciprocal(const double x)
static Quantum GetPixelWriteMask(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void SetPixelChannels(Image *image, const size_t number_channels)
static void SetPixelL(const Image *magick_restrict image, const Quantum L, Quantum *magick_restrict pixel)
static PixelTrait GetPixelReadMaskTraits(const Image *magick_restrict image)
static Quantum GetPixelOpacity(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static Quantum GetPixelMagenta(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void SetPixelMagentaTraits(Image *image, const PixelTrait traits)
static MagickBooleanType IsPixelAtDepth(const Quantum pixel, const QuantumAny range)
static PixelTrait GetPixelCrTraits(const Image *magick_restrict image)
static Quantum GetPixelGreen(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void GetPixelInfoPixel(const Image *magick_restrict image, const Quantum *magick_restrict pixel, PixelInfo *magick_restrict pixel_info)
static PixelTrait GetPixelCyanTraits(const Image *magick_restrict image)
static Quantum GetPixelIndex(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static Quantum GetPixelBlack(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void SetPixelCr(const Image *magick_restrict image, const Quantum cr, Quantum *magick_restrict pixel)
static void SetPixelIndexTraits(Image *image, const PixelTrait traits)
static MagickBooleanType IsPixelGray(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void SetPixelMagenta(const Image *magick_restrict image, const Quantum magenta, Quantum *magick_restrict pixel)
static PixelTrait GetPixelGreenTraits(const Image *magick_restrict image)
static PixelTrait GetPixelGrayTraits(const Image *magick_restrict image)
static void SetPixelBlue(const Image *magick_restrict image, const Quantum blue, Quantum *magick_restrict pixel)
static void SetPixelWriteMask(const Image *magick_restrict image, const Quantum mask, Quantum *magick_restrict pixel)
PixelChannel
Definition: pixel.h:66
static void SetPixelCbTraits(Image *image, const PixelTrait traits)
static size_t GetPixelChannels(const Image *magick_restrict image)
static void SetPixelCyan(const Image *magick_restrict image, const Quantum cyan, Quantum *magick_restrict pixel)
static Quantum ClampToQuantum(const MagickRealType value)
Definition: quantum.h:84
static PixelChannel GetPixelChannelChannel(const Image *magick_restrict image, const ssize_t offset)
static MagickRealType GetPixelInfoChannel(const PixelInfo *magick_restrict pixel_info, const PixelChannel channel)
static void SetPixelCrTraits(Image *image, const PixelTrait traits)
static PixelTrait GetPixelMagentaTraits(const Image *magick_restrict image)
unsigned short Quantum
Definition: magick-type.h:82
static size_t GetPixelMetaChannels(const Image *magick_restrict image)
static MagickBooleanType IsPixelInfoGray(const PixelInfo *magick_restrict pixel)
static Quantum GetPixelCb(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void SetPixelIndex(const Image *magick_restrict image, const Quantum index, Quantum *magick_restrict pixel)
size_t number_channels
Definition: image.h:283
static void SetPixelChannel(const Image *magick_restrict image, const PixelChannel channel, const Quantum quantum, Quantum *magick_restrict pixel)
static void SetPixelYellow(const Image *magick_restrict image, const Quantum yellow, Quantum *magick_restrict pixel)
static PixelTrait GetPixelTraits(const Image *magick_restrict image, const PixelChannel channel)
static void SetPixelAlpha(const Image *magick_restrict image, const Quantum alpha, Quantum *magick_restrict pixel)
static MagickRealType GetPixelInfoLuminance(const PixelInfo *magick_restrict pixel)
size_t metacontent_extent
Definition: image.h:283
#define MaxPixelChannels
Definition: pixel.h:27
static void SetPixelGreenTraits(Image *image, const PixelTrait traits)
static MagickRealType GetPixelLuminance(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static PixelTrait GetPixelYellowTraits(const Image *magick_restrict image)
static ssize_t GetPixelLabel(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void SetPixelRed(const Image *magick_restrict image, const Quantum red, Quantum *magick_restrict pixel)
static MagickRealType GetPixelInfoLuma(const PixelInfo *magick_restrict pixel)
PixelTrait traits
Definition: pixel.h:161
static void SetPixelb(const Image *magick_restrict image, const Quantum b, Quantum *magick_restrict pixel)
static Quantum GetPixelYellow(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void SetPixelBlack(const Image *magick_restrict image, const Quantum black, Quantum *magick_restrict pixel)
static Quantum GetPixelBlue(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
PixelTrait
Definition: pixel.h:132
MagickSizeType QuantumAny
Definition: magick-type.h:142
static void SetPixelReadMask(const Image *magick_restrict image, const Quantum mask, Quantum *magick_restrict pixel)
static Quantum GetPixelL(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void SetPixelBlueTraits(Image *image, const PixelTrait traits)
static void SetPixelCb(const Image *magick_restrict image, const Quantum cb, Quantum *magick_restrict pixel)
#define QuantumRange
Definition: magick-type.h:83
PixelChannelMap * channel_map
Definition: image.h:291
static void SetPixelGreen(const Image *magick_restrict image, const Quantum green, Quantum *magick_restrict pixel)
static PixelTrait GetPixelBlueTraits(const Image *magick_restrict image)