MagickCore  7.0.7
Convert, Edit, Or Compose Bitmap Images
channel.c
Go to the documentation of this file.
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % %
4 % %
5 % %
6 % CCCC H H AAA N N N N EEEEE L %
7 % C H H A A NN N NN N E L %
8 % C HHHHH AAAAA N N N N N N EEE L %
9 % C H H A A N NN N NN E L %
10 % CCCC H H A A N N N N EEEEE LLLLL %
11 % %
12 % %
13 % MagickCore Image Channel Methods %
14 % %
15 % Software Design %
16 % Cristy %
17 % December 2003 %
18 % %
19 % %
20 % Copyright 1999-2018 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
22 % %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
25 % %
26 % https://www.imagemagick.org/script/license.php %
27 % %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
33 % %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 %
36 %
37 %
38 */
39 
40 /*
41  Include declarations.
42 */
43 #include "MagickCore/studio.h"
45 #include "MagickCore/channel.h"
48 #include "MagickCore/enhance.h"
49 #include "MagickCore/image.h"
50 #include "MagickCore/list.h"
51 #include "MagickCore/log.h"
52 #include "MagickCore/monitor.h"
54 #include "MagickCore/option.h"
57 #include "MagickCore/resource_.h"
60 #include "MagickCore/token.h"
61 #include "MagickCore/utility.h"
62 #include "MagickCore/version.h"
63 
64 /*
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66 % %
67 % %
68 % %
69 % C h a n n e l F x I m a g e %
70 % %
71 % %
72 % %
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74 %
75 % ChannelFxImage() applies a channel expression to the specified image. The
76 % expression consists of one or more channels, either mnemonic or numeric (e.g.
77 % red, 1), separated by actions as follows:
78 %
79 % <=> exchange two channels (e.g. red<=>blue)
80 % => copy one channel to another channel (e.g. red=>green)
81 % = assign a constant value to a channel (e.g. red=50%)
82 % , write new image channels in the specified order (e.g. red, green)
83 % | add a new output image for the next set of channel operations
84 % ; move to the next input image for the source of channel data
85 %
86 % For example, to create 3 grayscale images from the red, green, and blue
87 % channels of an image, use:
88 %
89 % -channel-fx "red; green; blue"
90 %
91 % A channel without an operation symbol implies separate (i.e, semicolon).
92 %
93 % The format of the ChannelFxImage method is:
94 %
95 % Image *ChannelFxImage(const Image *image,const char *expression,
96 % ExceptionInfo *exception)
97 %
98 % A description of each parameter follows:
99 %
100 % o image: the image.
101 %
102 % o expression: A channel expression.
103 %
104 % o exception: return any errors or warnings in this structure.
105 %
106 */
107 
108 typedef enum
109 {
114 } ChannelFx;
115 
116 static MagickBooleanType ChannelImage(Image *destination_image,
117  const PixelChannel destination_channel,const ChannelFx channel_op,
118  const Image *source_image,const PixelChannel source_channel,
119  const Quantum pixel,ExceptionInfo *exception)
120 {
121  CacheView
122  *source_view,
123  *destination_view;
124 
126  status;
127 
128  size_t
129  height,
130  width;
131 
132  ssize_t
133  y;
134 
135  status=MagickTrue;
136  source_view=AcquireVirtualCacheView(source_image,exception);
137  destination_view=AcquireAuthenticCacheView(destination_image,exception);
138  height=MagickMin(source_image->rows,destination_image->rows);
139  width=MagickMin(source_image->columns,destination_image->columns);
140 #if defined(MAGICKCORE_OPENMP_SUPPORT)
141  #pragma omp parallel for schedule(static) shared(status) \
142  magick_number_threads(source_image,source_image,height,1)
143 #endif
144  for (y=0; y < (ssize_t) height; y++)
145  {
146  PixelTrait
147  destination_traits,
148  source_traits;
149 
150  register const Quantum
151  *magick_restrict p;
152 
153  register Quantum
154  *magick_restrict q;
155 
156  register ssize_t
157  x;
158 
159  if (status == MagickFalse)
160  continue;
161  p=GetCacheViewVirtualPixels(source_view,0,y,source_image->columns,1,
162  exception);
163  q=GetCacheViewAuthenticPixels(destination_view,0,y,
164  destination_image->columns,1,exception);
165  if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
166  {
167  status=MagickFalse;
168  continue;
169  }
170  destination_traits=GetPixelChannelTraits(destination_image,
171  destination_channel);
172  source_traits=GetPixelChannelTraits(source_image,source_channel);
173  if ((destination_traits == UndefinedPixelTrait) ||
174  (source_traits == UndefinedPixelTrait))
175  continue;
176  for (x=0; x < (ssize_t) width; x++)
177  {
178  if (channel_op == AssignChannelOp)
179  SetPixelChannel(destination_image,destination_channel,pixel,q);
180  else
181  SetPixelChannel(destination_image,destination_channel,
182  GetPixelChannel(source_image,source_channel,p),q);
183  p+=GetPixelChannels(source_image);
184  q+=GetPixelChannels(destination_image);
185  }
186  if (SyncCacheViewAuthenticPixels(destination_view,exception) == MagickFalse)
187  status=MagickFalse;
188  }
189  destination_view=DestroyCacheView(destination_view);
190  source_view=DestroyCacheView(source_view);
191  return(status);
192 }
193 
194 MagickExport Image *ChannelFxImage(const Image *image,const char *expression,
195  ExceptionInfo *exception)
196 {
197 #define ChannelFxImageTag "ChannelFx/Image"
198 
199  ChannelFx
200  channel_op;
201 
203  channel_mask;
204 
205  char
206  token[MagickPathExtent];
207 
208  const char
209  *p;
210 
211  const Image
212  *source_image;
213 
214  double
215  pixel;
216 
217  Image
218  *destination_image;
219 
221  status;
222 
224  source_channel,
225  destination_channel;
226 
227  ssize_t
228  channels;
229 
230  assert(image != (Image *) NULL);
231  assert(image->signature == MagickCoreSignature);
232  if (image->debug != MagickFalse)
233  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
234  assert(exception != (ExceptionInfo *) NULL);
235  assert(exception->signature == MagickCoreSignature);
236  source_image=image;
237  destination_image=CloneImage(source_image,0,0,MagickTrue,exception);
238  if (destination_image == (Image *) NULL)
239  return((Image *) NULL);
240  if (expression == (const char *) NULL)
241  return(destination_image);
242  status=SetImageStorageClass(destination_image,DirectClass,exception);
243  if (status == MagickFalse)
244  {
245  destination_image=GetLastImageInList(destination_image);
246  return((Image *) NULL);
247  }
248  destination_channel=RedPixelChannel;
249  channel_mask=UndefinedChannel;
250  pixel=0.0;
251  p=(char *) expression;
252  GetNextToken(p,&p,MagickPathExtent,token);
253  channel_op=ExtractChannelOp;
254  for (channels=0; *token != '\0'; )
255  {
256  ssize_t
257  i;
258 
259  /*
260  Interpret channel expression.
261  */
262  switch (*token)
263  {
264  case ',':
265  {
266  GetNextToken(p,&p,MagickPathExtent,token);
267  break;
268  }
269  case '|':
270  {
271  if (GetNextImageInList(source_image) != (Image *) NULL)
272  source_image=GetNextImageInList(source_image);
273  else
274  source_image=GetFirstImageInList(source_image);
275  GetNextToken(p,&p,MagickPathExtent,token);
276  break;
277  }
278  case ';':
279  {
280  Image
281  *canvas;
282 
283  (void) SetPixelChannelMask(destination_image,channel_mask);
284  if ((channel_op == ExtractChannelOp) && (channels == 1))
285  {
286  (void) SetPixelMetaChannels(destination_image,0,exception);
287  (void) SetImageColorspace(destination_image,GRAYColorspace,
288  exception);
289  }
290  canvas=CloneImage(source_image,0,0,MagickTrue,exception);
291  if (canvas == (Image *) NULL)
292  {
293  destination_image=DestroyImageList(destination_image);
294  return(destination_image);
295  }
296  AppendImageToList(&destination_image,canvas);
297  destination_image=GetLastImageInList(destination_image);
298  status=SetImageStorageClass(destination_image,DirectClass,exception);
299  if (status == MagickFalse)
300  {
301  destination_image=GetLastImageInList(destination_image);
302  return((Image *) NULL);
303  }
304  GetNextToken(p,&p,MagickPathExtent,token);
305  channels=0;
306  destination_channel=RedPixelChannel;
307  channel_mask=UndefinedChannel;
308  break;
309  }
310  default:
311  break;
312  }
313  i=ParsePixelChannelOption(token);
314  if (i < 0)
315  {
317  "UnrecognizedChannelType","`%s'",token);
318  destination_image=DestroyImageList(destination_image);
319  return(destination_image);
320  }
321  source_channel=(PixelChannel) i;
322  channel_op=ExtractChannelOp;
323  GetNextToken(p,&p,MagickPathExtent,token);
324  if (*token == '<')
325  {
326  channel_op=ExchangeChannelOp;
327  GetNextToken(p,&p,MagickPathExtent,token);
328  }
329  if (*token == '=')
330  {
331  if (channel_op != ExchangeChannelOp)
332  channel_op=AssignChannelOp;
333  GetNextToken(p,&p,MagickPathExtent,token);
334  }
335  if (*token == '>')
336  {
337  if (channel_op != ExchangeChannelOp)
338  channel_op=TransferChannelOp;
339  GetNextToken(p,&p,MagickPathExtent,token);
340  }
341  switch (channel_op)
342  {
343  case AssignChannelOp:
344  case ExchangeChannelOp:
345  case TransferChannelOp:
346  {
347  if (channel_op == AssignChannelOp)
348  pixel=StringToDoubleInterval(token,(double) QuantumRange+1.0);
349  else
350  {
351  i=ParsePixelChannelOption(token);
352  if (i < 0)
353  {
354  (void) ThrowMagickException(exception,GetMagickModule(),
355  OptionError,"UnrecognizedChannelType","`%s'",token);
356  destination_image=DestroyImageList(destination_image);
357  return(destination_image);
358  }
359  }
360  destination_channel=(PixelChannel) i;
361  if (i >= (ssize_t) GetPixelChannels(destination_image))
362  (void) SetPixelMetaChannels(destination_image,(size_t) (
363  destination_channel-GetPixelChannels(destination_image)+1),
364  exception);
365  if (image->colorspace != UndefinedColorspace)
366  switch (destination_channel)
367  {
368  case RedPixelChannel:
369  case GreenPixelChannel:
370  case BluePixelChannel:
371  case BlackPixelChannel:
372  case IndexPixelChannel:
373  break;
374  case AlphaPixelChannel:
375  {
376  destination_image->alpha_trait=BlendPixelTrait;
377  break;
378  }
380  {
381  destination_image->read_mask=MagickTrue;
382  break;
383  }
385  {
386  destination_image->write_mask=MagickTrue;
387  break;
388  }
389  case MetaPixelChannel:
390  default:
391  {
392  (void) SetPixelMetaChannels(destination_image,(size_t) (
393  destination_channel-GetPixelChannels(destination_image)+1),
394  exception);
395  break;
396  }
397  }
398  channel_mask=(ChannelType) (channel_mask | ParseChannelOption(token));
399  if (((channels >= 1) || (destination_channel >= 1)) &&
400  (IsGrayColorspace(destination_image->colorspace) != MagickFalse))
401  (void) SetImageColorspace(destination_image,sRGBColorspace,exception);
402  GetNextToken(p,&p,MagickPathExtent,token);
403  break;
404  }
405  default:
406  break;
407  }
408  status=ChannelImage(destination_image,destination_channel,channel_op,
409  source_image,source_channel,ClampToQuantum(pixel),exception);
410  if (status == MagickFalse)
411  {
412  destination_image=DestroyImageList(destination_image);
413  break;
414  }
415  channels++;
416  if (channel_op == ExchangeChannelOp)
417  {
418  status=ChannelImage(destination_image,source_channel,channel_op,
419  source_image,destination_channel,ClampToQuantum(pixel),exception);
420  if (status == MagickFalse)
421  {
422  destination_image=DestroyImageList(destination_image);
423  break;
424  }
425  channels++;
426  }
427  switch (channel_op)
428  {
429  case ExtractChannelOp:
430  {
431  channel_mask=(ChannelType) (channel_mask | (1 << destination_channel));
432  destination_channel=(PixelChannel) (destination_channel+1);
433  break;
434  }
435  default:
436  break;
437  }
438  status=SetImageProgress(source_image,ChannelFxImageTag,p-expression,
439  strlen(expression));
440  if (status == MagickFalse)
441  break;
442  }
443  (void) SetPixelChannelMask(destination_image,channel_mask);
444  if ((channel_op == ExtractChannelOp) && (channels == 1))
445  {
446  (void) SetPixelMetaChannels(destination_image,0,exception);
447  (void) SetImageColorspace(destination_image,GRAYColorspace,exception);
448  }
449  return(GetFirstImageInList(destination_image));
450 }
451 
452 /*
453 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
454 % %
455 % %
456 % %
457 % C o m b i n e I m a g e s %
458 % %
459 % %
460 % %
461 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
462 %
463 % CombineImages() combines one or more images into a single image. The
464 % grayscale value of the pixels of each image in the sequence is assigned in
465 % order to the specified channels of the combined image. The typical
466 % ordering would be image 1 => Red, 2 => Green, 3 => Blue, etc.
467 %
468 % The format of the CombineImages method is:
469 %
470 % Image *CombineImages(const Image *images,const ColorspaceType colorspace,
471 % ExceptionInfo *exception)
472 %
473 % A description of each parameter follows:
474 %
475 % o images: the image sequence.
476 %
477 % o colorspace: the image colorspace.
478 %
479 % o exception: return any errors or warnings in this structure.
480 %
481 */
483  const ColorspaceType colorspace,ExceptionInfo *exception)
484 {
485 #define CombineImageTag "Combine/Image"
486 
487  CacheView
488  *combine_view;
489 
490  Image
491  *combine_image;
492 
494  status;
495 
497  progress;
498 
499  ssize_t
500  y;
501 
502  /*
503  Ensure the image are the same size.
504  */
505  assert(image != (const Image *) NULL);
506  assert(image->signature == MagickCoreSignature);
507  if (image->debug != MagickFalse)
508  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
509  assert(exception != (ExceptionInfo *) NULL);
510  assert(exception->signature == MagickCoreSignature);
511  combine_image=CloneImage(image,0,0,MagickTrue,exception);
512  if (combine_image == (Image *) NULL)
513  return((Image *) NULL);
514  if (SetImageStorageClass(combine_image,DirectClass,exception) == MagickFalse)
515  {
516  combine_image=DestroyImage(combine_image);
517  return((Image *) NULL);
518  }
519  if (colorspace != UndefinedColorspace)
520  (void) SetImageColorspace(combine_image,colorspace,exception);
521  else
522  if (fabs(image->gamma-1.0) <= MagickEpsilon)
523  (void) SetImageColorspace(combine_image,RGBColorspace,exception);
524  else
525  (void) SetImageColorspace(combine_image,sRGBColorspace,exception);
526  switch (combine_image->colorspace)
527  {
528  case UndefinedColorspace:
529  case sRGBColorspace:
530  {
531  if (GetImageListLength(image) > 3)
532  combine_image->alpha_trait=BlendPixelTrait;
533  break;
534  }
536  case GRAYColorspace:
537  {
538  if (GetImageListLength(image) > 1)
539  combine_image->alpha_trait=BlendPixelTrait;
540  break;
541  }
542  case CMYKColorspace:
543  {
544  if (GetImageListLength(image) > 4)
545  combine_image->alpha_trait=BlendPixelTrait;
546  break;
547  }
548  default:
549  break;
550  }
551  /*
552  Combine images.
553  */
554  status=MagickTrue;
555  progress=0;
556  combine_view=AcquireAuthenticCacheView(combine_image,exception);
557  for (y=0; y < (ssize_t) combine_image->rows; y++)
558  {
559  CacheView
560  *image_view;
561 
562  const Image
563  *next;
564 
565  Quantum
566  *pixels;
567 
568  register const Quantum
569  *magick_restrict p;
570 
571  register Quantum
572  *magick_restrict q;
573 
574  register ssize_t
575  i;
576 
577  if (status == MagickFalse)
578  continue;
579  pixels=GetCacheViewAuthenticPixels(combine_view,0,y,combine_image->columns,
580  1,exception);
581  if (pixels == (Quantum *) NULL)
582  {
583  status=MagickFalse;
584  continue;
585  }
586  next=image;
587  for (i=0; i < (ssize_t) GetPixelChannels(combine_image); i++)
588  {
589  register ssize_t
590  x;
591 
592  PixelChannel channel = GetPixelChannelChannel(combine_image,i);
593  PixelTrait traits = GetPixelChannelTraits(combine_image,channel);
594  if (traits == UndefinedPixelTrait)
595  continue;
596  if (next == (Image *) NULL)
597  continue;
598  image_view=AcquireVirtualCacheView(next,exception);
599  p=GetCacheViewVirtualPixels(image_view,0,y,next->columns,1,exception);
600  if (p == (const Quantum *) NULL)
601  continue;
602  q=pixels;
603  for (x=0; x < (ssize_t) combine_image->columns; x++)
604  {
605  if (x < (ssize_t) next->columns)
606  {
607  q[i]=GetPixelGray(next,p);
608  p+=GetPixelChannels(next);
609  }
610  q+=GetPixelChannels(combine_image);
611  }
612  image_view=DestroyCacheView(image_view);
613  next=GetNextImageInList(next);
614  }
615  if (SyncCacheViewAuthenticPixels(combine_view,exception) == MagickFalse)
616  status=MagickFalse;
617  if (image->progress_monitor != (MagickProgressMonitor) NULL)
618  {
620  proceed;
621 
622  proceed=SetImageProgress(image,CombineImageTag,progress++,
623  combine_image->rows);
624  if (proceed == MagickFalse)
625  status=MagickFalse;
626  }
627  }
628  combine_view=DestroyCacheView(combine_view);
629  if (status == MagickFalse)
630  combine_image=DestroyImage(combine_image);
631  return(combine_image);
632 }
633 
634 /*
635 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
636 % %
637 % %
638 % %
639 % G e t I m a g e A l p h a C h a n n e l %
640 % %
641 % %
642 % %
643 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
644 %
645 % GetImageAlphaChannel() returns MagickFalse if the image alpha channel is
646 % not activated. That is, the image is RGB rather than RGBA or CMYK rather
647 % than CMYKA.
648 %
649 % The format of the GetImageAlphaChannel method is:
650 %
651 % MagickBooleanType GetImageAlphaChannel(const Image *image)
652 %
653 % A description of each parameter follows:
654 %
655 % o image: the image.
656 %
657 */
659 {
660  assert(image != (const Image *) NULL);
661  if (image->debug != MagickFalse)
662  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
663  assert(image->signature == MagickCoreSignature);
665 }
666 
667 /*
668 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
669 % %
670 % %
671 % %
672 % S e p a r a t e I m a g e %
673 % %
674 % %
675 % %
676 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
677 %
678 % SeparateImage() separates a channel from the image and returns it as a
679 % grayscale image.
680 %
681 % The format of the SeparateImage method is:
682 %
683 % Image *SeparateImage(const Image *image,const ChannelType channel,
684 % ExceptionInfo *exception)
685 %
686 % A description of each parameter follows:
687 %
688 % o image: the image.
689 %
690 % o channel: the image channel.
691 %
692 % o exception: return any errors or warnings in this structure.
693 %
694 */
696  const ChannelType channel_type,ExceptionInfo *exception)
697 {
698 #define GetChannelBit(mask,bit) (((size_t) (mask) >> (size_t) (bit)) & 0x01)
699 #define SeparateImageTag "Separate/Image"
700 
701  CacheView
702  *image_view,
703  *separate_view;
704 
705  Image
706  *separate_image;
707 
709  status;
710 
712  progress;
713 
714  ssize_t
715  y;
716 
717  /*
718  Initialize separate image attributes.
719  */
720  assert(image != (Image *) NULL);
721  assert(image->signature == MagickCoreSignature);
722  if (image->debug != MagickFalse)
723  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
724  assert(exception != (ExceptionInfo *) NULL);
725  assert(exception->signature == MagickCoreSignature);
726  separate_image=CloneImage(image,image->columns,image->rows,MagickTrue,
727  exception);
728  if (separate_image == (Image *) NULL)
729  return((Image *) NULL);
730  if (SetImageStorageClass(separate_image,DirectClass,exception) == MagickFalse)
731  {
732  separate_image=DestroyImage(separate_image);
733  return((Image *) NULL);
734  }
735  separate_image->alpha_trait=UndefinedPixelTrait;
736  (void) SetImageColorspace(separate_image,GRAYColorspace,exception);
737  separate_image->gamma=image->gamma;
738  /*
739  Separate image.
740  */
741  status=MagickTrue;
742  progress=0;
743  image_view=AcquireVirtualCacheView(image,exception);
744  separate_view=AcquireAuthenticCacheView(separate_image,exception);
745 #if defined(MAGICKCORE_OPENMP_SUPPORT)
746  #pragma omp parallel for schedule(static) shared(progress,status) \
747  magick_number_threads(image,image,image->rows,1)
748 #endif
749  for (y=0; y < (ssize_t) image->rows; y++)
750  {
751  register const Quantum
752  *magick_restrict p;
753 
754  register Quantum
755  *magick_restrict q;
756 
757  register ssize_t
758  x;
759 
760  if (status == MagickFalse)
761  continue;
762  p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
763  q=QueueCacheViewAuthenticPixels(separate_view,0,y,separate_image->columns,1,
764  exception);
765  if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
766  {
767  status=MagickFalse;
768  continue;
769  }
770  for (x=0; x < (ssize_t) image->columns; x++)
771  {
772  register ssize_t
773  i;
774 
775  if (GetPixelWriteMask(image,p) <= (QuantumRange/2))
776  {
777  SetPixelBackgoundColor(separate_image,q);
778  p+=GetPixelChannels(image);
779  q+=GetPixelChannels(separate_image);
780  continue;
781  }
782  SetPixelChannel(separate_image,GrayPixelChannel,0,q);
783  for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
784  {
785  PixelChannel channel = GetPixelChannelChannel(image,i);
786  PixelTrait traits = GetPixelChannelTraits(image,channel);
787  if ((traits == UndefinedPixelTrait) ||
788  (GetChannelBit(channel_type,channel) == 0))
789  continue;
790  SetPixelChannel(separate_image,GrayPixelChannel,p[i],q);
791  }
792  p+=GetPixelChannels(image);
793  q+=GetPixelChannels(separate_image);
794  }
795  if (SyncCacheViewAuthenticPixels(separate_view,exception) == MagickFalse)
796  status=MagickFalse;
797  if (image->progress_monitor != (MagickProgressMonitor) NULL)
798  {
800  proceed;
801 
802 #if defined(MAGICKCORE_OPENMP_SUPPORT)
803  #pragma omp critical (MagickCore_SeparateImage)
804 #endif
805  proceed=SetImageProgress(image,SeparateImageTag,progress++,image->rows);
806  if (proceed == MagickFalse)
807  status=MagickFalse;
808  }
809  }
810  separate_view=DestroyCacheView(separate_view);
811  image_view=DestroyCacheView(image_view);
812  (void) SetImageChannelMask(separate_image,DefaultChannels);
813  if (status == MagickFalse)
814  separate_image=DestroyImage(separate_image);
815  return(separate_image);
816 }
817 
818 /*
819 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
820 % %
821 % %
822 % %
823 % S e p a r a t e I m a g e s %
824 % %
825 % %
826 % %
827 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
828 %
829 % SeparateImages() returns a separate grayscale image for each channel
830 % specified.
831 %
832 % The format of the SeparateImages method is:
833 %
834 % Image *SeparateImages(const Image *image,ExceptionInfo *exception)
835 %
836 % A description of each parameter follows:
837 %
838 % o image: the image.
839 %
840 % o exception: return any errors or warnings in this structure.
841 %
842 */
844 {
845  Image
846  *images,
847  *separate_image;
848 
849  register ssize_t
850  i;
851 
852  assert(image != (Image *) NULL);
853  assert(image->signature == MagickCoreSignature);
854  if (image->debug != MagickFalse)
855  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
856  images=NewImageList();
857  for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
858  {
859  PixelChannel channel = GetPixelChannelChannel(image,i);
860  PixelTrait traits = GetPixelChannelTraits(image,channel);
861  if ((traits == UndefinedPixelTrait) || ((traits & UpdatePixelTrait) == 0))
862  continue;
863  separate_image=SeparateImage(image,(ChannelType) (1 << channel),exception);
864  if (separate_image != (Image *) NULL)
865  AppendImageToList(&images,separate_image);
866  }
867  if (images == (Image *) NULL)
868  images=SeparateImage(image,UndefinedChannel,exception);
869  return(images);
870 }
871 
872 /*
873 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
874 % %
875 % %
876 % %
877 % S e t I m a g e A l p h a C h a n n e l %
878 % %
879 % %
880 % %
881 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
882 %
883 % SetImageAlphaChannel() activates, deactivates, resets, or sets the alpha
884 % channel.
885 %
886 % The format of the SetImageAlphaChannel method is:
887 %
888 % MagickBooleanType SetImageAlphaChannel(Image *image,
889 % const AlphaChannelOption alpha_type,ExceptionInfo *exception)
890 %
891 % A description of each parameter follows:
892 %
893 % o image: the image.
894 %
895 % o alpha_type: The alpha channel type: ActivateAlphaChannel,
896 % AssociateAlphaChannel, CopyAlphaChannel, DeactivateAlphaChannel,
897 % DisassociateAlphaChannel, ExtractAlphaChannel, OffAlphaChannel,
898 % OnAlphaChannel, OpaqueAlphaChannel, SetAlphaChannel, ShapeAlphaChannel,
899 % and TransparentAlphaChannel.
900 %
901 % o exception: return any errors or warnings in this structure.
902 %
903 */
904 
905 static inline void FlattenPixelInfo(const Image *image,const PixelInfo *p,
906  const double alpha,const Quantum *q,const double beta,
907  Quantum *composite)
908 {
909  double
910  Da,
911  gamma,
912  Sa;
913 
914  register ssize_t
915  i;
916 
917  /*
918  Compose pixel p over pixel q with the given alpha.
919  */
920  Sa=QuantumScale*alpha;
921  Da=QuantumScale*beta,
922  gamma=Sa*(-Da)+Sa+Da;
923  gamma=PerceptibleReciprocal(gamma);
924  for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
925  {
926  PixelChannel channel = GetPixelChannelChannel(image,i);
927  PixelTrait traits = GetPixelChannelTraits(image,channel);
928  if (traits == UndefinedPixelTrait)
929  continue;
930  switch (channel)
931  {
932  case RedPixelChannel:
933  {
934  composite[i]=ClampToQuantum(gamma*MagickOver_((double) q[i],beta,
935  (double) p->red,alpha));
936  break;
937  }
938  case GreenPixelChannel:
939  {
940  composite[i]=ClampToQuantum(gamma*MagickOver_((double) q[i],beta,
941  (double) p->green,alpha));
942  break;
943  }
944  case BluePixelChannel:
945  {
946  composite[i]=ClampToQuantum(gamma*MagickOver_((double) q[i],beta,
947  (double) p->blue,alpha));
948  break;
949  }
950  case BlackPixelChannel:
951  {
952  composite[i]=ClampToQuantum(gamma*MagickOver_((double) q[i],beta,
953  (double) p->black,alpha));
954  break;
955  }
956  case AlphaPixelChannel:
957  {
958  composite[i]=ClampToQuantum(QuantumRange*(Sa*(-Da)+Sa+Da));
959  break;
960  }
961  default:
962  break;
963  }
964  }
965 }
966 
968  const AlphaChannelOption alpha_type,ExceptionInfo *exception)
969 {
970  CacheView
971  *image_view;
972 
974  status;
975 
976  ssize_t
977  y;
978 
979  assert(image != (Image *) NULL);
980  if (image->debug != MagickFalse)
981  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
982  assert(image->signature == MagickCoreSignature);
983  status=MagickTrue;
984  switch (alpha_type)
985  {
987  {
989  break;
990  }
992  {
993  /*
994  Associate alpha.
995  */
996  status=SetImageStorageClass(image,DirectClass,exception);
997  if (status == MagickFalse)
998  break;
999  image_view=AcquireAuthenticCacheView(image,exception);
1000 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1001  #pragma omp parallel for schedule(static) shared(status) \
1002  magick_number_threads(image,image,image->rows,1)
1003 #endif
1004  for (y=0; y < (ssize_t) image->rows; y++)
1005  {
1006  register Quantum
1007  *magick_restrict q;
1008 
1009  register ssize_t
1010  x;
1011 
1012  if (status == MagickFalse)
1013  continue;
1014  q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
1015  exception);
1016  if (q == (Quantum *) NULL)
1017  {
1018  status=MagickFalse;
1019  continue;
1020  }
1021  for (x=0; x < (ssize_t) image->columns; x++)
1022  {
1023  double
1024  gamma;
1025 
1026  register ssize_t
1027  i;
1028 
1029  if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
1030  {
1031  q+=GetPixelChannels(image);
1032  continue;
1033  }
1034  gamma=QuantumScale*GetPixelAlpha(image,q);
1035  for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
1036  {
1037  PixelChannel channel = GetPixelChannelChannel(image,i);
1038  PixelTrait traits = GetPixelChannelTraits(image,channel);
1039  if (channel == AlphaPixelChannel)
1040  continue;
1041  if ((traits & UpdatePixelTrait) == 0)
1042  continue;
1043  q[i]=ClampToQuantum(gamma*q[i]);
1044  }
1045  q+=GetPixelChannels(image);
1046  }
1047  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
1048  status=MagickFalse;
1049  }
1050  image_view=DestroyCacheView(image_view);
1051  image->alpha_trait=CopyPixelTrait;
1052  return(status);
1053  }
1055  {
1056  /*
1057  Set transparent pixels to background color.
1058  */
1059  if (image->alpha_trait == UndefinedPixelTrait)
1060  break;
1061  status=SetImageStorageClass(image,DirectClass,exception);
1062  if (status == MagickFalse)
1063  break;
1064  image_view=AcquireAuthenticCacheView(image,exception);
1065 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1066  #pragma omp parallel for schedule(static) shared(status) \
1067  magick_number_threads(image,image,image->rows,1)
1068 #endif
1069  for (y=0; y < (ssize_t) image->rows; y++)
1070  {
1071  register Quantum
1072  *magick_restrict q;
1073 
1074  register ssize_t
1075  x;
1076 
1077  if (status == MagickFalse)
1078  continue;
1079  q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
1080  exception);
1081  if (q == (Quantum *) NULL)
1082  {
1083  status=MagickFalse;
1084  continue;
1085  }
1086  for (x=0; x < (ssize_t) image->columns; x++)
1087  {
1088  if (GetPixelAlpha(image,q) == TransparentAlpha)
1089  {
1090  SetPixelViaPixelInfo(image,&image->background_color,q);
1092  }
1093  q+=GetPixelChannels(image);
1094  }
1095  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
1096  status=MagickFalse;
1097  }
1098  image_view=DestroyCacheView(image_view);
1099  return(status);
1100  }
1101  case CopyAlphaChannel:
1102  {
1104  status=CompositeImage(image,image,IntensityCompositeOp,MagickTrue,0,0,
1105  exception);
1106  break;
1107  }
1109  {
1110  if (image->alpha_trait == UndefinedPixelTrait)
1111  status=SetImageAlpha(image,OpaqueAlpha,exception);
1112  image->alpha_trait=CopyPixelTrait;
1113  break;
1114  }
1116  {
1117  /*
1118  Disassociate alpha.
1119  */
1120  status=SetImageStorageClass(image,DirectClass,exception);
1121  if (status == MagickFalse)
1122  break;
1124  image_view=AcquireAuthenticCacheView(image,exception);
1125 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1126  #pragma omp parallel for schedule(static) shared(status) \
1127  magick_number_threads(image,image,image->rows,1)
1128 #endif
1129  for (y=0; y < (ssize_t) image->rows; y++)
1130  {
1131  register Quantum
1132  *magick_restrict q;
1133 
1134  register ssize_t
1135  x;
1136 
1137  if (status == MagickFalse)
1138  continue;
1139  q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
1140  exception);
1141  if (q == (Quantum *) NULL)
1142  {
1143  status=MagickFalse;
1144  continue;
1145  }
1146  for (x=0; x < (ssize_t) image->columns; x++)
1147  {
1148  double
1149  gamma,
1150  Sa;
1151 
1152  register ssize_t
1153  i;
1154 
1155  if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
1156  {
1157  q+=GetPixelChannels(image);
1158  continue;
1159  }
1160  Sa=QuantumScale*GetPixelAlpha(image,q);
1161  gamma=PerceptibleReciprocal(Sa);
1162  for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
1163  {
1164  PixelChannel channel = GetPixelChannelChannel(image,i);
1165  PixelTrait traits = GetPixelChannelTraits(image,channel);
1166  if (channel == AlphaPixelChannel)
1167  continue;
1168  if ((traits & UpdatePixelTrait) == 0)
1169  continue;
1170  q[i]=ClampToQuantum(gamma*q[i]);
1171  }
1172  q+=GetPixelChannels(image);
1173  }
1174  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
1175  status=MagickFalse;
1176  }
1177  image_view=DestroyCacheView(image_view);
1179  return(status);
1180  }
1181  case DiscreteAlphaChannel:
1182  {
1183  if (image->alpha_trait == UndefinedPixelTrait)
1184  status=SetImageAlpha(image,OpaqueAlpha,exception);
1186  break;
1187  }
1188  case ExtractAlphaChannel:
1189  {
1190  status=CompositeImage(image,image,AlphaCompositeOp,MagickTrue,0,0,
1191  exception);
1193  break;
1194  }
1195  case OffAlphaChannel:
1196  {
1198  break;
1199  }
1200  case OnAlphaChannel:
1201  {
1202  if (image->alpha_trait == UndefinedPixelTrait)
1203  status=SetImageAlpha(image,OpaqueAlpha,exception);
1205  break;
1206  }
1207  case OpaqueAlphaChannel:
1208  {
1209  status=SetImageAlpha(image,OpaqueAlpha,exception);
1210  break;
1211  }
1212  case RemoveAlphaChannel:
1213  {
1214  /*
1215  Remove transparency.
1216  */
1217  if (image->alpha_trait == UndefinedPixelTrait)
1218  break;
1219  status=SetImageStorageClass(image,DirectClass,exception);
1220  if (status == MagickFalse)
1221  break;
1222  image_view=AcquireAuthenticCacheView(image,exception);
1223 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1224  #pragma omp parallel for schedule(static) shared(status) \
1225  magick_number_threads(image,image,image->rows,1)
1226 #endif
1227  for (y=0; y < (ssize_t) image->rows; y++)
1228  {
1229  register Quantum
1230  *magick_restrict q;
1231 
1232  register ssize_t
1233  x;
1234 
1235  if (status == MagickFalse)
1236  continue;
1237  q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
1238  exception);
1239  if (q == (Quantum *) NULL)
1240  {
1241  status=MagickFalse;
1242  continue;
1243  }
1244  for (x=0; x < (ssize_t) image->columns; x++)
1245  {
1246  FlattenPixelInfo(image,&image->background_color,
1247  image->background_color.alpha,q,(double)
1248  GetPixelAlpha(image,q),q);
1249  q+=GetPixelChannels(image);
1250  }
1251  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
1252  status=MagickFalse;
1253  }
1254  image_view=DestroyCacheView(image_view);
1256  break;
1257  }
1258  case SetAlphaChannel:
1259  {
1260  if (image->alpha_trait == UndefinedPixelTrait)
1261  status=SetImageAlpha(image,OpaqueAlpha,exception);
1262  break;
1263  }
1264  case ShapeAlphaChannel:
1265  {
1266  /*
1267  Set alpha channel by shape.
1268  */
1269  status=SetImageStorageClass(image,DirectClass,exception);
1270  if (status == MagickFalse)
1271  break;
1273  (void) SetImageMask(image,WritePixelMask,image,exception);
1274  (void) LevelImageColors(image,&image->background_color,
1275  &image->background_color,MagickTrue,exception);
1276  (void) SetImageMask(image,WritePixelMask,(Image *) NULL,exception);
1277  break;
1278  }
1280  {
1281  status=SetImageAlpha(image,TransparentAlpha,exception);
1282  break;
1283  }
1284  case UndefinedAlphaChannel:
1285  break;
1286  }
1287  if (status == MagickFalse)
1288  return(status);
1289  (void) SetPixelChannelMask(image,image->channel_mask);
1290  return(SyncImagePixelCache(image,exception));
1291 }
size_t rows
Definition: image.h:172
#define magick_restrict
Definition: MagickCore.h:41
MagickExport CacheView * DestroyCacheView(CacheView *cache_view)
Definition: cache-view.c:252
static double MagickOver_(const double p, const double alpha, const double q, const double beta)
#define TransparentAlpha
Definition: image.h:26
static MagickBooleanType SetImageProgress(const Image *image, const char *tag, const MagickOffsetType offset, const MagickSizeType extent)
#define GetChannelBit(mask, bit)
MagickProgressMonitor progress_monitor
Definition: image.h:303
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)
PixelTrait alpha_trait
Definition: pixel.h:176
AlphaChannelOption
Definition: image.h:28
static Quantum GetPixelGray(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
size_t signature
Definition: exception.h:123
ChannelFx
Definition: channel.c:108
#define CombineImageTag
#define OpaqueAlpha
Definition: image.h:25
static Quantum GetPixelChannel(const Image *magick_restrict image, const PixelChannel channel, const Quantum *magick_restrict pixel)
MagickPrivate MagickBooleanType SyncImagePixelCache(Image *, ExceptionInfo *)
Definition: cache.c:5280
MagickRealType red
Definition: pixel.h:188
MagickExport MagickBooleanType SetImageAlpha(Image *image, const Quantum alpha, ExceptionInfo *exception)
Definition: image.c:2318
MagickBooleanType read_mask
Definition: image.h:276
static PixelTrait GetPixelChannelTraits(const Image *magick_restrict image, const PixelChannel channel)
MagickExport Image * ChannelFxImage(const Image *image, const char *expression, ExceptionInfo *exception)
Definition: channel.c:194
static void SetPixelViaPixelInfo(const Image *magick_restrict image, const PixelInfo *magick_restrict pixel_info, Quantum *magick_restrict pixel)
static MagickBooleanType IsGrayColorspace(const ColorspaceType colorspace)
MagickExport const Quantum * GetCacheViewVirtualPixels(const CacheView *cache_view, const ssize_t x, const ssize_t y, const size_t columns, const size_t rows, ExceptionInfo *exception)
Definition: cache-view.c:651
MagickRealType alpha
Definition: pixel.h:188
#define MagickEpsilon
Definition: magick-type.h:110
MagickExport MagickBooleanType CompositeImage(Image *image, const Image *composite, const CompositeOperator compose, const MagickBooleanType clip_to_self, const ssize_t x_offset, const ssize_t y_offset, ExceptionInfo *exception)
Definition: composite.c:539
MagickExport Image * CombineImages(const Image *image, const ColorspaceType colorspace, ExceptionInfo *exception)
Definition: channel.c:482
Definition: log.h:52
ssize_t MagickOffsetType
Definition: magick-type.h:127
MagickExport ssize_t ParseChannelOption(const char *channels)
Definition: option.c:2836
Definition: image.h:151
#define MagickCoreSignature
MagickExport Quantum * GetCacheViewAuthenticPixels(CacheView *cache_view, const ssize_t x, const ssize_t y, const size_t columns, const size_t rows, ExceptionInfo *exception)
Definition: cache-view.c:299
MagickExport Image * GetFirstImageInList(const Image *images)
Definition: list.c:545
MagickExport MagickBooleanType SetImageMask(Image *image, const PixelMask type, const Image *mask, ExceptionInfo *exception)
Definition: image.c:3167
MagickExport MagickBooleanType SetImageAlphaChannel(Image *image, const AlphaChannelOption alpha_type, ExceptionInfo *exception)
Definition: channel.c:967
MagickBooleanType
Definition: magick-type.h:156
MagickExport Image * NewImageList(void)
Definition: list.c:929
static double PerceptibleReciprocal(const double x)
static Quantum GetPixelWriteMask(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static void FlattenPixelInfo(const Image *image, const PixelInfo *p, const double alpha, const Quantum *q, const double beta, Quantum *composite)
Definition: channel.c:905
MagickExport Image * SeparateImage(const Image *image, const ChannelType channel_type, ExceptionInfo *exception)
Definition: channel.c:695
ChannelType channel_mask
Definition: image.h:288
#define MagickPathExtent
PixelTrait alpha_trait
Definition: image.h:280
MagickRealType blue
Definition: pixel.h:188
MagickExport ChannelType SetPixelChannelMask(Image *image, const ChannelType channel_mask)
Definition: pixel.c:6268
MagickExport ChannelType SetImageChannelMask(Image *image, const ChannelType channel_mask)
Definition: image.c:2486
MagickExport Quantum * QueueCacheViewAuthenticPixels(CacheView *cache_view, const ssize_t x, const ssize_t y, const size_t columns, const size_t rows, ExceptionInfo *exception)
Definition: cache-view.c:977
MagickExport MagickBooleanType ThrowMagickException(ExceptionInfo *exception, const char *module, const char *function, const size_t line, const ExceptionType severity, const char *tag, const char *format,...)
Definition: exception.c:1058
MagickExport MagickBooleanType LogMagickEvent(const LogEventType type, const char *module, const char *function, const size_t line, const char *format,...)
Definition: log.c:1397
size_t signature
Definition: image.h:354
MagickExport MagickBooleanType LevelImageColors(Image *image, const PixelInfo *black_color, const PixelInfo *white_color, const MagickBooleanType invert, ExceptionInfo *exception)
Definition: enhance.c:2715
#define QuantumScale
Definition: magick-type.h:113
size_t columns
Definition: image.h:172
MagickBooleanType(* MagickProgressMonitor)(const char *, const MagickOffsetType, const MagickSizeType, void *)
Definition: monitor.h:26
MagickExport Image * GetLastImageInList(const Image *images)
Definition: list.c:728
ChannelType
Definition: pixel.h:33
MagickExport MagickBooleanType SetImageStorageClass(Image *image, const ClassType storage_class, ExceptionInfo *exception)
Definition: image.c:2602
MagickExport Image * DestroyImageList(Image *images)
Definition: list.c:446
PixelChannel
Definition: pixel.h:66
static size_t GetPixelChannels(const Image *magick_restrict image)
char filename[MagickPathExtent]
Definition: image.h:319
#define GetMagickModule()
Definition: log.h:28
static Quantum ClampToQuantum(const MagickRealType value)
Definition: quantum.h:84
static PixelChannel GetPixelChannelChannel(const Image *magick_restrict image, const ssize_t offset)
MagickExport CacheView * AcquireVirtualCacheView(const Image *image, ExceptionInfo *exception)
Definition: cache-view.c:149
MagickExport void GetNextToken(const char *start, const char **end, const size_t extent, char *token)
Definition: token.c:171
static double StringToDoubleInterval(const char *string, const double interval)
unsigned short Quantum
Definition: magick-type.h:82
MagickExport MagickBooleanType SetImageColorspace(Image *image, const ColorspaceType colorspace, ExceptionInfo *exception)
Definition: colorspace.c:1134
MagickExport MagickBooleanType GetImageAlphaChannel(const Image *image)
Definition: channel.c:658
MagickExport Image * GetNextImageInList(const Image *images)
Definition: list.c:762
MagickRealType black
Definition: pixel.h:188
#define SeparateImageTag
static void SetPixelChannel(const Image *magick_restrict image, const PixelChannel channel, const Quantum quantum, Quantum *magick_restrict pixel)
MagickExport void AppendImageToList(Image **images, const Image *append)
Definition: list.c:77
#define MagickMin(x, y)
Definition: image-private.h:27
ColorspaceType
Definition: colorspace.h:25
#define ChannelFxImageTag
MagickRealType green
Definition: pixel.h:188
MagickExport ssize_t ParsePixelChannelOption(const char *channels)
Definition: option.c:3062
#define MagickExport
MagickExport MagickBooleanType SyncCacheViewAuthenticPixels(CacheView *magick_restrict cache_view, ExceptionInfo *exception)
Definition: cache-view.c:1100
MagickExport MagickBooleanType SetPixelMetaChannels(Image *image, const size_t number_meta_channels, ExceptionInfo *exception)
Definition: pixel.c:6350
MagickExport CacheView * AcquireAuthenticCacheView(const Image *image, ExceptionInfo *exception)
Definition: cache-view.c:112
PixelTrait
Definition: pixel.h:132
MagickBooleanType write_mask
Definition: image.h:276
PixelInfo background_color
Definition: image.h:179
MagickExport size_t GetImageListLength(const Image *images)
Definition: list.c:687
static MagickBooleanType ChannelImage(Image *destination_image, const PixelChannel destination_channel, const ChannelFx channel_op, const Image *source_image, const PixelChannel source_channel, const Quantum pixel, ExceptionInfo *exception)
Definition: channel.c:116
MagickExport Image * SeparateImages(const Image *image, ExceptionInfo *exception)
Definition: channel.c:843
MagickExport Image * DestroyImage(Image *image)
Definition: image.c:1183
MagickExport Image * CloneImage(const Image *image, const size_t columns, const size_t rows, const MagickBooleanType detach, ExceptionInfo *exception)
Definition: image.c:800
double gamma
Definition: image.h:186
ColorspaceType colorspace
Definition: image.h:157
#define QuantumRange
Definition: magick-type.h:83
MagickBooleanType debug
Definition: image.h:334