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-2018 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 % https://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/cache-private.h"
50 #include "MagickCore/colorspace.h"
51 #include "MagickCore/colorspace-private.h"
52 #include "MagickCore/constitute.h"
53 #include "MagickCore/delegate.h"
54 #include "MagickCore/geometry.h"
55 #include "MagickCore/list.h"
56 #include "MagickCore/magick.h"
57 #include "MagickCore/memory_.h"
58 #include "MagickCore/memory-private.h"
59 #include "MagickCore/monitor.h"
60 #include "MagickCore/option.h"
61 #include "MagickCore/pixel.h"
62 #include "MagickCore/pixel-accessor.h"
63 #include "MagickCore/property.h"
64 #include "MagickCore/quantum.h"
65 #include "MagickCore/quantum-private.h"
66 #include "MagickCore/resource_.h"
67 #include "MagickCore/semaphore.h"
68 #include "MagickCore/statistic.h"
69 #include "MagickCore/stream.h"
70 #include "MagickCore/string_.h"
71 #include "MagickCore/string-private.h"
72 #include "MagickCore/thread-private.h"
73 #include "MagickCore/utility.h"
78 #define QuantumSignature 0xab
84 DestroyQuantumPixels(QuantumInfo *);
87 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
91 % A c q u i r e Q u a n t u m I n f o %
95 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
97 % AcquireQuantumInfo() allocates the QuantumInfo structure.
99 % The format of the AcquireQuantumInfo method is:
101 % QuantumInfo *AcquireQuantumInfo(const ImageInfo *image_info,Image *image)
103 % A description of each parameter follows:
105 % o image_info: the image info.
107 % o image: the image.
110 MagickExport QuantumInfo *AcquireQuantumInfo(const ImageInfo *image_info,
119 quantum_info=(QuantumInfo *) AcquireCriticalMemory(sizeof(*quantum_info));
120 quantum_info->signature=MagickCoreSignature;
121 GetQuantumInfo(image_info,quantum_info);
122 if (image == (const Image *) NULL)
123 return(quantum_info);
124 status=SetQuantumDepth(image,quantum_info,image->depth);
125 quantum_info->endian=image->endian;
126 if (status == MagickFalse)
127 quantum_info=DestroyQuantumInfo(quantum_info);
128 return(quantum_info);
132 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
136 + A c q u i r e Q u a n t u m P i x e l s %
140 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
142 % AcquireQuantumPixels() allocates the pixel staging areas.
144 % The format of the AcquireQuantumPixels method is:
146 % MagickBooleanType AcquireQuantumPixels(QuantumInfo *quantum_info,
147 % const size_t extent)
149 % A description of each parameter follows:
151 % o quantum_info: the quantum info.
153 % o extent: the quantum info.
156 static MagickBooleanType AcquireQuantumPixels(QuantumInfo *quantum_info,
162 assert(quantum_info != (QuantumInfo *) NULL);
163 assert(quantum_info->signature == MagickCoreSignature);
164 quantum_info->number_threads=(size_t) GetMagickResourceLimit(ThreadResource);
165 quantum_info->pixels=(MemoryInfo **) AcquireQuantumMemory(
166 quantum_info->number_threads,sizeof(*quantum_info->pixels));
167 if (quantum_info->pixels == (MemoryInfo **) NULL)
169 quantum_info->extent=extent;
170 (void) memset(quantum_info->pixels,0,quantum_info->number_threads*
171 sizeof(*quantum_info->pixels));
172 for (i=0; i < (ssize_t) quantum_info->number_threads; i++)
177 quantum_info->pixels[i]=AcquireVirtualMemory((extent+1),sizeof(*pixels));
178 if (quantum_info->pixels[i] == (MemoryInfo *) NULL)
180 DestroyQuantumPixels(quantum_info);
183 pixels=(unsigned char *) GetVirtualMemoryBlob(quantum_info->pixels[i]);
184 (void) memset(pixels,0,(extent+1)*sizeof(*pixels));
185 pixels[extent]=QuantumSignature;
191 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
195 % D e s t r o y Q u a n t u m I n f o %
199 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
201 % DestroyQuantumInfo() deallocates memory associated with the QuantumInfo
204 % The format of the DestroyQuantumInfo method is:
206 % QuantumInfo *DestroyQuantumInfo(QuantumInfo *quantum_info)
208 % A description of each parameter follows:
210 % o quantum_info: the quantum info.
213 MagickExport QuantumInfo *DestroyQuantumInfo(QuantumInfo *quantum_info)
215 assert(quantum_info != (QuantumInfo *) NULL);
216 assert(quantum_info->signature == MagickCoreSignature);
217 if (quantum_info->pixels != (MemoryInfo **) NULL)
218 DestroyQuantumPixels(quantum_info);
219 if (quantum_info->semaphore != (SemaphoreInfo *) NULL)
220 RelinquishSemaphoreInfo(&quantum_info->semaphore);
221 quantum_info->signature=(~MagickCoreSignature);
222 quantum_info=(QuantumInfo *) RelinquishMagickMemory(quantum_info);
223 return(quantum_info);
227 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
231 + D e s t r o y Q u a n t u m P i x e l s %
235 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
237 % DestroyQuantumPixels() destroys the quantum pixels.
239 % The format of the DestroyQuantumPixels() method is:
241 % void DestroyQuantumPixels(QuantumInfo *quantum_info)
243 % A description of each parameter follows:
245 % o quantum_info: the quantum info.
248 static void DestroyQuantumPixels(QuantumInfo *quantum_info)
256 assert(quantum_info != (QuantumInfo *) NULL);
257 assert(quantum_info->signature == MagickCoreSignature);
258 assert(quantum_info->pixels != (MemoryInfo **) NULL);
259 extent=(ssize_t) quantum_info->extent;
260 for (i=0; i < (ssize_t) quantum_info->number_threads; i++)
261 if (quantum_info->pixels[i] != (MemoryInfo *) NULL)
267 Did we overrun our quantum buffer?
269 pixels=(unsigned char *) GetVirtualMemoryBlob(quantum_info->pixels[i]);
270 assert(pixels[extent] == QuantumSignature);
271 quantum_info->pixels[i]=RelinquishVirtualMemory(
272 quantum_info->pixels[i]);
274 quantum_info->pixels=(MemoryInfo **) RelinquishMagickMemory(
275 quantum_info->pixels);
279 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
283 % G e t Q u a n t u m E x t e n t %
287 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
289 % GetQuantumExtent() returns the quantum pixel buffer extent.
291 % The format of the GetQuantumExtent method is:
293 % size_t GetQuantumExtent(Image *image,const QuantumInfo *quantum_info,
294 % const QuantumType quantum_type)
296 % A description of each parameter follows:
298 % o image: the image.
300 % o quantum_info: the quantum info.
302 % o quantum_type: Declare which pixel components to transfer (red, green,
303 % blue, opacity, RGB, or RGBA).
306 MagickExport size_t GetQuantumExtent(const Image *image,
307 const QuantumInfo *quantum_info,const QuantumType quantum_type)
312 assert(quantum_info != (QuantumInfo *) NULL);
313 assert(quantum_info->signature == MagickCoreSignature);
315 switch (quantum_type)
317 case GrayAlphaQuantum: packet_size=2; break;
318 case IndexAlphaQuantum: packet_size=2; break;
319 case RGBQuantum: packet_size=3; break;
320 case BGRQuantum: packet_size=3; break;
321 case RGBAQuantum: packet_size=4; break;
322 case RGBOQuantum: packet_size=4; break;
323 case BGRAQuantum: packet_size=4; break;
324 case CMYKQuantum: packet_size=4; break;
325 case CMYKAQuantum: packet_size=5; break;
326 case CbYCrAQuantum: packet_size=4; break;
327 case CbYCrQuantum: packet_size=3; break;
328 case CbYCrYQuantum: packet_size=4; break;
331 if (quantum_info->pack == MagickFalse)
332 return((size_t) (packet_size*image->columns*((quantum_info->depth+7)/8)));
333 return((size_t) ((packet_size*image->columns*quantum_info->depth+7)/8));
337 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
341 % G e t Q u a n t u m E n d i a n %
345 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
347 % GetQuantumEndian() returns the quantum endian of the image.
349 % The endian of the GetQuantumEndian method is:
351 % EndianType GetQuantumEndian(const QuantumInfo *quantum_info)
353 % A description of each parameter follows:
355 % o quantum_info: the quantum info.
358 MagickExport EndianType GetQuantumEndian(const QuantumInfo *quantum_info)
360 assert(quantum_info != (QuantumInfo *) NULL);
361 assert(quantum_info->signature == MagickCoreSignature);
362 return(quantum_info->endian);
366 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
370 % G e t Q u a n t u m F o r m a t %
374 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
376 % GetQuantumFormat() returns the quantum format of the image.
378 % The format of the GetQuantumFormat method is:
380 % QuantumFormatType GetQuantumFormat(const QuantumInfo *quantum_info)
382 % A description of each parameter follows:
384 % o quantum_info: the quantum info.
387 MagickExport QuantumFormatType GetQuantumFormat(const QuantumInfo *quantum_info)
389 assert(quantum_info != (QuantumInfo *) NULL);
390 assert(quantum_info->signature == MagickCoreSignature);
391 return(quantum_info->format);
395 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
399 % G e t Q u a n t u m I n f o %
403 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
405 % GetQuantumInfo() initializes the QuantumInfo structure to default values.
407 % The format of the GetQuantumInfo method is:
409 % GetQuantumInfo(const ImageInfo *image_info,QuantumInfo *quantum_info)
411 % A description of each parameter follows:
413 % o image_info: the image info.
415 % o quantum_info: the quantum info.
418 MagickExport void GetQuantumInfo(const ImageInfo *image_info,
419 QuantumInfo *quantum_info)
424 assert(quantum_info != (QuantumInfo *) NULL);
425 (void) memset(quantum_info,0,sizeof(*quantum_info));
426 quantum_info->quantum=8;
427 quantum_info->maximum=1.0;
428 quantum_info->scale=QuantumRange;
429 quantum_info->pack=MagickTrue;
430 quantum_info->semaphore=AcquireSemaphoreInfo();
431 quantum_info->signature=MagickCoreSignature;
432 if (image_info == (const ImageInfo *) NULL)
434 option=GetImageOption(image_info,"quantum:format");
435 if (option != (char *) NULL)
436 quantum_info->format=(QuantumFormatType) ParseCommandOption(
437 MagickQuantumFormatOptions,MagickFalse,option);
438 option=GetImageOption(image_info,"quantum:minimum");
439 if (option != (char *) NULL)
440 quantum_info->minimum=StringToDouble(option,(char **) NULL);
441 option=GetImageOption(image_info,"quantum:maximum");
442 if (option != (char *) NULL)
443 quantum_info->maximum=StringToDouble(option,(char **) NULL);
444 if ((quantum_info->minimum == 0.0) && (quantum_info->maximum == 0.0))
445 quantum_info->scale=0.0;
447 if (quantum_info->minimum == quantum_info->maximum)
449 quantum_info->scale=(double) QuantumRange/quantum_info->minimum;
450 quantum_info->minimum=0.0;
453 quantum_info->scale=(double) QuantumRange/(quantum_info->maximum-
454 quantum_info->minimum);
455 option=GetImageOption(image_info,"quantum:scale");
456 if (option != (char *) NULL)
457 quantum_info->scale=StringToDouble(option,(char **) NULL);
458 option=GetImageOption(image_info,"quantum:polarity");
459 if (option != (char *) NULL)
460 quantum_info->min_is_white=LocaleCompare(option,"min-is-white") == 0 ?
461 MagickTrue : MagickFalse;
462 quantum_info->endian=image_info->endian;
463 ResetQuantumState(quantum_info);
467 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
471 % G e t Q u a n t u m P i x e l s %
475 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
477 % GetQuantumPixels() returns the quantum pixels.
479 % The format of the GetQuantumPixels method is:
481 % unsigned char *QuantumPixels GetQuantumPixels(
482 % const QuantumInfo *quantum_info)
484 % A description of each parameter follows:
486 % o image: the image.
489 MagickExport unsigned char *GetQuantumPixels(const QuantumInfo *quantum_info)
492 id = GetOpenMPThreadId();
494 assert(quantum_info != (QuantumInfo *) NULL);
495 assert(quantum_info->signature == MagickCoreSignature);
496 return((unsigned char *) GetVirtualMemoryBlob(quantum_info->pixels[id]));
500 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
504 % G e t Q u a n t u m T y p e %
508 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
510 % GetQuantumType() returns the quantum type of the image.
512 % The format of the GetQuantumType method is:
514 % QuantumType GetQuantumType(Image *image,ExceptionInfo *exception)
516 % A description of each parameter follows:
518 % o image: the image.
520 % o exception: return any errors or warnings in this structure.
523 MagickExport QuantumType GetQuantumType(Image *image,ExceptionInfo *exception)
528 assert(image != (Image *) NULL);
529 assert(image->signature == MagickCoreSignature);
530 if (image->debug != MagickFalse)
531 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
533 quantum_type=RGBQuantum;
534 if (image->alpha_trait != UndefinedPixelTrait)
535 quantum_type=RGBAQuantum;
536 if (image->colorspace == CMYKColorspace)
538 quantum_type=CMYKQuantum;
539 if (image->alpha_trait != UndefinedPixelTrait)
540 quantum_type=CMYKAQuantum;
542 if (IsGrayColorspace(image->colorspace) != MagickFalse)
544 quantum_type=GrayQuantum;
545 if (image->alpha_trait != UndefinedPixelTrait)
546 quantum_type=GrayAlphaQuantum;
548 if (image->storage_class == PseudoClass)
550 quantum_type=IndexQuantum;
551 if (image->alpha_trait != UndefinedPixelTrait)
552 quantum_type=IndexAlphaQuantum;
554 return(quantum_type);
558 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
562 + R e s e t Q u a n t u m S t a t e %
566 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
568 % ResetQuantumState() resets the quantum state.
570 % The format of the ResetQuantumState method is:
572 % void ResetQuantumState(QuantumInfo *quantum_info)
574 % A description of each parameter follows:
576 % o quantum_info: the quantum info.
579 MagickPrivate void ResetQuantumState(QuantumInfo *quantum_info)
581 static const unsigned int mask[32] =
583 0x00000000U, 0x00000001U, 0x00000003U, 0x00000007U, 0x0000000fU,
584 0x0000001fU, 0x0000003fU, 0x0000007fU, 0x000000ffU, 0x000001ffU,
585 0x000003ffU, 0x000007ffU, 0x00000fffU, 0x00001fffU, 0x00003fffU,
586 0x00007fffU, 0x0000ffffU, 0x0001ffffU, 0x0003ffffU, 0x0007ffffU,
587 0x000fffffU, 0x001fffffU, 0x003fffffU, 0x007fffffU, 0x00ffffffU,
588 0x01ffffffU, 0x03ffffffU, 0x07ffffffU, 0x0fffffffU, 0x1fffffffU,
589 0x3fffffffU, 0x7fffffffU
592 assert(quantum_info != (QuantumInfo *) NULL);
593 assert(quantum_info->signature == MagickCoreSignature);
594 quantum_info->state.inverse_scale=1.0;
595 if (fabs(quantum_info->scale) >= MagickEpsilon)
596 quantum_info->state.inverse_scale/=quantum_info->scale;
597 quantum_info->state.pixel=0U;
598 quantum_info->state.bits=0U;
599 quantum_info->state.mask=mask;
603 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
607 % S e t Q u a n t u m F o r m a t %
611 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
613 % SetQuantumAlphaType() sets the quantum format.
615 % The format of the SetQuantumAlphaType method is:
617 % void SetQuantumAlphaType(QuantumInfo *quantum_info,
618 % const QuantumAlphaType type)
620 % A description of each parameter follows:
622 % o quantum_info: the quantum info.
624 % o type: the alpha type (e.g. associate).
627 MagickExport void SetQuantumAlphaType(QuantumInfo *quantum_info,
628 const QuantumAlphaType type)
630 assert(quantum_info != (QuantumInfo *) NULL);
631 assert(quantum_info->signature == MagickCoreSignature);
632 quantum_info->alpha_type=type;
636 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
640 % S e t Q u a n t u m D e p t h %
644 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
646 % SetQuantumDepth() sets the quantum depth.
648 % The format of the SetQuantumDepth method is:
650 % MagickBooleanType SetQuantumDepth(const Image *image,
651 % QuantumInfo *quantum_info,const size_t depth)
653 % A description of each parameter follows:
655 % o image: the image.
657 % o quantum_info: the quantum info.
659 % o depth: the quantum depth.
662 MagickExport MagickBooleanType SetQuantumDepth(const Image *image,
663 QuantumInfo *quantum_info,const size_t depth)
670 Allocate the quantum pixel buffer.
672 assert(image != (Image *) NULL);
673 assert(image->signature == MagickCoreSignature);
674 if (image->debug != MagickFalse)
675 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
676 assert(quantum_info != (QuantumInfo *) NULL);
677 assert(quantum_info->signature == MagickCoreSignature);
678 quantum_info->depth=depth;
679 if (quantum_info->format == FloatingPointQuantumFormat)
681 if (quantum_info->depth > 32)
682 quantum_info->depth=64;
684 if (quantum_info->depth > 16)
685 quantum_info->depth=32;
687 quantum_info->depth=16;
689 if (quantum_info->pixels != (MemoryInfo **) NULL)
690 DestroyQuantumPixels(quantum_info);
691 quantum=(quantum_info->pad+MaxPixelChannels)*(quantum_info->depth+7)/8;
692 extent=MagickMax(image->columns,image->rows)*quantum;
693 if ((MagickMax(image->columns,image->rows) != 0) &&
694 (quantum != (extent/MagickMax(image->columns,image->rows))))
696 return(AcquireQuantumPixels(quantum_info,extent));
700 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
704 % S e t Q u a n t u m E n d i a n %
708 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
710 % SetQuantumEndian() sets the quantum endian.
712 % The endian of the SetQuantumEndian method is:
714 % MagickBooleanType SetQuantumEndian(const Image *image,
715 % QuantumInfo *quantum_info,const EndianType endian)
717 % A description of each parameter follows:
719 % o image: the image.
721 % o quantum_info: the quantum info.
723 % o endian: the quantum endian.
726 MagickExport MagickBooleanType SetQuantumEndian(const Image *image,
727 QuantumInfo *quantum_info,const EndianType endian)
729 assert(image != (Image *) NULL);
730 assert(image->signature == MagickCoreSignature);
731 if (image->debug != MagickFalse)
732 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
733 assert(quantum_info != (QuantumInfo *) NULL);
734 assert(quantum_info->signature == MagickCoreSignature);
735 quantum_info->endian=endian;
736 return(SetQuantumDepth(image,quantum_info,quantum_info->depth));
740 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
744 % S e t Q u a n t u m F o r m a t %
748 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
750 % SetQuantumFormat() sets the quantum format.
752 % The format of the SetQuantumFormat method is:
754 % MagickBooleanType SetQuantumFormat(const Image *image,
755 % QuantumInfo *quantum_info,const QuantumFormatType format)
757 % A description of each parameter follows:
759 % o image: the image.
761 % o quantum_info: the quantum info.
763 % o format: the quantum format.
766 MagickExport MagickBooleanType SetQuantumFormat(const Image *image,
767 QuantumInfo *quantum_info,const QuantumFormatType format)
769 assert(image != (Image *) NULL);
770 assert(image->signature == MagickCoreSignature);
771 if (image->debug != MagickFalse)
772 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
773 assert(quantum_info != (QuantumInfo *) NULL);
774 assert(quantum_info->signature == MagickCoreSignature);
775 quantum_info->format=format;
776 return(SetQuantumDepth(image,quantum_info,quantum_info->depth));
780 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
784 % S e t Q u a n t u m I m a g e T y p e %
788 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
790 % SetQuantumImageType() sets the image type based on the quantum type.
792 % The format of the SetQuantumImageType method is:
794 % void ImageType SetQuantumImageType(Image *image,
795 % const QuantumType quantum_type)
797 % A description of each parameter follows:
799 % o image: the image.
801 % o quantum_type: Declare which pixel components to transfer (red, green,
802 % blue, opacity, RGB, or RGBA).
805 MagickExport void SetQuantumImageType(Image *image,
806 const QuantumType quantum_type)
808 assert(image != (Image *) NULL);
809 assert(image->signature == MagickCoreSignature);
810 if (image->debug != MagickFalse)
811 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
812 switch (quantum_type)
815 case IndexAlphaQuantum:
817 image->type=PaletteType;
821 case GrayAlphaQuantum:
823 image->type=GrayscaleType;
824 if (image->depth == 1)
825 image->type=BilevelType;
835 image->type=ColorSeparationType;
840 image->type=TrueColorType;
847 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
851 % S e t Q u a n t u m P a c k %
855 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
857 % SetQuantumPack() sets the quantum pack flag.
859 % The format of the SetQuantumPack method is:
861 % void SetQuantumPack(QuantumInfo *quantum_info,
862 % const MagickBooleanType pack)
864 % A description of each parameter follows:
866 % o quantum_info: the quantum info.
868 % o pack: the pack flag.
871 MagickExport void SetQuantumPack(QuantumInfo *quantum_info,
872 const MagickBooleanType pack)
874 assert(quantum_info != (QuantumInfo *) NULL);
875 assert(quantum_info->signature == MagickCoreSignature);
876 quantum_info->pack=pack;
880 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
884 % S e t Q u a n t u m P a d %
888 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
890 % SetQuantumPad() sets the quantum pad.
892 % The format of the SetQuantumPad method is:
894 % MagickBooleanType SetQuantumPad(const Image *image,
895 % QuantumInfo *quantum_info,const size_t pad)
897 % A description of each parameter follows:
899 % o image: the image.
901 % o quantum_info: the quantum info.
903 % o pad: the quantum pad.
906 MagickExport MagickBooleanType SetQuantumPad(const Image *image,
907 QuantumInfo *quantum_info,const size_t pad)
909 assert(image != (Image *) NULL);
910 assert(image->signature == MagickCoreSignature);
911 if (image->debug != MagickFalse)
912 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
913 assert(quantum_info != (QuantumInfo *) NULL);
914 assert(quantum_info->signature == MagickCoreSignature);
915 quantum_info->pad=pad;
916 return(SetQuantumDepth(image,quantum_info,quantum_info->depth));
920 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
924 % S e t Q u a n t u m M i n I s W h i t e %
928 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
930 % SetQuantumMinIsWhite() sets the quantum min-is-white flag.
932 % The format of the SetQuantumMinIsWhite method is:
934 % void SetQuantumMinIsWhite(QuantumInfo *quantum_info,
935 % const MagickBooleanType min_is_white)
937 % A description of each parameter follows:
939 % o quantum_info: the quantum info.
941 % o min_is_white: the min-is-white flag.
944 MagickExport void SetQuantumMinIsWhite(QuantumInfo *quantum_info,
945 const MagickBooleanType min_is_white)
947 assert(quantum_info != (QuantumInfo *) NULL);
948 assert(quantum_info->signature == MagickCoreSignature);
949 quantum_info->min_is_white=min_is_white;
953 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
957 % S e t Q u a n t u m Q u a n t u m %
961 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
963 % SetQuantumQuantum() sets the quantum quantum.
965 % The format of the SetQuantumQuantum method is:
967 % void SetQuantumQuantum(QuantumInfo *quantum_info,
968 % const size_t quantum)
970 % A description of each parameter follows:
972 % o quantum_info: the quantum info.
974 % o quantum: the quantum quantum.
977 MagickExport void SetQuantumQuantum(QuantumInfo *quantum_info,
978 const size_t quantum)
980 assert(quantum_info != (QuantumInfo *) NULL);
981 assert(quantum_info->signature == MagickCoreSignature);
982 quantum_info->quantum=quantum;
986 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
990 % S e t Q u a n t u m S c a l e %
994 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
996 % SetQuantumScale() sets the quantum scale.
998 % The format of the SetQuantumScale method is:
1000 % void SetQuantumScale(QuantumInfo *quantum_info,const double scale)
1002 % A description of each parameter follows:
1004 % o quantum_info: the quantum info.
1006 % o scale: the quantum scale.
1009 MagickExport void SetQuantumScale(QuantumInfo *quantum_info,const double scale)
1011 assert(quantum_info != (QuantumInfo *) NULL);
1012 assert(quantum_info->signature == MagickCoreSignature);
1013 quantum_info->scale=scale;