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