MagickCore  7.0.8
Convert, Edit, Or Compose Bitmap Images
attribute.c
Go to the documentation of this file.
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % %
4 % %
5 % %
6 % AAA TTTTT TTTTT RRRR IIIII BBBB U U TTTTT EEEEE %
7 % A A T T R R I B B U U T E %
8 % AAAAA T T RRRR I BBBB U U T EEE %
9 % A A T T R R I B B U U T E %
10 % A A T T R R IIIII BBBB UUU T EEEEE %
11 % %
12 % %
13 % MagickCore Get / Set Image Attributes %
14 % %
15 % Software Design %
16 % Cristy %
17 % October 2002 %
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"
44 #include "MagickCore/artifact.h"
45 #include "MagickCore/attribute.h"
46 #include "MagickCore/blob.h"
48 #include "MagickCore/cache.h"
50 #include "MagickCore/cache-view.h"
51 #include "MagickCore/channel.h"
52 #include "MagickCore/client.h"
53 #include "MagickCore/color.h"
55 #include "MagickCore/colormap.h"
57 #include "MagickCore/colorspace.h"
59 #include "MagickCore/composite.h"
61 #include "MagickCore/constitute.h"
62 #include "MagickCore/draw.h"
64 #include "MagickCore/effect.h"
65 #include "MagickCore/enhance.h"
66 #include "MagickCore/exception.h"
68 #include "MagickCore/geometry.h"
69 #include "MagickCore/histogram.h"
70 #include "MagickCore/identify.h"
71 #include "MagickCore/image.h"
73 #include "MagickCore/list.h"
74 #include "MagickCore/log.h"
75 #include "MagickCore/memory_.h"
76 #include "MagickCore/magick.h"
77 #include "MagickCore/monitor.h"
79 #include "MagickCore/option.h"
80 #include "MagickCore/paint.h"
81 #include "MagickCore/pixel.h"
83 #include "MagickCore/property.h"
84 #include "MagickCore/quantize.h"
86 #include "MagickCore/random_.h"
87 #include "MagickCore/resource_.h"
88 #include "MagickCore/semaphore.h"
89 #include "MagickCore/segment.h"
90 #include "MagickCore/splay-tree.h"
91 #include "MagickCore/string_.h"
93 #include "MagickCore/threshold.h"
94 #include "MagickCore/transform.h"
95 #include "MagickCore/utility.h"
96 
97 /*
98 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
99 % %
100 % %
101 % %
102 + G e t I m a g e B o u n d i n g B o x %
103 % %
104 % %
105 % %
106 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
107 %
108 % GetImageBoundingBox() returns the bounding box of an image canvas.
109 %
110 % The format of the GetImageBoundingBox method is:
111 %
112 % RectangleInfo GetImageBoundingBox(const Image *image,
113 % ExceptionInfo *exception)
114 %
115 % A description of each parameter follows:
116 %
117 % o bounds: Method GetImageBoundingBox returns the bounding box of an
118 % image canvas.
119 %
120 % o image: the image.
121 %
122 % o exception: return any errors or warnings in this structure.
123 %
124 */
126  ExceptionInfo *exception)
127 {
128  CacheView
129  *image_view;
130 
132  status;
133 
134  PixelInfo
135  target[3],
136  zero;
137 
139  bounds;
140 
141  register const Quantum
142  *r;
143 
144  ssize_t
145  y;
146 
147  assert(image != (Image *) NULL);
148  assert(image->signature == MagickCoreSignature);
149  if (image->debug != MagickFalse)
150  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
151  bounds.width=0;
152  bounds.height=0;
153  bounds.x=(ssize_t) image->columns;
154  bounds.y=(ssize_t) image->rows;
155  GetPixelInfo(image,&target[0]);
156  image_view=AcquireVirtualCacheView(image,exception);
157  r=GetCacheViewVirtualPixels(image_view,0,0,1,1,exception);
158  if (r == (const Quantum *) NULL)
159  {
160  image_view=DestroyCacheView(image_view);
161  return(bounds);
162  }
163  GetPixelInfoPixel(image,r,&target[0]);
164  GetPixelInfo(image,&target[1]);
165  r=GetCacheViewVirtualPixels(image_view,(ssize_t) image->columns-1,0,1,1,
166  exception);
167  if (r != (const Quantum *) NULL)
168  GetPixelInfoPixel(image,r,&target[1]);
169  GetPixelInfo(image,&target[2]);
170  r=GetCacheViewVirtualPixels(image_view,0,(ssize_t) image->rows-1,1,1,
171  exception);
172  if (r != (const Quantum *) NULL)
173  GetPixelInfoPixel(image,r,&target[2]);
174  status=MagickTrue;
175  GetPixelInfo(image,&zero);
176 #if defined(MAGICKCORE_OPENMP_SUPPORT)
177  #pragma omp parallel for schedule(static) shared(status) \
178  magick_number_threads(image,image,image->rows,1)
179 #endif
180  for (y=0; y < (ssize_t) image->rows; y++)
181  {
182  PixelInfo
183  pixel;
184 
186  bounding_box;
187 
188  register const Quantum
189  *magick_restrict p;
190 
191  register ssize_t
192  x;
193 
194  if (status == MagickFalse)
195  continue;
196 #if defined(MAGICKCORE_OPENMP_SUPPORT)
197 # pragma omp critical (MagickCore_GetImageBoundingBox)
198 #endif
199  bounding_box=bounds;
200  p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
201  if (p == (const Quantum *) NULL)
202  {
203  status=MagickFalse;
204  continue;
205  }
206  pixel=zero;
207  for (x=0; x < (ssize_t) image->columns; x++)
208  {
209  GetPixelInfoPixel(image,p,&pixel);
210  if ((x < bounding_box.x) &&
211  (IsFuzzyEquivalencePixelInfo(&pixel,&target[0]) == MagickFalse))
212  bounding_box.x=x;
213  if ((x > (ssize_t) bounding_box.width) &&
214  (IsFuzzyEquivalencePixelInfo(&pixel,&target[1]) == MagickFalse))
215  bounding_box.width=(size_t) x;
216  if ((y < bounding_box.y) &&
217  (IsFuzzyEquivalencePixelInfo(&pixel,&target[0]) == MagickFalse))
218  bounding_box.y=y;
219  if ((y > (ssize_t) bounding_box.height) &&
220  (IsFuzzyEquivalencePixelInfo(&pixel,&target[2]) == MagickFalse))
221  bounding_box.height=(size_t) y;
222  p+=GetPixelChannels(image);
223  }
224 #if defined(MAGICKCORE_OPENMP_SUPPORT)
225 # pragma omp critical (MagickCore_GetImageBoundingBox)
226 #endif
227  {
228  if (bounding_box.x < bounds.x)
229  bounds.x=bounding_box.x;
230  if (bounding_box.y < bounds.y)
231  bounds.y=bounding_box.y;
232  if (bounding_box.width > bounds.width)
233  bounds.width=bounding_box.width;
234  if (bounding_box.height > bounds.height)
235  bounds.height=bounding_box.height;
236  }
237  }
238  image_view=DestroyCacheView(image_view);
239  if ((bounds.width == 0) && (bounds.height == 0))
241  "GeometryDoesNotContainImage","`%s'",image->filename);
242  else
243  {
244  bounds.width-=(bounds.x-1);
245  bounds.height-=(bounds.y-1);
246  }
247  return(bounds);
248 }
249 
250 /*
251 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
252 % %
253 % %
254 % %
255 % G e t I m a g e D e p t h %
256 % %
257 % %
258 % %
259 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
260 %
261 % GetImageDepth() returns the depth of a particular image channel.
262 %
263 % The format of the GetImageDepth method is:
264 %
265 % size_t GetImageDepth(const Image *image,ExceptionInfo *exception)
266 %
267 % A description of each parameter follows:
268 %
269 % o image: the image.
270 %
271 % o exception: return any errors or warnings in this structure.
272 %
273 */
274 MagickExport size_t GetImageDepth(const Image *image,ExceptionInfo *exception)
275 {
276  CacheView
277  *image_view;
278 
280  status;
281 
282  register ssize_t
283  i;
284 
285  size_t
286  *current_depth,
287  depth,
288  number_threads;
289 
290  ssize_t
291  y;
292 
293  /*
294  Compute image depth.
295  */
296  assert(image != (Image *) NULL);
297  assert(image->signature == MagickCoreSignature);
298  if (image->debug != MagickFalse)
299  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
300  number_threads=(size_t) GetMagickResourceLimit(ThreadResource);
301  current_depth=(size_t *) AcquireQuantumMemory(number_threads,
302  sizeof(*current_depth));
303  if (current_depth == (size_t *) NULL)
304  ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
305  status=MagickTrue;
306  for (i=0; i < (ssize_t) number_threads; i++)
307  current_depth[i]=1;
308  if ((image->storage_class == PseudoClass) &&
309  (image->alpha_trait == UndefinedPixelTrait))
310  {
311  for (i=0; i < (ssize_t) image->colors; i++)
312  {
313  const int
314  id = GetOpenMPThreadId();
315 
316  while (current_depth[id] < MAGICKCORE_QUANTUM_DEPTH)
317  {
319  atDepth;
320 
321  QuantumAny
322  range;
323 
324  atDepth=MagickTrue;
325  range=GetQuantumRange(current_depth[id]);
326  if ((atDepth != MagickFalse) &&
327  (GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
328  if (IsPixelAtDepth(ClampToQuantum(image->colormap[i].red),range) == MagickFalse)
329  atDepth=MagickFalse;
330  if ((atDepth != MagickFalse) &&
331  (GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
332  if (IsPixelAtDepth(ClampToQuantum(image->colormap[i].green),range) == MagickFalse)
333  atDepth=MagickFalse;
334  if ((atDepth != MagickFalse) &&
335  (GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
336  if (IsPixelAtDepth(ClampToQuantum(image->colormap[i].blue),range) == MagickFalse)
337  atDepth=MagickFalse;
338  if ((atDepth != MagickFalse))
339  break;
340  current_depth[id]++;
341  }
342  }
343  depth=current_depth[0];
344  for (i=1; i < (ssize_t) number_threads; i++)
345  if (depth < current_depth[i])
346  depth=current_depth[i];
347  current_depth=(size_t *) RelinquishMagickMemory(current_depth);
348  return(depth);
349  }
350  image_view=AcquireVirtualCacheView(image,exception);
351 #if !defined(MAGICKCORE_HDRI_SUPPORT)
352  if ((1UL*QuantumRange) <= MaxMap)
353  {
354  size_t
355  *depth_map;
356 
357  /*
358  Scale pixels to desired (optimized with depth map).
359  */
360  depth_map=(size_t *) AcquireQuantumMemory(MaxMap+1,sizeof(*depth_map));
361  if (depth_map == (size_t *) NULL)
362  ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
363  for (i=0; i <= (ssize_t) MaxMap; i++)
364  {
365  unsigned int
366  depth;
367 
368  for (depth=1; depth < MAGICKCORE_QUANTUM_DEPTH; depth++)
369  {
370  Quantum
371  pixel;
372 
373  QuantumAny
374  range;
375 
376  range=GetQuantumRange(depth);
377  pixel=(Quantum) i;
378  if (pixel == ScaleAnyToQuantum(ScaleQuantumToAny(pixel,range),range))
379  break;
380  }
381  depth_map[i]=depth;
382  }
383 #if defined(MAGICKCORE_OPENMP_SUPPORT)
384  #pragma omp parallel for schedule(static) shared(status) \
385  magick_number_threads(image,image,image->rows,1)
386 #endif
387  for (y=0; y < (ssize_t) image->rows; y++)
388  {
389  const int
390  id = GetOpenMPThreadId();
391 
392  register const Quantum
393  *magick_restrict p;
394 
395  register ssize_t
396  x;
397 
398  if (status == MagickFalse)
399  continue;
400  p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
401  if (p == (const Quantum *) NULL)
402  continue;
403  for (x=0; x < (ssize_t) image->columns; x++)
404  {
405  register ssize_t
406  i;
407 
408  for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
409  {
410  PixelChannel channel = GetPixelChannelChannel(image,i);
411  PixelTrait traits = GetPixelChannelTraits(image,channel);
412  if ((traits & UpdatePixelTrait) == 0)
413  continue;
414  if (depth_map[ScaleQuantumToMap(p[i])] > current_depth[id])
415  current_depth[id]=depth_map[ScaleQuantumToMap(p[i])];
416  }
417  p+=GetPixelChannels(image);
418  }
419  if (current_depth[id] == MAGICKCORE_QUANTUM_DEPTH)
420  status=MagickFalse;
421  }
422  image_view=DestroyCacheView(image_view);
423  depth=current_depth[0];
424  for (i=1; i < (ssize_t) number_threads; i++)
425  if (depth < current_depth[i])
426  depth=current_depth[i];
427  depth_map=(size_t *) RelinquishMagickMemory(depth_map);
428  current_depth=(size_t *) RelinquishMagickMemory(current_depth);
429  return(depth);
430  }
431 #endif
432  /*
433  Compute pixel depth.
434  */
435 #if defined(MAGICKCORE_OPENMP_SUPPORT)
436  #pragma omp parallel for schedule(static) shared(status) \
437  magick_number_threads(image,image,image->rows,1)
438 #endif
439  for (y=0; y < (ssize_t) image->rows; y++)
440  {
441  const int
442  id = GetOpenMPThreadId();
443 
444  register const Quantum
445  *magick_restrict p;
446 
447  register ssize_t
448  x;
449 
450  if (status == MagickFalse)
451  continue;
452  p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
453  if (p == (const Quantum *) NULL)
454  continue;
455  for (x=0; x < (ssize_t) image->columns; x++)
456  {
457  register ssize_t
458  i;
459 
460  for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
461  {
463  channel;
464 
465  PixelTrait
466  traits;
467 
468  channel=GetPixelChannelChannel(image,i);
469  traits=GetPixelChannelTraits(image,channel);
470  if ((traits & UpdatePixelTrait) == 0)
471  continue;
472  while (current_depth[id] < MAGICKCORE_QUANTUM_DEPTH)
473  {
474  QuantumAny
475  range;
476 
477  range=GetQuantumRange(current_depth[id]);
478  if (p[i] == ScaleAnyToQuantum(ScaleQuantumToAny(p[i],range),range))
479  break;
480  current_depth[id]++;
481  }
482  }
483  p+=GetPixelChannels(image);
484  }
485  if (current_depth[id] == MAGICKCORE_QUANTUM_DEPTH)
486  status=MagickFalse;
487  }
488  image_view=DestroyCacheView(image_view);
489  depth=current_depth[0];
490  for (i=1; i < (ssize_t) number_threads; i++)
491  if (depth < current_depth[i])
492  depth=current_depth[i];
493  current_depth=(size_t *) RelinquishMagickMemory(current_depth);
494  return(depth);
495 }
496 
497 /*
498 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
499 % %
500 % %
501 % %
502 % G e t I m a g e Q u a n t u m D e p t h %
503 % %
504 % %
505 % %
506 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
507 %
508 % GetImageQuantumDepth() returns the depth of the image rounded to a legal
509 % quantum depth: 8, 16, or 32.
510 %
511 % The format of the GetImageQuantumDepth method is:
512 %
513 % size_t GetImageQuantumDepth(const Image *image,
514 % const MagickBooleanType constrain)
515 %
516 % A description of each parameter follows:
517 %
518 % o image: the image.
519 %
520 % o constrain: A value other than MagickFalse, constrains the depth to
521 % a maximum of MAGICKCORE_QUANTUM_DEPTH.
522 %
523 */
525  const MagickBooleanType constrain)
526 {
527  size_t
528  depth;
529 
530  depth=image->depth;
531  if (depth <= 8)
532  depth=8;
533  else
534  if (depth <= 16)
535  depth=16;
536  else
537  if (depth <= 32)
538  depth=32;
539  else
540  if (depth <= 64)
541  depth=64;
542  if (constrain != MagickFalse)
543  depth=(size_t) MagickMin((double) depth,(double) MAGICKCORE_QUANTUM_DEPTH);
544  return(depth);
545 }
546 
547 /*
548 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
549 % %
550 % %
551 % %
552 % G e t I m a g e T y p e %
553 % %
554 % %
555 % %
556 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
557 %
558 % GetImageType() returns the type of image:
559 %
560 % Bilevel Grayscale GrayscaleMatte
561 % Palette PaletteMatte TrueColor
562 % TrueColorMatte ColorSeparation ColorSeparationMatte
563 %
564 % The format of the GetImageType method is:
565 %
566 % ImageType GetImageType(const Image *image)
567 %
568 % A description of each parameter follows:
569 %
570 % o image: the image.
571 %
572 */
574 {
575  assert(image != (Image *) NULL);
576  assert(image->signature == MagickCoreSignature);
577  if (image->colorspace == CMYKColorspace)
578  {
579  if (image->alpha_trait == UndefinedPixelTrait)
580  return(ColorSeparationType);
581  return(ColorSeparationAlphaType);
582  }
583  if (IsImageMonochrome(image) != MagickFalse)
584  return(BilevelType);
585  if (IsImageGray(image) != MagickFalse)
586  {
587  if (image->alpha_trait != UndefinedPixelTrait)
588  return(GrayscaleAlphaType);
589  return(GrayscaleType);
590  }
591  if (IsPaletteImage(image) != MagickFalse)
592  {
593  if (image->alpha_trait != UndefinedPixelTrait)
594  return(PaletteAlphaType);
595  return(PaletteType);
596  }
597  if (image->alpha_trait != UndefinedPixelTrait)
598  return(TrueColorAlphaType);
599  return(TrueColorType);
600 }
601 
602 /*
603 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
604 % %
605 % %
606 % %
607 % I d e n t i f y I m a g e G r a y %
608 % %
609 % %
610 % %
611 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
612 %
613 % IdentifyImageGray() returns grayscale if all the pixels in the image have
614 % the same red, green, and blue intensities, and bi-level is the intensity is
615 % either 0 or QuantumRange. Otherwise undefined is returned.
616 %
617 % The format of the IdentifyImageGray method is:
618 %
619 % ImageType IdentifyImageGray(const Image *image,ExceptionInfo *exception)
620 %
621 % A description of each parameter follows:
622 %
623 % o image: the image.
624 %
625 % o exception: return any errors or warnings in this structure.
626 %
627 */
629  ExceptionInfo *exception)
630 {
631  CacheView
632  *image_view;
633 
634  ImageType
635  type;
636 
637  register const Quantum
638  *p;
639 
640  register ssize_t
641  x;
642 
643  ssize_t
644  y;
645 
646  assert(image != (Image *) NULL);
647  assert(image->signature == MagickCoreSignature);
648  if (image->debug != MagickFalse)
649  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
650  if ((image->type == BilevelType) || (image->type == GrayscaleType) ||
651  (image->type == GrayscaleAlphaType))
652  return(image->type);
654  return(UndefinedType);
655  type=BilevelType;
656  image_view=AcquireVirtualCacheView(image,exception);
657  for (y=0; y < (ssize_t) image->rows; y++)
658  {
659  p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
660  if (p == (const Quantum *) NULL)
661  break;
662  for (x=0; x < (ssize_t) image->columns; x++)
663  {
664  if (IsPixelGray(image,p) == MagickFalse)
665  {
666  type=UndefinedType;
667  break;
668  }
669  if ((type == BilevelType) &&
670  (IsPixelMonochrome(image,p) == MagickFalse))
671  type=GrayscaleType;
672  p+=GetPixelChannels(image);
673  }
674  if (type == UndefinedType)
675  break;
676  }
677  image_view=DestroyCacheView(image_view);
678  if ((type == GrayscaleType) && (image->alpha_trait != UndefinedPixelTrait))
679  type=GrayscaleAlphaType;
680  return(type);
681 }
682 
683 /*
684 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
685 % %
686 % %
687 % %
688 % I d e n t i f y I m a g e M o n o c h r o m e %
689 % %
690 % %
691 % %
692 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
693 %
694 % IdentifyImageMonochrome() returns MagickTrue if all the pixels in the image
695 % have the same red, green, and blue intensities and the intensity is either
696 % 0 or QuantumRange.
697 %
698 % The format of the IdentifyImageMonochrome method is:
699 %
700 % MagickBooleanType IdentifyImageMonochrome(const Image *image,
701 % ExceptionInfo *exception)
702 %
703 % A description of each parameter follows:
704 %
705 % o image: the image.
706 %
707 % o exception: return any errors or warnings in this structure.
708 %
709 */
711  ExceptionInfo *exception)
712 {
713  CacheView
714  *image_view;
715 
717  bilevel;
718 
719  register ssize_t
720  x;
721 
722  register const Quantum
723  *p;
724 
725  ssize_t
726  y;
727 
728  assert(image != (Image *) NULL);
729  assert(image->signature == MagickCoreSignature);
730  if (image->debug != MagickFalse)
731  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
732  if (image->type == BilevelType)
733  return(MagickTrue);
735  return(MagickFalse);
736  bilevel=MagickTrue;
737  image_view=AcquireVirtualCacheView(image,exception);
738  for (y=0; y < (ssize_t) image->rows; y++)
739  {
740  p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
741  if (p == (const Quantum *) NULL)
742  break;
743  for (x=0; x < (ssize_t) image->columns; x++)
744  {
745  if (IsPixelMonochrome(image,p) == MagickFalse)
746  {
747  bilevel=MagickFalse;
748  break;
749  }
750  p+=GetPixelChannels(image);
751  }
752  if (bilevel == MagickFalse)
753  break;
754  }
755  image_view=DestroyCacheView(image_view);
756  return(bilevel);
757 }
758 
759 /*
760 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
761 % %
762 % %
763 % %
764 % I d e n t i f y I m a g e T y p e %
765 % %
766 % %
767 % %
768 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
769 %
770 % IdentifyImageType() returns the potential type of image:
771 %
772 % Bilevel Grayscale GrayscaleMatte
773 % Palette PaletteMatte TrueColor
774 % TrueColorMatte ColorSeparation ColorSeparationMatte
775 %
776 % To ensure the image type matches its potential, use SetImageType():
777 %
778 % (void) SetImageType(image,IdentifyImageType(image,exception),exception);
779 %
780 % The format of the IdentifyImageType method is:
781 %
782 % ImageType IdentifyImageType(const Image *image,ExceptionInfo *exception)
783 %
784 % A description of each parameter follows:
785 %
786 % o image: the image.
787 %
788 % o exception: return any errors or warnings in this structure.
789 %
790 */
792  ExceptionInfo *exception)
793 {
794  assert(image != (Image *) NULL);
795  assert(image->signature == MagickCoreSignature);
796  if (image->debug != MagickFalse)
797  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
798  if (image->colorspace == CMYKColorspace)
799  {
800  if (image->alpha_trait == UndefinedPixelTrait)
801  return(ColorSeparationType);
802  return(ColorSeparationAlphaType);
803  }
804  if (IdentifyImageMonochrome(image,exception) != MagickFalse)
805  return(BilevelType);
806  if (IdentifyImageGray(image,exception) != UndefinedType)
807  {
808  if (image->alpha_trait != UndefinedPixelTrait)
809  return(GrayscaleAlphaType);
810  return(GrayscaleType);
811  }
812  if (IdentifyPaletteImage(image,exception) != MagickFalse)
813  {
814  if (image->alpha_trait != UndefinedPixelTrait)
815  return(PaletteAlphaType);
816  return(PaletteType);
817  }
818  if (image->alpha_trait != UndefinedPixelTrait)
819  return(TrueColorAlphaType);
820  return(TrueColorType);
821 }
822 
823 /*
824 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
825 % %
826 % %
827 % %
828 % I s I m a g e G r a y %
829 % %
830 % %
831 % %
832 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
833 %
834 % IsImageGray() returns MagickTrue if the type of the image is grayscale or
835 % bi-level.
836 %
837 % The format of the IsImageGray method is:
838 %
839 % MagickBooleanType IsImageGray(const Image *image)
840 %
841 % A description of each parameter follows:
842 %
843 % o image: the image.
844 %
845 */
847 {
848  assert(image != (Image *) NULL);
849  assert(image->signature == MagickCoreSignature);
850  if ((image->type == BilevelType) || (image->type == GrayscaleType) ||
851  (image->type == GrayscaleAlphaType))
852  return(MagickTrue);
853  return(MagickFalse);
854 }
855 
856 /*
857 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
858 % %
859 % %
860 % %
861 % I s I m a g e M o n o c h r o m e %
862 % %
863 % %
864 % %
865 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
866 %
867 % IsImageMonochrome() returns MagickTrue if type of the image is bi-level.
868 %
869 % The format of the IsImageMonochrome method is:
870 %
871 % MagickBooleanType IsImageMonochrome(const Image *image)
872 %
873 % A description of each parameter follows:
874 %
875 % o image: the image.
876 %
877 */
879 {
880  assert(image != (Image *) NULL);
881  assert(image->signature == MagickCoreSignature);
882  if (image->type == BilevelType)
883  return(MagickTrue);
884  return(MagickFalse);
885 }
886 
887 /*
888 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
889 % %
890 % %
891 % %
892 % I s I m a g e O p a q u e %
893 % %
894 % %
895 % %
896 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
897 %
898 % IsImageOpaque() returns MagickTrue if none of the pixels in the image have
899 % an alpha value other than OpaqueAlpha (QuantumRange).
900 %
901 % Will return true immediatally is alpha channel is not available.
902 %
903 % The format of the IsImageOpaque method is:
904 %
905 % MagickBooleanType IsImageOpaque(const Image *image,
906 % ExceptionInfo *exception)
907 %
908 % A description of each parameter follows:
909 %
910 % o image: the image.
911 %
912 % o exception: return any errors or warnings in this structure.
913 %
914 */
916  ExceptionInfo *exception)
917 {
918  CacheView
919  *image_view;
920 
921  register const Quantum
922  *p;
923 
924  register ssize_t
925  x;
926 
927  ssize_t
928  y;
929 
930  /*
931  Determine if image is opaque.
932  */
933  assert(image != (Image *) NULL);
934  assert(image->signature == MagickCoreSignature);
935  if (image->debug != MagickFalse)
936  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
937  if (image->alpha_trait == UndefinedPixelTrait)
938  return(MagickTrue);
939  image_view=AcquireVirtualCacheView(image,exception);
940  for (y=0; y < (ssize_t) image->rows; y++)
941  {
942  p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
943  if (p == (const Quantum *) NULL)
944  break;
945  for (x=0; x < (ssize_t) image->columns; x++)
946  {
947  if (GetPixelAlpha(image,p) != OpaqueAlpha)
948  break;
949  p+=GetPixelChannels(image);
950  }
951  if (x < (ssize_t) image->columns)
952  break;
953  }
954  image_view=DestroyCacheView(image_view);
955  return(y < (ssize_t) image->rows ? MagickFalse : MagickTrue);
956 }
957 
958 /*
959 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
960 % %
961 % %
962 % %
963 % S e t I m a g e D e p t h %
964 % %
965 % %
966 % %
967 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
968 %
969 % SetImageDepth() sets the depth of the image.
970 %
971 % The format of the SetImageDepth method is:
972 %
973 % MagickBooleanType SetImageDepth(Image *image,const size_t depth,
974 % ExceptionInfo *exception)
975 %
976 % A description of each parameter follows:
977 %
978 % o image: the image.
979 %
980 % o channel: the channel.
981 %
982 % o depth: the image depth.
983 %
984 % o exception: return any errors or warnings in this structure.
985 %
986 */
988  const size_t depth,ExceptionInfo *exception)
989 {
990  CacheView
991  *image_view;
992 
994  status;
995 
996  QuantumAny
997  range;
998 
999  ssize_t
1000  y;
1001 
1002  assert(image != (Image *) NULL);
1003  if (image->debug != MagickFalse)
1004  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1005  assert(image->signature == MagickCoreSignature);
1006  if (depth >= MAGICKCORE_QUANTUM_DEPTH)
1007  {
1008  image->depth=depth;
1009  return(MagickTrue);
1010  }
1011  range=GetQuantumRange(depth);
1012  if (image->storage_class == PseudoClass)
1013  {
1014  register ssize_t
1015  i;
1016 
1017 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1018  #pragma omp parallel for schedule(static) shared(status) \
1019  magick_number_threads(image,image,image->colors,1)
1020 #endif
1021  for (i=0; i < (ssize_t) image->colors; i++)
1022  {
1023  if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
1024  image->colormap[i].red=(double) ScaleAnyToQuantum(ScaleQuantumToAny(
1025  ClampPixel(image->colormap[i].red),range),range);
1026  if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
1028  ClampPixel(image->colormap[i].green),range),range);
1029  if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
1030  image->colormap[i].blue=(double) ScaleAnyToQuantum(ScaleQuantumToAny(
1031  ClampPixel(image->colormap[i].blue),range),range);
1032  if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
1034  ClampPixel(image->colormap[i].alpha),range),range);
1035  }
1036  }
1037  status=MagickTrue;
1038  image_view=AcquireAuthenticCacheView(image,exception);
1039 #if !defined(MAGICKCORE_HDRI_SUPPORT)
1040  if ((1UL*QuantumRange) <= MaxMap)
1041  {
1042  Quantum
1043  *depth_map;
1044 
1045  register ssize_t
1046  i;
1047 
1048  /*
1049  Scale pixels to desired (optimized with depth map).
1050  */
1051  depth_map=(Quantum *) AcquireQuantumMemory(MaxMap+1,sizeof(*depth_map));
1052  if (depth_map == (Quantum *) NULL)
1053  ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
1054  for (i=0; i <= (ssize_t) MaxMap; i++)
1055  depth_map[i]=ScaleAnyToQuantum(ScaleQuantumToAny((Quantum) i,range),
1056  range);
1057 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1058  #pragma omp parallel for schedule(static) shared(status) \
1059  magick_number_threads(image,image,image->rows,1)
1060 #endif
1061  for (y=0; y < (ssize_t) image->rows; y++)
1062  {
1063  register ssize_t
1064  x;
1065 
1066  register Quantum
1067  *magick_restrict q;
1068 
1069  if (status == MagickFalse)
1070  continue;
1071  q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
1072  exception);
1073  if (q == (Quantum *) NULL)
1074  {
1075  status=MagickFalse;
1076  continue;
1077  }
1078  for (x=0; x < (ssize_t) image->columns; x++)
1079  {
1080  register ssize_t
1081  i;
1082 
1083  for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
1084  {
1085  PixelChannel
1086  channel;
1087 
1088  PixelTrait
1089  traits;
1090 
1091  channel=GetPixelChannelChannel(image,i);
1092  traits=GetPixelChannelTraits(image,channel);
1093  if ((traits & UpdatePixelTrait) == 0)
1094  continue;
1095  q[i]=depth_map[ScaleQuantumToMap(q[i])];
1096  }
1097  q+=GetPixelChannels(image);
1098  }
1099  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
1100  {
1101  status=MagickFalse;
1102  continue;
1103  }
1104  }
1105  image_view=DestroyCacheView(image_view);
1106  depth_map=(Quantum *) RelinquishMagickMemory(depth_map);
1107  if (status != MagickFalse)
1108  image->depth=depth;
1109  return(status);
1110  }
1111 #endif
1112  /*
1113  Scale pixels to desired depth.
1114  */
1115 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1116  #pragma omp parallel for schedule(static) shared(status) \
1117  magick_number_threads(image,image,image->rows,1)
1118 #endif
1119  for (y=0; y < (ssize_t) image->rows; y++)
1120  {
1121  register ssize_t
1122  x;
1123 
1124  register Quantum
1125  *magick_restrict q;
1126 
1127  if (status == MagickFalse)
1128  continue;
1129  q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
1130  if (q == (Quantum *) NULL)
1131  {
1132  status=MagickFalse;
1133  continue;
1134  }
1135  for (x=0; x < (ssize_t) image->columns; x++)
1136  {
1137  register ssize_t
1138  i;
1139 
1140  for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
1141  {
1142  PixelChannel
1143  channel;
1144 
1145  PixelTrait
1146  traits;
1147 
1148  channel=GetPixelChannelChannel(image,i);
1149  traits=GetPixelChannelTraits(image,channel);
1150  if ((traits & UpdatePixelTrait) == 0)
1151  continue;
1153  q[i]),range),range);
1154  }
1155  q+=GetPixelChannels(image);
1156  }
1157  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
1158  {
1159  status=MagickFalse;
1160  continue;
1161  }
1162  }
1163  image_view=DestroyCacheView(image_view);
1164  if (status != MagickFalse)
1165  image->depth=depth;
1166  return(status);
1167 }
1168 
1169 /*
1170 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1171 % %
1172 % %
1173 % %
1174 % S e t I m a g e T y p e %
1175 % %
1176 % %
1177 % %
1178 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1179 %
1180 % SetImageType() sets the type of image. Choose from these types:
1181 %
1182 % Bilevel Grayscale GrayscaleMatte
1183 % Palette PaletteMatte TrueColor
1184 % TrueColorMatte ColorSeparation ColorSeparationMatte
1185 % OptimizeType
1186 %
1187 % The format of the SetImageType method is:
1188 %
1189 % MagickBooleanType SetImageType(Image *image,const ImageType type,
1190 % ExceptionInfo *exception)
1191 %
1192 % A description of each parameter follows:
1193 %
1194 % o image: the image.
1195 %
1196 % o type: Image type.
1197 %
1198 % o exception: return any errors or warnings in this structure.
1199 %
1200 */
1202  ExceptionInfo *exception)
1203 {
1204  const char
1205  *artifact;
1206 
1207  ImageInfo
1208  *image_info;
1209 
1211  status;
1212 
1213  QuantizeInfo
1214  *quantize_info;
1215 
1216  assert(image != (Image *) NULL);
1217  if (image->debug != MagickFalse)
1218  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1219  assert(image->signature == MagickCoreSignature);
1220  status=MagickTrue;
1221  image_info=AcquireImageInfo();
1222  image_info->dither=image->dither;
1223  artifact=GetImageArtifact(image,"dither");
1224  if (artifact != (const char *) NULL)
1225  (void) SetImageOption(image_info,"dither",artifact);
1226  switch (type)
1227  {
1228  case BilevelType:
1229  {
1230  status=TransformImageColorspace(image,GRAYColorspace,exception);
1231  (void) NormalizeImage(image,exception);
1232  quantize_info=AcquireQuantizeInfo(image_info);
1233  quantize_info->number_colors=2;
1234  quantize_info->colorspace=GRAYColorspace;
1235  status=QuantizeImage(quantize_info,image,exception);
1236  quantize_info=DestroyQuantizeInfo(quantize_info);
1238  break;
1239  }
1240  case GrayscaleType:
1241  {
1242  status=TransformImageColorspace(image,GRAYColorspace,exception);
1244  break;
1245  }
1246  case GrayscaleAlphaType:
1247  {
1248  status=TransformImageColorspace(image,GRAYColorspace,exception);
1249  if (image->alpha_trait == UndefinedPixelTrait)
1250  (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception);
1251  break;
1252  }
1253  case PaletteType:
1254  {
1255  status=TransformImageColorspace(image,sRGBColorspace,exception);
1256  if ((image->storage_class == DirectClass) || (image->colors > 256))
1257  {
1258  quantize_info=AcquireQuantizeInfo(image_info);
1259  quantize_info->number_colors=256;
1260  status=QuantizeImage(quantize_info,image,exception);
1261  quantize_info=DestroyQuantizeInfo(quantize_info);
1262  }
1264  break;
1265  }
1267  {
1268  ChannelType
1269  channel_mask;
1270 
1271  status=TransformImageColorspace(image,sRGBColorspace,exception);
1272  if (image->alpha_trait == UndefinedPixelTrait)
1273  (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception);
1274  channel_mask=SetImageChannelMask(image,AlphaChannel);
1275  (void) BilevelImage(image,(double) QuantumRange/2.0,exception);
1276  (void) SetImageChannelMask(image,channel_mask);
1277  quantize_info=AcquireQuantizeInfo(image_info);
1278  status=QuantizeImage(quantize_info,image,exception);
1279  quantize_info=DestroyQuantizeInfo(quantize_info);
1280  break;
1281  }
1282  case PaletteAlphaType:
1283  {
1284  status=TransformImageColorspace(image,sRGBColorspace,exception);
1285  if (image->alpha_trait == UndefinedPixelTrait)
1286  (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception);
1287  quantize_info=AcquireQuantizeInfo(image_info);
1288  quantize_info->colorspace=TransparentColorspace;
1289  status=QuantizeImage(quantize_info,image,exception);
1290  quantize_info=DestroyQuantizeInfo(quantize_info);
1291  break;
1292  }
1293  case TrueColorType:
1294  {
1295  status=TransformImageColorspace(image,sRGBColorspace,exception);
1296  if (image->storage_class != DirectClass)
1297  status=SetImageStorageClass(image,DirectClass,exception);
1299  break;
1300  }
1301  case TrueColorAlphaType:
1302  {
1303  status=TransformImageColorspace(image,sRGBColorspace,exception);
1304  if (image->storage_class != DirectClass)
1305  status=SetImageStorageClass(image,DirectClass,exception);
1306  if (image->alpha_trait == UndefinedPixelTrait)
1307  (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception);
1308  break;
1309  }
1310  case ColorSeparationType:
1311  {
1312  status=TransformImageColorspace(image,CMYKColorspace,exception);
1313  if (image->storage_class != DirectClass)
1314  status=SetImageStorageClass(image,DirectClass,exception);
1316  break;
1317  }
1319  {
1320  status=TransformImageColorspace(image,CMYKColorspace,exception);
1321  if (image->storage_class != DirectClass)
1322  status=SetImageStorageClass(image,DirectClass,exception);
1323  if (image->alpha_trait == UndefinedPixelTrait)
1324  status=SetImageAlphaChannel(image,OpaqueAlphaChannel,exception);
1325  break;
1326  }
1327  case OptimizeType:
1328  case UndefinedType:
1329  break;
1330  }
1331  image_info=DestroyImageInfo(image_info);
1332  if (status == MagickFalse)
1333  return(status);
1334  image->type=type;
1335  return(MagickTrue);
1336 }
size_t rows
Definition: image.h:172
#define magick_restrict
Definition: MagickCore.h:41
MagickDoubleType MagickRealType
Definition: magick-type.h:118
MagickExport CacheView * DestroyCacheView(CacheView *cache_view)
Definition: cache-view.c:252
PixelInfo * colormap
Definition: image.h:179
static MagickSizeType GetQuantumRange(const size_t depth)
MagickExport ImageInfo * AcquireImageInfo(void)
Definition: image.c:343
ImageType type
Definition: image.h:264
static Quantum GetPixelAlpha(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
static PixelTrait GetPixelRedTraits(const Image *magick_restrict image)
MagickExport MagickBooleanType TransformImageColorspace(Image *image, const ColorspaceType colorspace, ExceptionInfo *exception)
Definition: colorspace.c:1325
static PixelTrait GetPixelAlphaTraits(const Image *magick_restrict image)
ColorspaceType colorspace
Definition: quantize.h:44
MagickExport MagickBooleanType SetImageDepth(Image *image, const size_t depth, ExceptionInfo *exception)
Definition: attribute.c:987
#define ThrowFatalException(severity, tag)
MagickExport ImageType IdentifyImageGray(const Image *image, ExceptionInfo *exception)
Definition: attribute.c:628
#define OpaqueAlpha
Definition: image.h:25
MagickExport QuantizeInfo * DestroyQuantizeInfo(QuantizeInfo *quantize_info)
Definition: quantize.c:1387
MagickExport const char * GetImageArtifact(const Image *image, const char *artifact)
Definition: artifact.c:273
MagickRealType red
Definition: pixel.h:191
static PixelTrait GetPixelChannelTraits(const Image *magick_restrict image, const PixelChannel channel)
static MagickBooleanType IsPixelMonochrome(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
#define MAGICKCORE_QUANTUM_DEPTH
Definition: magick-type.h:28
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:191
MagickExport MagickBooleanType IdentifyImageMonochrome(const Image *image, ExceptionInfo *exception)
Definition: attribute.c:710
ClassType storage_class
Definition: image.h:154
size_t width
Definition: geometry.h:130
Definition: log.h:52
MagickExport void GetPixelInfo(const Image *image, PixelInfo *pixel)
Definition: pixel.c:2170
MagickExport MagickBooleanType SetImageOption(ImageInfo *image_info, const char *option, const char *value)
Definition: option.c:3230
Definition: image.h:151
#define MagickCoreSignature
MagickExport MagickBooleanType SetImageType(Image *image, const ImageType type, ExceptionInfo *exception)
Definition: attribute.c:1201
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
static Quantum ClampPixel(const MagickRealType pixel)
MagickExport MagickBooleanType SetImageAlphaChannel(Image *image, const AlphaChannelOption alpha_type, ExceptionInfo *exception)
Definition: channel.c:966
MagickBooleanType
Definition: magick-type.h:156
static Quantum ScaleAnyToQuantum(const QuantumAny quantum, const QuantumAny range)
static MagickBooleanType IssRGBCompatibleColorspace(const ColorspaceType colorspace)
MagickExport MagickBooleanType NormalizeImage(Image *image, ExceptionInfo *exception)
Definition: enhance.c:3544
MagickExport void * AcquireQuantumMemory(const size_t count, const size_t quantum)
Definition: memory.c:533
MagickExport ImageType GetImageType(const Image *image)
Definition: attribute.c:573
static int GetOpenMPThreadId(void)
static MagickBooleanType IsPixelAtDepth(const Quantum pixel, const QuantumAny range)
size_t number_colors
Definition: quantize.h:38
static void GetPixelInfoPixel(const Image *magick_restrict image, const Quantum *magick_restrict pixel, PixelInfo *magick_restrict pixel_info)
PixelTrait alpha_trait
Definition: image.h:280
MagickRealType blue
Definition: pixel.h:191
MagickExport MagickBooleanType IdentifyPaletteImage(const Image *image, ExceptionInfo *exception)
Definition: histogram.c:769
MagickExport ChannelType SetImageChannelMask(Image *image, const ChannelType channel_mask)
Definition: image.c:2497
MagickBooleanType dither
Definition: image.h:267
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:1064
MagickExport MagickBooleanType LogMagickEvent(const LogEventType type, const char *module, const char *function, const size_t line, const char *format,...)
Definition: log.c:1398
MagickExport MagickBooleanType QuantizeImage(const QuantizeInfo *quantize_info, Image *image, ExceptionInfo *exception)
Definition: quantize.c:2651
size_t signature
Definition: image.h:354
MagickExport MagickSizeType GetMagickResourceLimit(const ResourceType type)
Definition: resource.c:745
size_t columns
Definition: image.h:172
MagickExport size_t GetImageQuantumDepth(const Image *image, const MagickBooleanType constrain)
Definition: attribute.c:524
ssize_t x
Definition: geometry.h:134
static MagickBooleanType IsPixelGray(const Image *magick_restrict image, const Quantum *magick_restrict pixel)
size_t height
Definition: geometry.h:130
MagickExport ImageType IdentifyImageType(const Image *image, ExceptionInfo *exception)
Definition: attribute.c:791
static PixelTrait GetPixelGreenTraits(const Image *magick_restrict image)
ChannelType
Definition: pixel.h:33
MagickExport MagickBooleanType SetImageStorageClass(Image *image, const ClassType storage_class, ExceptionInfo *exception)
Definition: image.c:2613
PixelChannel
Definition: pixel.h:67
#define MaxMap
Definition: magick-type.h:75
size_t colors
Definition: image.h:172
static size_t GetPixelChannels(const Image *magick_restrict image)
MagickExport MagickBooleanType IsPaletteImage(const Image *image)
Definition: histogram.c:840
MagickExport QuantizeInfo * AcquireQuantizeInfo(const ImageInfo *image_info)
Definition: quantize.c:375
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 ImageInfo * DestroyImageInfo(ImageInfo *image_info)
Definition: image.c:1248
MagickExport MagickBooleanType IsImageGray(const Image *image)
Definition: attribute.c:846
MagickExport size_t GetImageDepth(const Image *image, ExceptionInfo *exception)
Definition: attribute.c:274
unsigned short Quantum
Definition: magick-type.h:82
MagickExport MagickBooleanType IsImageMonochrome(const Image *image)
Definition: attribute.c:878
MagickExport RectangleInfo GetImageBoundingBox(const Image *image, ExceptionInfo *exception)
Definition: attribute.c:125
MagickExport MagickBooleanType IsFuzzyEquivalencePixelInfo(const PixelInfo *p, const PixelInfo *q)
Definition: pixel.c:6060
MagickBooleanType dither
Definition: image.h:432
#define MagickMin(x, y)
Definition: image-private.h:27
MagickExport MagickBooleanType BilevelImage(Image *image, const double threshold, ExceptionInfo *exception)
Definition: threshold.c:801
MagickExport void * RelinquishMagickMemory(void *memory)
Definition: memory.c:1053
MagickRealType green
Definition: pixel.h:191
ImageType
Definition: image.h:48
#define MagickExport
MagickExport MagickBooleanType SyncCacheViewAuthenticPixels(CacheView *magick_restrict cache_view, ExceptionInfo *exception)
Definition: cache-view.c:1100
ssize_t y
Definition: geometry.h:134
MagickExport CacheView * AcquireAuthenticCacheView(const Image *image, ExceptionInfo *exception)
Definition: cache-view.c:112
PixelTrait
Definition: pixel.h:135
static QuantumAny ScaleQuantumToAny(const Quantum quantum, const QuantumAny range)
MagickSizeType QuantumAny
Definition: magick-type.h:142
ColorspaceType colorspace
Definition: image.h:157
MagickExport MagickBooleanType IsImageOpaque(const Image *image, ExceptionInfo *exception)
Definition: attribute.c:915
#define QuantumRange
Definition: magick-type.h:83
MagickBooleanType debug
Definition: image.h:334
static PixelTrait GetPixelBlueTraits(const Image *magick_restrict image)
size_t depth
Definition: image.h:172