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 #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 
142 static inline Quantum GetPixelCr(const Image *magick_restrict image,
143  const Quantum *magick_restrict pixel)
144 {
145  return(pixel[image->channel_map[CrPixelChannel].offset]);
146 }
147 
149 {
150  return(image->channel_map[CrPixelChannel].traits);
151 }
152 
153 static inline Quantum GetPixelCyan(const Image *magick_restrict image,
154  const Quantum *magick_restrict pixel)
155 {
156  return(pixel[image->channel_map[CyanPixelChannel].offset]);
157 }
158 
160 {
161  return(image->channel_map[CyanPixelChannel].traits);
162 }
163 
164 static inline Quantum GetPixelGray(const Image *magick_restrict image,
165  const Quantum *magick_restrict pixel)
166 {
167  return(pixel[image->channel_map[GrayPixelChannel].offset]);
168 }
169 
171 {
172  return(image->channel_map[GrayPixelChannel].traits);
173 }
174 
175 static inline Quantum GetPixelGreen(const Image *magick_restrict image,
176  const Quantum *magick_restrict pixel)
177 {
178  return(pixel[image->channel_map[GreenPixelChannel].offset]);
179 }
180 
182  const Image *magick_restrict image)
183 {
184  return(image->channel_map[GreenPixelChannel].traits);
185 }
186 
187 static inline Quantum GetPixelIndex(const Image *magick_restrict image,
188  const Quantum *magick_restrict pixel)
189 {
190  if (image->channel_map[IndexPixelChannel].traits == UndefinedPixelTrait)
191  return((Quantum) 0);
192  return(pixel[image->channel_map[IndexPixelChannel].offset]);
193 }
194 
196  const Image *magick_restrict image)
197 {
198  return(image->channel_map[IndexPixelChannel].traits);
199 }
200 
202  const PixelInfo *magick_restrict pixel_info,const PixelChannel channel)
203 {
204  switch (channel)
205  {
206  case RedPixelChannel: return(pixel_info->red);
207  case GreenPixelChannel: return(pixel_info->green);
208  case BluePixelChannel: return(pixel_info->blue);
209  case BlackPixelChannel: return(pixel_info->black);
210  case AlphaPixelChannel: return(pixel_info->alpha);
211  case IndexPixelChannel: return(pixel_info->index);
212  default: return((MagickRealType) 0.0);
213  }
214 }
215 
216 static inline double PerceptibleReciprocal(const double x)
217 {
218  double
219  sign;
220 
221  /*
222  Return 1/x where x is perceptible (not unlimited or infinitesimal).
223  */
224  sign=x < 0.0 ? -1.0 : 1.0;
225  if ((sign*x) >= MagickEpsilon)
226  return(1.0/x);
227  return(sign/MagickEpsilon);
228 }
229 
231  const PixelInfo *magick_restrict pixel)
232 {
234  intensity;
235 
236  if (pixel->colorspace == sRGBColorspace)
237  {
238  intensity=(MagickRealType) (0.212656f*pixel->red+0.715158f*pixel->green+
239  0.072186f*pixel->blue);
240  return(intensity);
241  }
242  intensity=(MagickRealType) (0.212656f*EncodePixelGamma(pixel->red)+
243  0.715158f*EncodePixelGamma(pixel->green)+
244  0.072186f*EncodePixelGamma(pixel->blue));
245  return(intensity);
246 }
247 
249  const PixelInfo *magick_restrict pixel)
250 {
252  intensity;
253 
254  if (pixel->colorspace != sRGBColorspace)
255  {
256  intensity=(MagickRealType) (0.212656f*pixel->red+0.715158f*pixel->green+
257  0.072186f*pixel->blue);
258  return(intensity);
259  }
260  intensity=(MagickRealType) (0.212656f*DecodePixelGamma(pixel->red)+
261  0.715158f*DecodePixelGamma(pixel->green)+
262  0.072186f*DecodePixelGamma(pixel->blue));
263  return(intensity);
264 }
265 
266 static inline Quantum GetPixelL(const Image *magick_restrict image,
267  const Quantum *magick_restrict pixel)
268 {
269  return(pixel[image->channel_map[LPixelChannel].offset]);
270 }
271 
272 static inline ssize_t GetPixelLabel(const Image *magick_restrict image,
273  const Quantum *magick_restrict pixel)
274 {
275  return((ssize_t) pixel[image->channel_map[LabelPixelChannel].offset]);
276 }
277 
279  const Quantum *magick_restrict pixel)
280 {
282  intensity;
283 
284  intensity=(MagickRealType) (
285  0.212656f*pixel[image->channel_map[RedPixelChannel].offset]+
286  0.715158f*pixel[image->channel_map[GreenPixelChannel].offset]+
287  0.072186f*pixel[image->channel_map[BluePixelChannel].offset]);
288  return(intensity);
289 }
290 
292  const Image *magick_restrict image,const Quantum *magick_restrict pixel)
293 {
295  intensity;
296 
297  if (image->colorspace != sRGBColorspace)
298  {
299  intensity=(MagickRealType) (
300  0.212656f*pixel[image->channel_map[RedPixelChannel].offset]+
301  0.715158f*pixel[image->channel_map[GreenPixelChannel].offset]+
302  0.072186f*pixel[image->channel_map[BluePixelChannel].offset]);
303  return(intensity);
304  }
305  intensity=(MagickRealType) (0.212656f*DecodePixelGamma((MagickRealType)
306  pixel[image->channel_map[RedPixelChannel].offset])+0.715158f*
308  pixel[image->channel_map[GreenPixelChannel].offset])+0.072186f*
310  pixel[image->channel_map[BluePixelChannel].offset]));
311  return(intensity);
312 }
313 
314 static inline Quantum GetPixelMagenta(const Image *magick_restrict image,
315  const Quantum *magick_restrict pixel)
316 {
317  return(pixel[image->channel_map[MagentaPixelChannel].offset]);
318 }
319 
321  const Image *magick_restrict image)
322 {
323  return(image->channel_map[MagentaPixelChannel].traits);
324 }
325 
326 static inline Quantum GetPixelReadMask(const Image *magick_restrict image,
327  const Quantum *magick_restrict pixel)
328 {
329  if (image->channel_map[ReadMaskPixelChannel].traits == UndefinedPixelTrait)
330  return((Quantum) QuantumRange);
331  return(pixel[image->channel_map[ReadMaskPixelChannel].offset]);
332 }
333 
334 static inline Quantum GetPixelWriteMask(const Image *magick_restrict image,
335  const Quantum *magick_restrict pixel)
336 {
337  if (image->channel_map[WriteMaskPixelChannel].traits == UndefinedPixelTrait)
338  return((Quantum) QuantumRange);
339  return(pixel[image->channel_map[WriteMaskPixelChannel].offset]);
340 }
341 
343  const Image *magick_restrict image)
344 {
345  return(image->channel_map[ReadMaskPixelChannel].traits);
346 }
347 
348 static inline size_t GetPixelMetaChannels(const Image *magick_restrict image)
349 {
350  return(image->number_meta_channels);
351 }
352 
353 static inline size_t GetPixelMetacontentExtent(
354  const Image *magick_restrict image)
355 {
356  return(image->metacontent_extent);
357 }
358 
359 static inline Quantum GetPixelOpacity(const Image *magick_restrict image,
360  const Quantum *magick_restrict pixel)
361 {
362  if (image->channel_map[AlphaPixelChannel].traits != BlendPixelTrait)
363  return(QuantumRange-OpaqueAlpha);
364  return(QuantumRange-pixel[image->channel_map[AlphaPixelChannel].offset]);
365 }
366 
367 static inline Quantum GetPixelRed(const Image *magick_restrict image,
368  const Quantum *magick_restrict pixel)
369 {
370  return(pixel[image->channel_map[RedPixelChannel].offset]);
371 }
372 
374 {
375  return(image->channel_map[RedPixelChannel].traits);
376 }
377 
378 static inline void GetPixelInfoPixel(const Image *magick_restrict image,
379  const Quantum *magick_restrict pixel,PixelInfo *magick_restrict pixel_info)
380 {
381  (void) ResetMagickMemory(pixel_info,0,sizeof(*pixel_info));
382  pixel_info->storage_class=DirectClass;
383  pixel_info->colorspace=sRGBColorspace;
384  pixel_info->depth=MAGICKCORE_QUANTUM_DEPTH;
385  pixel_info->alpha_trait=UndefinedPixelTrait;
386  pixel_info->alpha=(MagickRealType) OpaqueAlpha;
387  if (image != (Image *) NULL)
388  {
389  pixel_info->storage_class=image->storage_class;
390  pixel_info->colorspace=image->colorspace;
391  pixel_info->fuzz=image->fuzz;
392  pixel_info->depth=image->depth;
393  pixel_info->alpha_trait=image->alpha_trait;
394  }
395  if (pixel != (Quantum *) NULL)
396  {
397  pixel_info->red=(MagickRealType)
398  pixel[image->channel_map[RedPixelChannel].offset];
399  pixel_info->green=(MagickRealType)
400  pixel[image->channel_map[GreenPixelChannel].offset];
401  pixel_info->blue=(MagickRealType)
402  pixel[image->channel_map[BluePixelChannel].offset];
403  if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
404  pixel_info->black=(MagickRealType)
405  pixel[image->channel_map[BlackPixelChannel].offset];
406  if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
407  {
408  pixel_info->alpha=(MagickRealType)
409  pixel[image->channel_map[AlphaPixelChannel].offset];
410  pixel_info->alpha_trait=BlendPixelTrait;
411  }
412  if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
413  pixel_info->index=(MagickRealType)
414  pixel[image->channel_map[IndexPixelChannel].offset];
415  }
416 }
417 
418 static inline PixelTrait GetPixelTraits(const Image *magick_restrict image,
419  const PixelChannel channel)
420 {
421  return(image->channel_map[channel].traits);
422 }
423 
424 static inline Quantum GetPixelY(const Image *magick_restrict image,
425  const Quantum *magick_restrict pixel)
426 {
427  return(pixel[image->channel_map[YPixelChannel].offset]);
428 }
429 
430 static inline PixelTrait GetPixelYTraits(const Image *magick_restrict image)
431 {
432  return(image->channel_map[YPixelChannel].traits);
433 }
434 
435 static inline Quantum GetPixelYellow(const Image *magick_restrict image,
436  const Quantum *magick_restrict pixel)
437 {
438  return(pixel[image->channel_map[YellowPixelChannel].offset]);
439 }
440 
442  const Image *magick_restrict image)
443 {
444  return(image->channel_map[YellowPixelChannel].traits);
445 }
446 
448 {
449  return(x < 0.0f ? -x : x);
450 }
451 
452 static inline MagickBooleanType IsPixelAtDepth(const Quantum pixel,
453  const QuantumAny range)
454 {
455  Quantum
456  quantum;
457 
458 #if !defined(MAGICKCORE_HDRI_SUPPORT)
460  (((MagickRealType) range*pixel)/QuantumRange+0.5)))/range+0.5);
461 #else
463  (((MagickRealType) range*pixel)/QuantumRange+0.5)))/range);
464 #endif
465  return(pixel == quantum ? MagickTrue : MagickFalse);
466 }
467 
469  const Image *magick_restrict image,const Quantum *magick_restrict p,
470  const PixelInfo *magick_restrict q)
471 {
473  alpha,
474  beta,
475  color;
476 
477  color=(MagickRealType) p[image->channel_map[AlphaPixelChannel].offset];
478  alpha=image->alpha_trait == UndefinedPixelTrait ? (MagickRealType)
479  OpaqueAlpha : color;
480  beta=q->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
481  q->alpha;
482  if (AbsolutePixelValue(alpha-beta) >= MagickEpsilon)
483  return(MagickFalse);
486  return(MagickTrue); /* no color component if pixel is transparent */
487  color=(MagickRealType) p[image->channel_map[RedPixelChannel].offset];
488  if (AbsolutePixelValue(color-q->red) >= MagickEpsilon)
489  return(MagickFalse);
490  color=(MagickRealType) p[image->channel_map[GreenPixelChannel].offset];
491  if (AbsolutePixelValue(color-q->green) >= MagickEpsilon)
492  return(MagickFalse);
493  color=(MagickRealType) p[image->channel_map[BluePixelChannel].offset];
494  if (AbsolutePixelValue(color-q->blue) >= MagickEpsilon)
495  return(MagickFalse);
496  if (image->colorspace == CMYKColorspace)
497  {
498  color=(MagickRealType) p[image->channel_map[BlackPixelChannel].offset];
499  if (AbsolutePixelValue(color-q->black) >= MagickEpsilon)
500  return(MagickFalse);
501  }
502  return(MagickTrue);
503 }
504 
506  const Quantum *magick_restrict pixel)
507 {
509  green_blue,
510  red_green;
511 
512  red_green=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]-
513  pixel[image->channel_map[GreenPixelChannel].offset];
514  green_blue=(MagickRealType)
515  pixel[image->channel_map[GreenPixelChannel].offset]-
516  pixel[image->channel_map[BluePixelChannel].offset];
517  if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
518  (AbsolutePixelValue(green_blue) < MagickEpsilon))
519  return(MagickTrue);
520  return(MagickFalse);
521 }
522 
525 {
527  alpha,
528  beta;
529 
530  alpha=p->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
531  p->alpha;
532  beta=q->alpha_trait == UndefinedPixelTrait ? (MagickRealType) OpaqueAlpha :
533  q->alpha;
534  if (AbsolutePixelValue(alpha-beta) >= MagickEpsilon)
535  return(MagickFalse);
538  return(MagickTrue); /* no color component if pixel is transparent */
539  if (AbsolutePixelValue(p->red-q->red) >= MagickEpsilon)
540  return(MagickFalse);
541  if (AbsolutePixelValue(p->green-q->green) >= MagickEpsilon)
542  return(MagickFalse);
543  if (AbsolutePixelValue(p->blue-q->blue) >= MagickEpsilon)
544  return(MagickFalse);
545  if (p->colorspace == CMYKColorspace)
546  {
547  if (AbsolutePixelValue(p->black-q->black) >= MagickEpsilon)
548  return(MagickFalse);
549  }
550  return(MagickTrue);
551 }
552 
554  const Image *magick_restrict image,const Quantum *magick_restrict pixel)
555 {
557  green_blue,
558  red,
559  red_green;
560 
561  red=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset];
562  if ((AbsolutePixelValue(red) >= MagickEpsilon) &&
564  return(MagickFalse);
565  red_green=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset]-
566  pixel[image->channel_map[GreenPixelChannel].offset];
567  green_blue=(MagickRealType)
568  pixel[image->channel_map[GreenPixelChannel].offset]-
569  pixel[image->channel_map[BluePixelChannel].offset];
570  if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
571  (AbsolutePixelValue(green_blue) < MagickEpsilon))
572  return(MagickTrue);
573  return(MagickFalse);
574 }
575 
577  const PixelInfo *magick_restrict pixel)
578 {
579  if ((AbsolutePixelValue(pixel->red-pixel->green) < MagickEpsilon) &&
580  (AbsolutePixelValue(pixel->green-pixel->blue) < MagickEpsilon))
581  return(MagickTrue);
582  return(MagickFalse);
583 }
584 
586  const PixelInfo *magick_restrict pixel_info)
587 {
589  green_blue,
590  red_green;
591 
592  if ((AbsolutePixelValue(pixel_info->red) >= MagickEpsilon) ||
593  (AbsolutePixelValue(pixel_info->red-QuantumRange) >= MagickEpsilon))
594  return(MagickFalse);
595  red_green=pixel_info->red-pixel_info->green;
596  green_blue=pixel_info->green-pixel_info->blue;
597  if ((AbsolutePixelValue(red_green) < MagickEpsilon) &&
598  (AbsolutePixelValue(green_blue) < MagickEpsilon))
599  return(MagickTrue);
600  return(MagickFalse);
601 }
602 
603 static inline void SetPixela(const Image *magick_restrict image,
604  const Quantum a,Quantum *magick_restrict pixel)
605 {
606  if (image->channel_map[aPixelChannel].traits != UndefinedPixelTrait)
607  pixel[image->channel_map[aPixelChannel].offset]=a;
608 }
609 
610 static inline void SetPixelAlpha(const Image *magick_restrict image,
611  const Quantum alpha,Quantum *magick_restrict pixel)
612 {
613  if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
614  pixel[image->channel_map[AlphaPixelChannel].offset]=alpha;
615 }
616 
617 static inline void SetPixelAlphaTraits(Image *image,const PixelTrait traits)
618 {
619  image->channel_map[AlphaPixelChannel].traits=traits;
620 }
621 
622 static inline void SetPixelb(const Image *magick_restrict image,
623  const Quantum b,Quantum *magick_restrict pixel)
624 {
625  if (image->channel_map[bPixelChannel].traits != UndefinedPixelTrait)
626  pixel[image->channel_map[bPixelChannel].offset]=b;
627 }
628 
629 static inline void SetPixelBackgoundColor(const Image *magick_restrict image,
630  Quantum *magick_restrict pixel)
631 {
632  register ssize_t
633  i;
634 
635  for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
636  pixel[i]=(Quantum) 0;
637  pixel[image->channel_map[RedPixelChannel].offset]=
638  ClampToQuantum(image->background_color.red);
639  pixel[image->channel_map[GreenPixelChannel].offset]=
640  ClampToQuantum(image->background_color.green);
641  pixel[image->channel_map[BluePixelChannel].offset]=
642  ClampToQuantum(image->background_color.blue);
643  if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
644  pixel[image->channel_map[BlackPixelChannel].offset]=
645  ClampToQuantum(image->background_color.black);
646  if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
647  pixel[image->channel_map[AlphaPixelChannel].offset]=
648  image->background_color.alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
649  ClampToQuantum(image->background_color.alpha);
650 }
651 
652 static inline void SetPixelBlack(const Image *magick_restrict image,
653  const Quantum black,Quantum *magick_restrict pixel)
654 {
655  if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
656  pixel[image->channel_map[BlackPixelChannel].offset]=black;
657 }
658 
659 static inline void SetPixelBlackTraits(Image *image,const PixelTrait traits)
660 {
661  image->channel_map[BlackPixelChannel].traits=traits;
662 }
663 
664 static inline void SetPixelBlue(const Image *magick_restrict image,
665  const Quantum blue,Quantum *magick_restrict pixel)
666 {
667  pixel[image->channel_map[BluePixelChannel].offset]=blue;
668 }
669 
670 static inline void SetPixelBlueTraits(Image *image,const PixelTrait traits)
671 {
672  image->channel_map[BluePixelChannel].traits=traits;
673 }
674 
675 static inline void SetPixelCb(const Image *magick_restrict image,
676  const Quantum cb,Quantum *magick_restrict pixel)
677 {
678  pixel[image->channel_map[CbPixelChannel].offset]=cb;
679 }
680 
681 static inline void SetPixelCbTraits(Image *image,const PixelTrait traits)
682 {
683  image->channel_map[CbPixelChannel].traits=traits;
684 }
685 
686 static inline void SetPixelChannel(const Image *magick_restrict image,
687  const PixelChannel channel,const Quantum quantum,
688  Quantum *magick_restrict pixel)
689 {
690  if (image->channel_map[channel].traits != UndefinedPixelTrait)
691  pixel[image->channel_map[channel].offset]=quantum;
692 }
693 
694 static inline void SetPixelChannelAttributes(
695  const Image *magick_restrict image,const PixelChannel channel,
696  const PixelTrait traits,const ssize_t offset)
697 {
698  assert((ssize_t) channel < MaxPixelChannels);
699  assert(offset < MaxPixelChannels);
700  image->channel_map[offset].channel=channel;
701  image->channel_map[channel].offset=offset;
702  image->channel_map[channel].traits=traits;
703 }
704 
705 static inline void SetPixelChannelChannel(const Image *magick_restrict image,
706  const PixelChannel channel,const ssize_t offset)
707 {
708  image->channel_map[offset].channel=channel;
709  image->channel_map[channel].offset=offset;
710 }
711 
712 static inline void SetPixelChannels(Image *image,const size_t number_channels)
713 {
714  image->number_channels=number_channels;
715 }
716 
717 static inline void SetPixelChannelTraits(Image *image,
718  const PixelChannel channel,const PixelTrait traits)
719 {
720  image->channel_map[channel].traits=traits;
721 }
722 
723 static inline void SetPixelCr(const Image *magick_restrict image,
724  const Quantum cr,Quantum *magick_restrict pixel)
725 {
726  pixel[image->channel_map[CrPixelChannel].offset]=cr;
727 }
728 
729 static inline void SetPixelCrTraits(Image *image,const PixelTrait traits)
730 {
731  image->channel_map[CrPixelChannel].traits=traits;
732 }
733 
734 static inline void SetPixelCyan(const Image *magick_restrict image,
735  const Quantum cyan,Quantum *magick_restrict pixel)
736 {
737  pixel[image->channel_map[CyanPixelChannel].offset]=cyan;
738 }
739 
740 static inline void SetPixelGray(const Image *magick_restrict image,
741  const Quantum gray,Quantum *magick_restrict pixel)
742 {
743  pixel[image->channel_map[GrayPixelChannel].offset]=gray;
744 }
745 
746 static inline void SetPixelGrayTraits(Image *image,const PixelTrait traits)
747 {
748  image->channel_map[GrayPixelChannel].traits=traits;
749 }
750 
751 static inline void SetPixelGreen(const Image *magick_restrict image,
752  const Quantum green,Quantum *magick_restrict pixel)
753 {
754  pixel[image->channel_map[GreenPixelChannel].offset]=green;
755 }
756 
757 static inline void SetPixelGreenTraits(Image *image,const PixelTrait traits)
758 {
759  image->channel_map[GreenPixelChannel].traits=traits;
760 }
761 
762 static inline void SetPixelIndex(const Image *magick_restrict image,
763  const Quantum index,Quantum *magick_restrict pixel)
764 {
765  if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
766  pixel[image->channel_map[IndexPixelChannel].offset]=index;
767 }
768 
769 static inline void SetPixelIndexTraits(Image *image,const PixelTrait traits)
770 {
771  image->channel_map[IndexPixelChannel].traits=traits;
772 }
773 
774 static inline void SetPixelViaPixelInfo(const Image *magick_restrict image,
775  const PixelInfo *magick_restrict pixel_info,Quantum *magick_restrict pixel)
776 {
777  pixel[image->channel_map[RedPixelChannel].offset]=
778  ClampToQuantum(pixel_info->red);
779  pixel[image->channel_map[GreenPixelChannel].offset]=
780  ClampToQuantum(pixel_info->green);
781  pixel[image->channel_map[BluePixelChannel].offset]=
782  ClampToQuantum(pixel_info->blue);
783  if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
784  pixel[image->channel_map[BlackPixelChannel].offset]=
785  ClampToQuantum(pixel_info->black);
786  if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
787  pixel[image->channel_map[AlphaPixelChannel].offset]=
788  pixel_info->alpha_trait == UndefinedPixelTrait ? OpaqueAlpha :
789  ClampToQuantum(pixel_info->alpha);
790 }
791 
792 static inline void SetPixelL(const Image *magick_restrict image,const Quantum L,
793  Quantum *magick_restrict pixel)
794 {
795  if (image->channel_map[LPixelChannel].traits != UndefinedPixelTrait)
796  pixel[image->channel_map[LPixelChannel].offset]=L;
797 }
798 
799 static inline void SetPixelMagenta(const Image *magick_restrict image,
800  const Quantum magenta,Quantum *magick_restrict pixel)
801 {
802  pixel[image->channel_map[MagentaPixelChannel].offset]=magenta;
803 }
804 
805 static inline void SetPixelMagentaTraits(Image *image,const PixelTrait traits)
806 {
807  image->channel_map[MagentaPixelChannel].traits=traits;
808 }
809 
810 static inline void SetPixelReadMask(const Image *magick_restrict image,
811  const Quantum mask,Quantum *magick_restrict pixel)
812 {
813  if (image->channel_map[ReadMaskPixelChannel].traits != UndefinedPixelTrait)
814  pixel[image->channel_map[ReadMaskPixelChannel].offset]=mask;
815 }
816 
817 static inline void SetPixelWriteMask(const Image *magick_restrict image,
818  const Quantum mask,Quantum *magick_restrict pixel)
819 {
820  if (image->channel_map[WriteMaskPixelChannel].traits != UndefinedPixelTrait)
821  pixel[image->channel_map[WriteMaskPixelChannel].offset]=mask;
822 }
823 
824 static inline void SetPixelMetacontentExtent(Image *image,const size_t extent)
825 {
826  image->metacontent_extent=extent;
827 }
828 
829 static inline void SetPixelOpacity(const Image *magick_restrict image,
830  const Quantum alpha,Quantum *magick_restrict pixel)
831 {
832  if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
833  pixel[image->channel_map[AlphaPixelChannel].offset]=QuantumRange-alpha;
834 }
835 
836 static inline void SetPixelRed(const Image *magick_restrict image,
837  const Quantum red,Quantum *magick_restrict pixel)
838 {
839  pixel[image->channel_map[RedPixelChannel].offset]=red;
840 }
841 
842 static inline void SetPixelRedTraits(Image *image,const PixelTrait traits)
843 {
844  image->channel_map[RedPixelChannel].traits=traits;
845 }
846 
847 static inline void SetPixelYellow(const Image *magick_restrict image,
848  const Quantum yellow,Quantum *magick_restrict pixel)
849 {
850  pixel[image->channel_map[YellowPixelChannel].offset]=yellow;
851 }
852 
853 static inline void SetPixelYellowTraits(Image *image,const PixelTrait traits)
854 {
855  image->channel_map[YellowPixelChannel].traits=traits;
856 }
857 
858 static inline void SetPixelY(const Image *magick_restrict image,
859  const Quantum y,Quantum *magick_restrict pixel)
860 {
861  pixel[image->channel_map[YPixelChannel].offset]=y;
862 }
863 
864 static inline void SetPixelYTraits(Image *image,const PixelTrait traits)
865 {
866  image->channel_map[YPixelChannel].traits=traits;
867 }
868 
869 #if defined(__cplusplus) || defined(c_plusplus)
870 }
871 #endif
872 
873 #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:1153
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)