2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % QQQ U U AAA N N TTTTT U U M M %
7 % Q Q U U A A NN N T U U MM MM %
8 % Q Q U U AAAAA N N N T U U M M M %
9 % Q QQ U U A A N NN T U U M M %
10 % QQQQ UUU A A N N T UUU M M %
12 % MagicCore Methods to Acquire / Destroy Quantum Pixels %
19 % Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization %
20 % dedicated to making software imaging solutions freely available. %
22 % You may not use this file except in compliance with the License. You may %
23 % obtain a copy of the License at %
25 % http://www.imagemagick.org/script/license.php %
27 % Unless required by applicable law or agreed to in writing, software %
28 % distributed under the License is distributed on an "AS IS" BASIS, %
29 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
30 % See the License for the specific language governing permissions and %
31 % limitations under the License. %
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41 #include "MagickCore/studio.h"
42 #include "MagickCore/attribute.h"
43 #include "MagickCore/blob.h"
44 #include "MagickCore/blob-private.h"
45 #include "MagickCore/color-private.h"
46 #include "MagickCore/exception.h"
47 #include "MagickCore/exception-private.h"
48 #include "MagickCore/cache.h"
49 #include "MagickCore/constitute.h"
50 #include "MagickCore/delegate.h"
51 #include "MagickCore/geometry.h"
52 #include "MagickCore/list.h"
53 #include "MagickCore/magick.h"
54 #include "MagickCore/memory_.h"
55 #include "MagickCore/monitor.h"
56 #include "MagickCore/option.h"
57 #include "MagickCore/pixel.h"
58 #include "MagickCore/pixel-accessor.h"
59 #include "MagickCore/property.h"
60 #include "MagickCore/quantum.h"
61 #include "MagickCore/quantum-private.h"
62 #include "MagickCore/resource_.h"
63 #include "MagickCore/semaphore.h"
64 #include "MagickCore/statistic.h"
65 #include "MagickCore/stream.h"
66 #include "MagickCore/string_.h"
67 #include "MagickCore/string-private.h"
68 #include "MagickCore/thread-private.h"
69 #include "MagickCore/utility.h"
74 #define QuantumSignature 0xab
80 DestroyQuantumPixels(QuantumInfo *);
83 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
87 % A c q u i r e Q u a n t u m I n f o %
91 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
93 % AcquireQuantumInfo() allocates the QuantumInfo structure.
95 % The format of the AcquireQuantumInfo method is:
97 % QuantumInfo *AcquireQuantumInfo(const ImageInfo *image_info,Image *image)
99 % A description of each parameter follows:
101 % o image_info: the image info.
103 % o image: the image.
107 static inline size_t MagickMax(const size_t x,const size_t y)
114 MagickExport QuantumInfo *AcquireQuantumInfo(const ImageInfo *image_info,
123 quantum_info=(QuantumInfo *) AcquireMagickMemory(sizeof(*quantum_info));
124 if (quantum_info == (QuantumInfo *) NULL)
125 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
126 quantum_info->signature=MagickSignature;
127 GetQuantumInfo(image_info,quantum_info);
128 if (image == (const Image *) NULL)
129 return(quantum_info);
130 status=SetQuantumDepth(image,quantum_info,image->depth);
131 if (status == MagickFalse)
132 quantum_info=DestroyQuantumInfo(quantum_info);
133 quantum_info->endian=image->endian;
134 return(quantum_info);
138 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
142 + A c q u i r e Q u a n t u m P i x e l s %
146 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
148 % AcquireQuantumPixels() allocates the unsigned char structure.
150 % The format of the AcquireQuantumPixels method is:
152 % MagickBooleanType AcquireQuantumPixels(QuantumInfo *quantum_info,
153 % const size_t extent)
155 % A description of each parameter follows:
157 % o quantum_info: the quantum info.
159 % o extent: the quantum info.
162 static MagickBooleanType AcquireQuantumPixels(QuantumInfo *quantum_info,
168 assert(quantum_info != (QuantumInfo *) NULL);
169 assert(quantum_info->signature == MagickSignature);
170 quantum_info->number_threads=(size_t) GetMagickResourceLimit(ThreadResource);
171 quantum_info->pixels=(unsigned char **) AcquireQuantumMemory(
172 quantum_info->number_threads,sizeof(*quantum_info->pixels));
173 if (quantum_info->pixels == (unsigned char **) NULL)
175 quantum_info->extent=extent;
176 (void) ResetMagickMemory(quantum_info->pixels,0,quantum_info->number_threads*
177 sizeof(*quantum_info->pixels));
178 for (i=0; i < (ssize_t) quantum_info->number_threads; i++)
180 quantum_info->pixels[i]=(unsigned char *) AcquireQuantumMemory(extent+1,
181 sizeof(**quantum_info->pixels));
182 if (quantum_info->pixels[i] == (unsigned char *) NULL)
184 (void) ResetMagickMemory(quantum_info->pixels[i],0,(extent+1)*
185 sizeof(**quantum_info->pixels));
186 quantum_info->pixels[i][extent]=QuantumSignature;
192 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
196 % D e s t r o y Q u a n t u m I n f o %
200 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
202 % DestroyQuantumInfo() deallocates memory associated with the QuantumInfo
205 % The format of the DestroyQuantumInfo method is:
207 % QuantumInfo *DestroyQuantumInfo(QuantumInfo *quantum_info)
209 % A description of each parameter follows:
211 % o quantum_info: the quantum info.
214 MagickExport QuantumInfo *DestroyQuantumInfo(QuantumInfo *quantum_info)
216 assert(quantum_info != (QuantumInfo *) NULL);
217 assert(quantum_info->signature == MagickSignature);
218 if (quantum_info->pixels != (unsigned char **) NULL)
219 DestroyQuantumPixels(quantum_info);
220 if (quantum_info->semaphore != (SemaphoreInfo *) NULL)
221 DestroySemaphoreInfo(&quantum_info->semaphore);
222 quantum_info->signature=(~MagickSignature);
223 quantum_info=(QuantumInfo *) RelinquishMagickMemory(quantum_info);
224 return(quantum_info);
228 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
232 + D e s t r o y Q u a n t u m P i x e l s %
236 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
238 % DestroyQuantumPixels() destroys the quantum pixels.
240 % The format of the DestroyQuantumPixels() method is:
242 % void DestroyQuantumPixels(QuantumInfo *quantum_info)
244 % A description of each parameter follows:
246 % o quantum_info: the quantum info.
249 static void DestroyQuantumPixels(QuantumInfo *quantum_info)
257 assert(quantum_info != (QuantumInfo *) NULL);
258 assert(quantum_info->signature == MagickSignature);
259 assert(quantum_info->pixels != (unsigned char **) NULL);
260 extent=(ssize_t) quantum_info->extent;
261 for (i=0; i < (ssize_t) quantum_info->number_threads; i++)
262 if (quantum_info->pixels[i] != (unsigned char *) NULL)
265 Did we overrun our quantum buffer?
267 assert(quantum_info->pixels[i][extent] == QuantumSignature);
268 quantum_info->pixels[i]=(unsigned char *) RelinquishMagickMemory(
269 quantum_info->pixels[i]);
271 quantum_info->pixels=(unsigned char **) RelinquishMagickMemory(
272 quantum_info->pixels);
276 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
280 % G e t Q u a n t u m E x t e n t %
284 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
286 % GetQuantumExtent() returns the quantum pixel buffer extent.
288 % The format of the GetQuantumExtent method is:
290 % size_t GetQuantumExtent(Image *image,const QuantumInfo *quantum_info,
291 % const QuantumType quantum_type)
293 % A description of each parameter follows:
295 % o image: the image.
297 % o quantum_info: the quantum info.
299 % o quantum_type: Declare which pixel components to transfer (red, green,
300 % blue, opacity, RGB, or RGBA).
303 MagickExport size_t GetQuantumExtent(const Image *image,
304 const QuantumInfo *quantum_info,const QuantumType quantum_type)
309 assert(quantum_info != (QuantumInfo *) NULL);
310 assert(quantum_info->signature == MagickSignature);
312 switch (quantum_type)
314 case GrayAlphaQuantum: packet_size=2; break;
315 case IndexAlphaQuantum: packet_size=2; break;
316 case RGBQuantum: packet_size=3; break;
317 case BGRQuantum: packet_size=3; break;
318 case RGBAQuantum: packet_size=4; break;
319 case RGBOQuantum: packet_size=4; break;
320 case BGRAQuantum: packet_size=4; break;
321 case CMYKQuantum: packet_size=4; break;
322 case CMYKAQuantum: packet_size=5; break;
325 if (quantum_info->pack == MagickFalse)
326 return((size_t) (packet_size*image->columns*((quantum_info->depth+7)/8)));
327 return((size_t) ((packet_size*image->columns*quantum_info->depth+7)/8));
331 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
335 % G e t Q u a n t u m E n d i a n %
339 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
341 % GetQuantumEndian() returns the quantum endian of the image.
343 % The endian of the GetQuantumEndian method is:
345 % EndianType GetQuantumEndian(const QuantumInfo *quantum_info)
347 % A description of each parameter follows:
349 % o quantum_info: the quantum info.
352 MagickExport EndianType GetQuantumEndian(const QuantumInfo *quantum_info)
354 assert(quantum_info != (QuantumInfo *) NULL);
355 assert(quantum_info->signature == MagickSignature);
356 return(quantum_info->endian);
360 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
364 % G e t Q u a n t u m F o r m a t %
368 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
370 % GetQuantumFormat() returns the quantum format of the image.
372 % The format of the GetQuantumFormat method is:
374 % QuantumFormatType GetQuantumFormat(const QuantumInfo *quantum_info)
376 % A description of each parameter follows:
378 % o quantum_info: the quantum info.
381 MagickExport QuantumFormatType GetQuantumFormat(const QuantumInfo *quantum_info)
383 assert(quantum_info != (QuantumInfo *) NULL);
384 assert(quantum_info->signature == MagickSignature);
385 return(quantum_info->format);
389 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
393 % G e t Q u a n t u m I n f o %
397 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
399 % GetQuantumInfo() initializes the QuantumInfo structure to default values.
401 % The format of the GetQuantumInfo method is:
403 % GetQuantumInfo(const ImageInfo *image_info,QuantumInfo *quantum_info)
405 % A description of each parameter follows:
407 % o image_info: the image info.
409 % o quantum_info: the quantum info.
412 MagickExport void GetQuantumInfo(const ImageInfo *image_info,
413 QuantumInfo *quantum_info)
418 assert(quantum_info != (QuantumInfo *) NULL);
419 (void) ResetMagickMemory(quantum_info,0,sizeof(*quantum_info));
420 quantum_info->quantum=8;
421 quantum_info->maximum=1.0;
422 quantum_info->scale=QuantumRange;
423 quantum_info->pack=MagickTrue;
424 quantum_info->semaphore=AllocateSemaphoreInfo();
425 quantum_info->signature=MagickSignature;
426 if (image_info == (const ImageInfo *) NULL)
428 option=GetImageOption(image_info,"quantum:format");
429 if (option != (char *) NULL)
430 quantum_info->format=(QuantumFormatType) ParseCommandOption(
431 MagickQuantumFormatOptions,MagickFalse,option);
432 option=GetImageOption(image_info,"quantum:minimum");
433 if (option != (char *) NULL)
434 quantum_info->minimum=StringToDouble(option,(char **) NULL);
435 option=GetImageOption(image_info,"quantum:maximum");
436 if (option != (char *) NULL)
437 quantum_info->maximum=StringToDouble(option,(char **) NULL);
438 if ((quantum_info->minimum == 0.0) && (quantum_info->maximum == 0.0))
439 quantum_info->scale=0.0;
441 if (quantum_info->minimum == quantum_info->maximum)
443 quantum_info->scale=(double) QuantumRange/quantum_info->minimum;
444 quantum_info->minimum=0.0;
447 quantum_info->scale=(double) QuantumRange/(quantum_info->maximum-
448 quantum_info->minimum);
449 option=GetImageOption(image_info,"quantum:scale");
450 if (option != (char *) NULL)
451 quantum_info->scale=StringToDouble(option,(char **) NULL);
452 option=GetImageOption(image_info,"quantum:polarity");
453 if (option != (char *) NULL)
454 quantum_info->min_is_white=LocaleCompare(option,"min-is-white") == 0 ?
455 MagickTrue : MagickFalse;
456 quantum_info->endian=image_info->endian;
457 ResetQuantumState(quantum_info);
461 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
465 % G e t Q u a n t u m P i x e l s %
469 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
471 % GetQuantumPixels() returns the quantum pixels.
473 % The format of the GetQuantumPixels method is:
475 % unsigned char *QuantumPixels GetQuantumPixels(
476 % const QuantumInfo *quantum_info)
478 % A description of each parameter follows:
480 % o image: the image.
483 MagickExport unsigned char *GetQuantumPixels(const QuantumInfo *quantum_info)
486 id = GetOpenMPThreadId();
488 assert(quantum_info != (QuantumInfo *) NULL);
489 assert(quantum_info->signature == MagickSignature);
490 return(quantum_info->pixels[id]);
494 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
498 % G e t Q u a n t u m T y p e %
502 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
504 % GetQuantumType() returns the quantum type of the image.
506 % The format of the GetQuantumType method is:
508 % QuantumType GetQuantumType(Image *image,ExceptionInfo *exception)
510 % A description of each parameter follows:
512 % o image: the image.
515 MagickExport QuantumType GetQuantumType(Image *image,ExceptionInfo *exception)
520 assert(image != (Image *) NULL);
521 assert(image->signature == MagickSignature);
522 if (image->debug != MagickFalse)
523 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
524 quantum_type=RGBQuantum;
525 if (image->alpha_trait == BlendPixelTrait)
526 quantum_type=RGBAQuantum;
527 if (image->colorspace == CMYKColorspace)
529 quantum_type=CMYKQuantum;
530 if (image->alpha_trait == BlendPixelTrait)
531 quantum_type=CMYKAQuantum;
533 if (IsImageGray(image,exception) != MagickFalse)
535 quantum_type=GrayQuantum;
536 if (image->alpha_trait == BlendPixelTrait)
537 quantum_type=GrayAlphaQuantum;
539 if (image->storage_class == PseudoClass)
541 quantum_type=IndexQuantum;
542 if (image->alpha_trait == BlendPixelTrait)
543 quantum_type=IndexAlphaQuantum;
545 return(quantum_type);
549 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
553 + R e s e t Q u a n t u m S t a t e %
557 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
559 % ResetQuantumState() resets the quantum state.
561 % The format of the ResetQuantumState method is:
563 % void ResetQuantumState(QuantumInfo *quantum_info)
565 % A description of each parameter follows:
567 % o quantum_info: the quantum info.
570 MagickPrivate void ResetQuantumState(QuantumInfo *quantum_info)
572 static const unsigned int mask[32] =
574 0x00000000U, 0x00000001U, 0x00000003U, 0x00000007U, 0x0000000fU,
575 0x0000001fU, 0x0000003fU, 0x0000007fU, 0x000000ffU, 0x000001ffU,
576 0x000003ffU, 0x000007ffU, 0x00000fffU, 0x00001fffU, 0x00003fffU,
577 0x00007fffU, 0x0000ffffU, 0x0001ffffU, 0x0003ffffU, 0x0007ffffU,
578 0x000fffffU, 0x001fffffU, 0x003fffffU, 0x007fffffU, 0x00ffffffU,
579 0x01ffffffU, 0x03ffffffU, 0x07ffffffU, 0x0fffffffU, 0x1fffffffU,
580 0x3fffffffU, 0x7fffffffU
583 assert(quantum_info != (QuantumInfo *) NULL);
584 assert(quantum_info->signature == MagickSignature);
585 quantum_info->state.inverse_scale=1.0;
586 if (fabs(quantum_info->scale) >= MagickEpsilon)
587 quantum_info->state.inverse_scale/=quantum_info->scale;
588 quantum_info->state.pixel=0U;
589 quantum_info->state.bits=0U;
590 quantum_info->state.mask=mask;
594 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
598 % S e t Q u a n t u m F o r m a t %
602 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
604 % SetQuantumAlphaType() sets the quantum format.
606 % The format of the SetQuantumAlphaType method is:
608 % void SetQuantumAlphaType(QuantumInfo *quantum_info,
609 % const QuantumAlphaType type)
611 % A description of each parameter follows:
613 % o quantum_info: the quantum info.
615 % o type: the alpha type (e.g. associate).
618 MagickExport void SetQuantumAlphaType(QuantumInfo *quantum_info,
619 const QuantumAlphaType type)
621 assert(quantum_info != (QuantumInfo *) NULL);
622 assert(quantum_info->signature == MagickSignature);
623 quantum_info->alpha_type=type;
627 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
631 % S e t Q u a n t u m D e p t h %
635 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
637 % SetQuantumDepth() sets the quantum depth.
639 % The format of the SetQuantumDepth method is:
641 % MagickBooleanType SetQuantumDepth(const Image *image,
642 % QuantumInfo *quantum_info,const size_t depth)
644 % A description of each parameter follows:
646 % o image: the image.
648 % o quantum_info: the quantum info.
650 % o depth: the quantum depth.
653 MagickExport MagickBooleanType SetQuantumDepth(const Image *image,
654 QuantumInfo *quantum_info,const size_t depth)
660 Allocate the quantum pixel buffer.
662 assert(image != (Image *) NULL);
663 assert(image->signature == MagickSignature);
664 if (image->debug != MagickFalse)
665 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
666 assert(quantum_info != (QuantumInfo *) NULL);
667 assert(quantum_info->signature == MagickSignature);
668 quantum_info->depth=depth;
669 if (quantum_info->format == FloatingPointQuantumFormat)
671 if (quantum_info->depth > 32)
672 quantum_info->depth=64;
674 if (quantum_info->depth > 16)
675 quantum_info->depth=32;
677 quantum_info->depth=16;
679 if (quantum_info->pixels != (unsigned char **) NULL)
680 DestroyQuantumPixels(quantum_info);
681 status=AcquireQuantumPixels(quantum_info,(6+quantum_info->pad)*image->columns*
682 ((quantum_info->depth+7)/8)); /* allow for CMYKA + RLE byte + pad */
687 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
691 % S e t Q u a n t u m E n d i a n %
695 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
697 % SetQuantumEndian() sets the quantum endian.
699 % The endian of the SetQuantumEndian method is:
701 % MagickBooleanType SetQuantumEndian(const Image *image,
702 % QuantumInfo *quantum_info,const EndianType endian)
704 % A description of each parameter follows:
706 % o image: the image.
708 % o quantum_info: the quantum info.
710 % o endian: the quantum endian.
713 MagickExport MagickBooleanType SetQuantumEndian(const Image *image,
714 QuantumInfo *quantum_info,const EndianType endian)
716 assert(image != (Image *) NULL);
717 assert(image->signature == MagickSignature);
718 if (image->debug != MagickFalse)
719 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
720 assert(quantum_info != (QuantumInfo *) NULL);
721 assert(quantum_info->signature == MagickSignature);
722 quantum_info->endian=endian;
723 return(SetQuantumDepth(image,quantum_info,quantum_info->depth));
727 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
731 % S e t Q u a n t u m F o r m a t %
735 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
737 % SetQuantumFormat() sets the quantum format.
739 % The format of the SetQuantumFormat method is:
741 % MagickBooleanType SetQuantumFormat(const Image *image,
742 % QuantumInfo *quantum_info,const QuantumFormatType format)
744 % A description of each parameter follows:
746 % o image: the image.
748 % o quantum_info: the quantum info.
750 % o format: the quantum format.
753 MagickExport MagickBooleanType SetQuantumFormat(const Image *image,
754 QuantumInfo *quantum_info,const QuantumFormatType format)
756 assert(image != (Image *) NULL);
757 assert(image->signature == MagickSignature);
758 if (image->debug != MagickFalse)
759 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
760 assert(quantum_info != (QuantumInfo *) NULL);
761 assert(quantum_info->signature == MagickSignature);
762 quantum_info->format=format;
763 return(SetQuantumDepth(image,quantum_info,quantum_info->depth));
767 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771 % S e t Q u a n t u m I m a g e T y p e %
775 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
777 % SetQuantumImageType() sets the image type based on the quantum type.
779 % The format of the SetQuantumImageType method is:
781 % void ImageType SetQuantumImageType(Image *image,
782 % const QuantumType quantum_type)
784 % A description of each parameter follows:
786 % o image: the image.
788 % o quantum_type: Declare which pixel components to transfer (red, green,
789 % blue, opacity, RGB, or RGBA).
792 MagickExport void SetQuantumImageType(Image *image,
793 const QuantumType quantum_type)
795 assert(image != (Image *) NULL);
796 assert(image->signature == MagickSignature);
797 if (image->debug != MagickFalse)
798 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
799 switch (quantum_type)
802 case IndexAlphaQuantum:
804 image->type=PaletteType;
808 case GrayAlphaQuantum:
810 image->type=GrayscaleType;
811 if (image->depth == 1)
812 image->type=BilevelType;
822 image->type=ColorSeparationType;
827 image->type=TrueColorType;
834 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
838 % S e t Q u a n t u m P a c k %
842 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
844 % SetQuantumPack() sets the quantum pack flag.
846 % The format of the SetQuantumPack method is:
848 % void SetQuantumPack(QuantumInfo *quantum_info,
849 % const MagickBooleanType pack)
851 % A description of each parameter follows:
853 % o quantum_info: the quantum info.
855 % o pack: the pack flag.
858 MagickExport void SetQuantumPack(QuantumInfo *quantum_info,
859 const MagickBooleanType pack)
861 assert(quantum_info != (QuantumInfo *) NULL);
862 assert(quantum_info->signature == MagickSignature);
863 quantum_info->pack=pack;
868 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
872 % S e t Q u a n t u m P a d %
876 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
878 % SetQuantumPad() sets the quantum pad.
880 % The format of the SetQuantumPad method is:
882 % MagickBooleanType SetQuantumPad(const Image *image,
883 % QuantumInfo *quantum_info,const size_t pad)
885 % A description of each parameter follows:
887 % o image: the image.
889 % o quantum_info: the quantum info.
891 % o pad: the quantum pad.
894 MagickExport MagickBooleanType SetQuantumPad(const Image *image,
895 QuantumInfo *quantum_info,const size_t pad)
897 assert(image != (Image *) NULL);
898 assert(image->signature == MagickSignature);
899 if (image->debug != MagickFalse)
900 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
901 assert(quantum_info != (QuantumInfo *) NULL);
902 assert(quantum_info->signature == MagickSignature);
903 quantum_info->pad=pad;
904 return(SetQuantumDepth(image,quantum_info,quantum_info->depth));
908 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
912 % S e t Q u a n t u m M i n I s W h i t e %
916 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
918 % SetQuantumMinIsWhite() sets the quantum min-is-white flag.
920 % The format of the SetQuantumMinIsWhite method is:
922 % void SetQuantumMinIsWhite(QuantumInfo *quantum_info,
923 % const MagickBooleanType min_is_white)
925 % A description of each parameter follows:
927 % o quantum_info: the quantum info.
929 % o min_is_white: the min-is-white flag.
932 MagickExport void SetQuantumMinIsWhite(QuantumInfo *quantum_info,
933 const MagickBooleanType min_is_white)
935 assert(quantum_info != (QuantumInfo *) NULL);
936 assert(quantum_info->signature == MagickSignature);
937 quantum_info->min_is_white=min_is_white;
941 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
945 % S e t Q u a n t u m Q u a n t u m %
949 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
951 % SetQuantumQuantum() sets the quantum quantum.
953 % The format of the SetQuantumQuantum method is:
955 % void SetQuantumQuantum(QuantumInfo *quantum_info,
956 % const size_t quantum)
958 % A description of each parameter follows:
960 % o quantum_info: the quantum info.
962 % o quantum: the quantum quantum.
965 MagickExport void SetQuantumQuantum(QuantumInfo *quantum_info,
966 const size_t quantum)
968 assert(quantum_info != (QuantumInfo *) NULL);
969 assert(quantum_info->signature == MagickSignature);
970 quantum_info->quantum=quantum;
974 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
978 % S e t Q u a n t u m S c a l e %
982 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
984 % SetQuantumScale() sets the quantum scale.
986 % The format of the SetQuantumScale method is:
988 % void SetQuantumScale(QuantumInfo *quantum_info,const double scale)
990 % A description of each parameter follows:
992 % o quantum_info: the quantum info.
994 % o scale: the quantum scale.
997 MagickExport void SetQuantumScale(QuantumInfo *quantum_info,const double scale)
999 assert(quantum_info != (QuantumInfo *) NULL);
1000 assert(quantum_info->signature == MagickSignature);
1001 quantum_info->scale=scale;