blob: 655f6a421db1e14b90d5fed33635c608e8da7410 [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% %
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 %
11% %
12% MagicCore Methods to Acquire / Destroy Quantum Pixels %
13% %
14% Software Design %
15% John Cristy %
16% October 1998 %
17% %
18% %
19% Copyright 1999-2008 ImageMagick Studio LLC, a non-profit organization %
20% dedicated to making software imaging solutions freely available. %
21% %
22% You may not use this file except in compliance with the License. You may %
23% obtain a copy of the License at %
24% %
25% http://www.imagemagick.org/script/license.php %
26% %
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. %
32% %
33%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34%
35%
36*/
37
38/*
39 Include declarations.
40*/
41#include "magick/studio.h"
42#include "magick/property.h"
43#include "magick/blob.h"
44#include "magick/blob-private.h"
45#include "magick/color-private.h"
46#include "magick/exception.h"
47#include "magick/exception-private.h"
48#include "magick/cache.h"
49#include "magick/constitute.h"
50#include "magick/delegate.h"
51#include "magick/geometry.h"
52#include "magick/list.h"
53#include "magick/magick.h"
54#include "magick/memory_.h"
55#include "magick/monitor.h"
56#include "magick/option.h"
57#include "magick/pixel.h"
58#include "magick/pixel-private.h"
59#include "magick/quantum.h"
60#include "magick/quantum-private.h"
61#include "magick/resource_.h"
62#include "magick/semaphore.h"
63#include "magick/statistic.h"
64#include "magick/stream.h"
65#include "magick/string_.h"
cristyf2f27272009-12-17 14:48:46 +000066#include "magick/string-private.h"
cristy3ed852e2009-09-05 21:47:34 +000067#include "magick/thread-private.h"
68#include "magick/utility.h"
69
70/*
71 Define declarations.
72*/
73#define QuantumSignature 0xab
74
75/*
76 Forward declarations.
77*/
78static void
79 DestroyQuantumPixels(QuantumInfo *);
80
81/*
82%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
83% %
84% %
85% %
86% A c q u i r e Q u a n t u m I n f o %
87% %
88% %
89% %
90%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
91%
92% AcquireQuantumInfo() allocates the QuantumInfo structure.
93%
94% The format of the AcquireQuantumInfo method is:
95%
96% QuantumInfo *AcquireQuantumInfo(const ImageInfo *image_info,Image *image)
97%
98% A description of each parameter follows:
99%
100% o image_info: the image info.
101%
102% o image: the image.
103%
104*/
105
cristybb503372010-05-27 20:51:26 +0000106static inline size_t MagickMax(const size_t x,
107 const size_t y)
cristy3ed852e2009-09-05 21:47:34 +0000108{
109 if (x > y)
110 return(x);
111 return(y);
112}
113
114MagickExport QuantumInfo *AcquireQuantumInfo(const ImageInfo *image_info,
115 Image *image)
116{
117 MagickBooleanType
118 status;
119
120 QuantumInfo
121 *quantum_info;
122
cristy73bd4a52010-10-05 11:24:23 +0000123 quantum_info=(QuantumInfo *) AcquireMagickMemory(sizeof(*quantum_info));
cristy3ed852e2009-09-05 21:47:34 +0000124 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 return(quantum_info);
134}
135
136/*
137%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
138% %
139% %
140% %
141+ A c q u i r e Q u a n t u m P i x e l s %
142% %
143% %
144% %
145%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
146%
147% AcquireQuantumPixels() allocates the unsigned char structure.
148%
149% The format of the AcquireQuantumPixels method is:
150%
151% MagickBooleanType AcquireQuantumPixels(QuantumInfo *quantum_info,
152% const size_t extent)
153%
154% A description of each parameter follows:
155%
156% o quantum_info: the quantum info.
157%
158% o extent: the quantum info.
159%
160*/
161static MagickBooleanType AcquireQuantumPixels(QuantumInfo *quantum_info,
162 const size_t extent)
163{
cristybb503372010-05-27 20:51:26 +0000164 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000165 i;
166
167 assert(quantum_info != (QuantumInfo *) NULL);
168 assert(quantum_info->signature == MagickSignature);
169 quantum_info->number_threads=GetOpenMPMaximumThreads();
170 quantum_info->pixels=(unsigned char **) AcquireQuantumMemory(
171 quantum_info->number_threads,sizeof(*quantum_info->pixels));
172 if (quantum_info->pixels == (unsigned char **) NULL)
173 return(MagickFalse);
174 quantum_info->extent=extent;
175 (void) ResetMagickMemory(quantum_info->pixels,0,
176 sizeof(*quantum_info->pixels));
cristybb503372010-05-27 20:51:26 +0000177 for (i=0; i < (ssize_t) quantum_info->number_threads; i++)
cristy3ed852e2009-09-05 21:47:34 +0000178 {
179 quantum_info->pixels[i]=(unsigned char *) AcquireQuantumMemory(extent+1,
180 sizeof(**quantum_info->pixels));
cristy84787932009-10-06 19:18:19 +0000181 if (quantum_info->pixels[i] == (unsigned char *) NULL)
cristy3ed852e2009-09-05 21:47:34 +0000182 return(MagickFalse);
183 (void) ResetMagickMemory(quantum_info->pixels[i],0,(extent+1)*
184 sizeof(**quantum_info->pixels));
185 quantum_info->pixels[i][extent]=QuantumSignature;
186 }
187 return(MagickTrue);
188}
189
190/*
191%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
192% %
193% %
194% %
195% D e s t r o y Q u a n t u m I n f o %
196% %
197% %
198% %
199%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
200%
201% DestroyQuantumInfo() deallocates memory associated with the QuantumInfo
202% structure.
203%
204% The format of the DestroyQuantumInfo method is:
205%
206% QuantumInfo *DestroyQuantumInfo(QuantumInfo *quantum_info)
207%
208% A description of each parameter follows:
209%
210% o quantum_info: the quantum info.
211%
212*/
213MagickExport QuantumInfo *DestroyQuantumInfo(QuantumInfo *quantum_info)
214{
215 assert(quantum_info != (QuantumInfo *) NULL);
216 assert(quantum_info->signature == MagickSignature);
217 if (quantum_info->pixels != (unsigned char **) NULL)
218 DestroyQuantumPixels(quantum_info);
219 if (quantum_info->semaphore != (SemaphoreInfo *) NULL)
220 DestroySemaphoreInfo(&quantum_info->semaphore);
221 quantum_info->signature=(~MagickSignature);
222 quantum_info=(QuantumInfo *) RelinquishMagickMemory(quantum_info);
223 return(quantum_info);
224}
225
226/*
227%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
228% %
229% %
230% %
231+ D e s t r o y Q u a n t u m P i x e l s %
232% %
233% %
234% %
235%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
236%
237% DestroyQuantumPixels() destroys the quantum pixels.
238%
239% The format of the DestroyQuantumPixels() method is:
240%
241% void DestroyQuantumPixels(QuantumInfo *quantum_info)
242%
243% A description of each parameter follows:
244%
245% o quantum_info: the quantum info.
246%
247*/
248static void DestroyQuantumPixels(QuantumInfo *quantum_info)
249{
cristybb503372010-05-27 20:51:26 +0000250 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000251 i;
252
253 assert(quantum_info != (QuantumInfo *) NULL);
254 assert(quantum_info->signature == MagickSignature);
255 assert(quantum_info->pixels != (unsigned char **) NULL);
cristybb503372010-05-27 20:51:26 +0000256 for (i=0; i < (ssize_t) quantum_info->number_threads; i++)
cristy3ed852e2009-09-05 21:47:34 +0000257 {
cristy87440472010-05-15 14:21:45 +0000258 /*
259 Did we overrun our quantum buffer?
260 */
cristy3ed852e2009-09-05 21:47:34 +0000261 assert(quantum_info->pixels[i][quantum_info->extent] == QuantumSignature);
262 quantum_info->pixels[i]=(unsigned char *) RelinquishMagickMemory(
263 quantum_info->pixels[i]);
264 }
265 quantum_info->pixels=(unsigned char **) RelinquishMagickMemory(
266 quantum_info->pixels);
267}
268
269/*
270%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
271% %
272% %
273% %
274% G e t Q u a n t u m E x t e n t %
275% %
276% %
277% %
278%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
279%
280% GetQuantumExtent() returns the quantum pixel buffer extent.
281%
282% The format of the GetQuantumExtent method is:
283%
284% size_t GetQuantumExtent(Image *image,const QuantumInfo *quantum_info,
285% const QuantumType quantum_type)
286%
287% A description of each parameter follows:
288%
289% o image: the image.
290%
291% o quantum_info: the quantum info.
292%
293% o quantum_type: Declare which pixel components to transfer (red, green,
294% blue, opacity, RGB, or RGBA).
295%
296*/
297MagickExport size_t GetQuantumExtent(const Image *image,
298 const QuantumInfo *quantum_info,const QuantumType quantum_type)
299{
300 size_t
301 packet_size;
302
303 assert(quantum_info != (QuantumInfo *) NULL);
304 assert(quantum_info->signature == MagickSignature);
305 packet_size=1;
306 switch (quantum_type)
307 {
308 case GrayAlphaQuantum: packet_size=2; break;
309 case IndexAlphaQuantum: packet_size=2; break;
310 case RGBQuantum: packet_size=3; break;
cristy1f9852b2010-09-04 15:05:36 +0000311 case BGRQuantum: packet_size=3; break;
cristy3ed852e2009-09-05 21:47:34 +0000312 case RGBAQuantum: packet_size=4; break;
313 case RGBOQuantum: packet_size=4; break;
cristy1f9852b2010-09-04 15:05:36 +0000314 case BGRAQuantum: packet_size=4; break;
cristy3ed852e2009-09-05 21:47:34 +0000315 case CMYKQuantum: packet_size=4; break;
316 case CMYKAQuantum: packet_size=5; break;
317 default: break;
318 }
319 if (quantum_info->pack == MagickFalse)
cristyc9672a92010-01-06 00:57:45 +0000320 return((size_t) (packet_size*image->columns*((quantum_info->depth+7)/8)));
321 return((size_t) ((packet_size*image->columns*quantum_info->depth+7)/8));
cristy3ed852e2009-09-05 21:47:34 +0000322}
323
324/*
325%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
326% %
327% %
328% %
329% G e t Q u a n t u m I n f o %
330% %
331% %
332% %
333%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
334%
335% GetQuantumInfo() initializes the QuantumInfo structure to default values.
336%
337% The format of the GetQuantumInfo method is:
338%
339% GetQuantumInfo(const ImageInfo *image_info,QuantumInfo *quantum_info)
340%
341% A description of each parameter follows:
342%
343% o image_info: the image info.
344%
345% o quantum_info: the quantum info.
346%
347*/
348MagickExport void GetQuantumInfo(const ImageInfo *image_info,
349 QuantumInfo *quantum_info)
350{
351 const char
352 *option;
353
354 assert(quantum_info != (QuantumInfo *) NULL);
355 (void) ResetMagickMemory(quantum_info,0,sizeof(*quantum_info));
356 quantum_info->quantum=8;
357 quantum_info->maximum=1.0;
358 quantum_info->scale=QuantumRange;
359 quantum_info->pack=MagickTrue;
360 quantum_info->semaphore=AllocateSemaphoreInfo();
361 quantum_info->signature=MagickSignature;
362 if (image_info == (const ImageInfo *) NULL)
363 return;
364 option=GetImageOption(image_info,"quantum:format");
365 if (option != (char *) NULL)
366 quantum_info->format=(QuantumFormatType) ParseMagickOption(
367 MagickQuantumFormatOptions,MagickFalse,option);
368 option=GetImageOption(image_info,"quantum:minimum");
369 if (option != (char *) NULL)
cristyf2f27272009-12-17 14:48:46 +0000370 quantum_info->minimum=StringToDouble(option);
cristy3ed852e2009-09-05 21:47:34 +0000371 option=GetImageOption(image_info,"quantum:maximum");
372 if (option != (char *) NULL)
cristyf2f27272009-12-17 14:48:46 +0000373 quantum_info->maximum=StringToDouble(option);
cristy3ed852e2009-09-05 21:47:34 +0000374 if ((quantum_info->minimum == 0.0) && (quantum_info->maximum == 0.0))
375 quantum_info->scale=0.0;
376 else
377 if (quantum_info->minimum == quantum_info->maximum)
378 {
379 quantum_info->scale=(MagickRealType) QuantumRange/quantum_info->minimum;
380 quantum_info->minimum=0.0;
381 }
382 else
383 quantum_info->scale=(MagickRealType) QuantumRange/(quantum_info->maximum-
384 quantum_info->minimum);
385 option=GetImageOption(image_info,"quantum:scale");
386 if (option != (char *) NULL)
cristyf2f27272009-12-17 14:48:46 +0000387 quantum_info->scale=StringToDouble(option);
cristy3ed852e2009-09-05 21:47:34 +0000388 option=GetImageOption(image_info,"quantum:polarity");
389 if (option != (char *) NULL)
390 quantum_info->min_is_white=LocaleCompare(option,"min-is-white") == 0 ?
391 MagickTrue : MagickFalse;
392}
393
394/*
395%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
396% %
397% %
398% %
399% G e t Q u a n t u m P i x e l s %
400% %
401% %
402% %
403%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
404%
405% GetQuantumPixels() returns the quantum pixels.
406%
407% The format of the GetQuantumPixels method is:
408%
409% unsigned char *QuantumPixels GetQuantumPixels(
410% const QuantumInfo *quantum_info)
411%
412% A description of each parameter follows:
413%
414% o image: the image.
415%
416*/
417MagickExport unsigned char *GetQuantumPixels(const QuantumInfo *quantum_info)
418{
cristy5c9e6f22010-09-17 17:31:01 +0000419 const int
420 id = GetOpenMPThreadId();
cristy3ed852e2009-09-05 21:47:34 +0000421
422 assert(quantum_info != (QuantumInfo *) NULL);
423 assert(quantum_info->signature == MagickSignature);
cristy3ed852e2009-09-05 21:47:34 +0000424 return(quantum_info->pixels[id]);
425}
426
427/*
428%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
429% %
430% %
431% %
432% G e t Q u a n t u m T y p e %
433% %
434% %
435% %
436%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
437%
438% GetQuantumType() returns the quantum type of the image.
439%
440% The format of the GetQuantumType method is:
441%
442% QuantumType GetQuantumType(Image *image,ExceptionInfo *exception)
443%
444% A description of each parameter follows:
445%
446% o image: the image.
447%
448*/
449MagickExport QuantumType GetQuantumType(Image *image,ExceptionInfo *exception)
450{
451 QuantumType
452 quantum_type;
453
454 assert(image != (Image *) NULL);
455 assert(image->signature == MagickSignature);
456 if (image->debug != MagickFalse)
457 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
458 quantum_type=RGBQuantum;
459 if (image->matte != MagickFalse)
460 quantum_type=RGBAQuantum;
461 if (image->colorspace == CMYKColorspace)
462 {
463 quantum_type=CMYKQuantum;
464 if (image->matte != MagickFalse)
465 quantum_type=CMYKAQuantum;
466 }
467 if (IsGrayImage(image,exception) != MagickFalse)
468 {
469 quantum_type=GrayQuantum;
470 if (image->matte != MagickFalse)
471 quantum_type=GrayAlphaQuantum;
472 }
473 else
474 if (image->storage_class == PseudoClass)
475 {
476 quantum_type=IndexQuantum;
477 if (image->matte != MagickFalse)
478 quantum_type=IndexAlphaQuantum;
479 }
480 return(quantum_type);
481}
482
483/*
484%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
485% %
486% %
487% %
488% S e t Q u a n t u m F o r m a t %
489% %
490% %
491% %
492%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
493%
494% SetQuantumAlphaType() sets the quantum format.
495%
496% The format of the SetQuantumAlphaType method is:
497%
498% void SetQuantumAlphaType(QuantumInfo *quantum_info,
499% const QuantumAlphaType type)
500%
501% A description of each parameter follows:
502%
503% o quantum_info: the quantum info.
504%
505% o type: the alpha type (e.g. associate).
506%
507*/
508MagickExport void SetQuantumAlphaType(QuantumInfo *quantum_info,
509 const QuantumAlphaType type)
510{
511 assert(quantum_info != (QuantumInfo *) NULL);
512 assert(quantum_info->signature == MagickSignature);
513 quantum_info->alpha_type=type;
514}
515
516/*
517%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
518% %
519% %
520% %
521% S e t Q u a n t u m D e p t h %
522% %
523% %
524% %
525%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
526%
527% SetQuantumDepth() sets the quantum depth.
528%
529% The format of the SetQuantumDepth method is:
530%
531% MagickBooleanType SetQuantumDepth(const Image *image,
cristybb503372010-05-27 20:51:26 +0000532% QuantumInfo *quantum_info,const size_t depth)
cristy3ed852e2009-09-05 21:47:34 +0000533%
534% A description of each parameter follows:
535%
536% o image: the image.
537%
538% o quantum_info: the quantum info.
539%
540% o depth: the quantum depth.
541%
542*/
543MagickExport MagickBooleanType SetQuantumDepth(const Image *image,
cristybb503372010-05-27 20:51:26 +0000544 QuantumInfo *quantum_info,const size_t depth)
cristy3ed852e2009-09-05 21:47:34 +0000545{
546 MagickBooleanType
547 status;
548
549 /*
550 Allocate the quantum pixel buffer.
551 */
552 assert(image != (Image *) NULL);
553 assert(image->signature == MagickSignature);
554 if (image->debug != MagickFalse)
555 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
556 assert(quantum_info != (QuantumInfo *) NULL);
557 assert(quantum_info->signature == MagickSignature);
558 quantum_info->depth=depth;
559 if (quantum_info->format == FloatingPointQuantumFormat)
560 {
561 if (quantum_info->depth > 32)
562 quantum_info->depth=64;
563 else
cristyc9672a92010-01-06 00:57:45 +0000564 if (quantum_info->depth > 16)
565 quantum_info->depth=32;
566 else
567 quantum_info->depth=16;
cristy3ed852e2009-09-05 21:47:34 +0000568 }
cristy3ed852e2009-09-05 21:47:34 +0000569 if (quantum_info->pixels != (unsigned char **) NULL)
570 DestroyQuantumPixels(quantum_info);
cristya3274322010-05-14 23:22:12 +0000571 status=AcquireQuantumPixels(quantum_info,(6+quantum_info->pad)*image->columns*
cristy2dfdad32010-05-15 14:15:35 +0000572 ((quantum_info->depth+7)/8)); /* allow for CMYKA + RLE byte + pad */
cristy3ed852e2009-09-05 21:47:34 +0000573 return(status);
574}
575
576/*
577%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
578% %
579% %
580% %
581% S e t Q u a n t u m F o r m a t %
582% %
583% %
584% %
585%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
586%
587% SetQuantumFormat() sets the quantum format.
588%
589% The format of the SetQuantumFormat method is:
590%
591% MagickBooleanType SetQuantumFormat(const Image *image,
592% QuantumInfo *quantum_info,const QuantumFormatType format)
593%
594% A description of each parameter follows:
595%
596% o image: the image.
597%
598% o quantum_info: the quantum info.
599%
600% o format: the quantum format.
601%
602*/
603MagickExport MagickBooleanType SetQuantumFormat(const Image *image,
604 QuantumInfo *quantum_info,const QuantumFormatType format)
605{
606 assert(image != (Image *) NULL);
607 assert(image->signature == MagickSignature);
608 if (image->debug != MagickFalse)
609 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
610 assert(quantum_info != (QuantumInfo *) NULL);
611 assert(quantum_info->signature == MagickSignature);
612 quantum_info->format=format;
613 return(SetQuantumDepth(image,quantum_info,quantum_info->depth));
614}
615
616/*
617%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
618% %
619% %
620% %
621% S e t Q u a n t u m I m a g e T y p e %
622% %
623% %
624% %
625%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
626%
627% SetQuantumImageType() sets the image type based on the quantum type.
628%
629% The format of the SetQuantumImageType method is:
630%
631% void ImageType SetQuantumImageType(Image *image,
632% const QuantumType quantum_type)
633%
634% A description of each parameter follows:
635%
636% o image: the image.
637%
638% o quantum_type: Declare which pixel components to transfer (red, green,
639% blue, opacity, RGB, or RGBA).
640%
641*/
642MagickExport void SetQuantumImageType(Image *image,
643 const QuantumType quantum_type)
644{
645 assert(image != (Image *) NULL);
646 assert(image->signature == MagickSignature);
647 if (image->debug != MagickFalse)
648 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
649 switch (quantum_type)
650 {
651 case IndexQuantum:
652 case IndexAlphaQuantum:
653 {
654 image->type=PaletteType;
655 break;
656 }
657 case GrayQuantum:
658 case GrayAlphaQuantum:
659 {
660 image->type=GrayscaleType;
661 if (image->depth == 1)
662 image->type=BilevelType;
663 break;
664 }
665 case CyanQuantum:
666 case MagentaQuantum:
667 case YellowQuantum:
668 case BlackQuantum:
669 case CMYKQuantum:
670 case CMYKAQuantum:
671 {
672 image->type=ColorSeparationType;
673 break;
674 }
675 default:
676 {
677 image->type=TrueColorType;
678 break;
679 }
680 }
681}
682
683/*
684%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
685% %
686% %
687% %
688% S e t Q u a n t u m P a c k %
689% %
690% %
691% %
692%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
693%
694% SetQuantumPack() sets the quantum pack flag.
695%
696% The format of the SetQuantumPack method is:
697%
698% void SetQuantumPack(QuantumInfo *quantum_info,
699% const MagickBooleanType pack)
700%
701% A description of each parameter follows:
702%
703% o quantum_info: the quantum info.
704%
705% o pack: the pack flag.
706%
707*/
708MagickExport void SetQuantumPack(QuantumInfo *quantum_info,
709 const MagickBooleanType pack)
710{
711 assert(quantum_info != (QuantumInfo *) NULL);
712 assert(quantum_info->signature == MagickSignature);
713 quantum_info->pack=pack;
714}
715
716
717/*
718%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
719% %
720% %
721% %
722% S e t Q u a n t u m P a d %
723% %
724% %
725% %
726%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
727%
728% SetQuantumPad() sets the quantum pad.
729%
730% The format of the SetQuantumPad method is:
731%
732% MagickBooleanType SetQuantumPad(const Image *image,
cristybb503372010-05-27 20:51:26 +0000733% QuantumInfo *quantum_info,const size_t pad)
cristy3ed852e2009-09-05 21:47:34 +0000734%
735% A description of each parameter follows:
736%
737% o image: the image.
738%
739% o quantum_info: the quantum info.
740%
741% o pad: the quantum pad.
742%
743*/
744MagickExport MagickBooleanType SetQuantumPad(const Image *image,
cristybb503372010-05-27 20:51:26 +0000745 QuantumInfo *quantum_info,const size_t pad)
cristy3ed852e2009-09-05 21:47:34 +0000746{
747 assert(image != (Image *) NULL);
748 assert(image->signature == MagickSignature);
749 if (image->debug != MagickFalse)
750 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
751 assert(quantum_info != (QuantumInfo *) NULL);
752 assert(quantum_info->signature == MagickSignature);
753 quantum_info->pad=pad;
754 return(SetQuantumDepth(image,quantum_info,quantum_info->depth));
755}
756
757/*
758%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
759% %
760% %
761% %
762% S e t Q u a n t u m M i n I s W h i t e %
763% %
764% %
765% %
766%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
767%
768% SetQuantumMinIsWhite() sets the quantum min-is-white flag.
769%
770% The format of the SetQuantumMinIsWhite method is:
771%
772% void SetQuantumMinIsWhite(QuantumInfo *quantum_info,
773% const MagickBooleanType min_is_white)
774%
775% A description of each parameter follows:
776%
777% o quantum_info: the quantum info.
778%
779% o min_is_white: the min-is-white flag.
780%
781*/
782MagickExport void SetQuantumMinIsWhite(QuantumInfo *quantum_info,
783 const MagickBooleanType min_is_white)
784{
785 assert(quantum_info != (QuantumInfo *) NULL);
786 assert(quantum_info->signature == MagickSignature);
787 quantum_info->min_is_white=min_is_white;
788}
789
790/*
791%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
792% %
793% %
794% %
795% S e t Q u a n t u m Q u a n t u m %
796% %
797% %
798% %
799%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
800%
801% SetQuantumQuantum() sets the quantum quantum.
802%
803% The format of the SetQuantumQuantum method is:
804%
805% void SetQuantumQuantum(QuantumInfo *quantum_info,
cristybb503372010-05-27 20:51:26 +0000806% const size_t quantum)
cristy3ed852e2009-09-05 21:47:34 +0000807%
808% A description of each parameter follows:
809%
810% o quantum_info: the quantum info.
811%
812% o quantum: the quantum quantum.
813%
814*/
815MagickExport void SetQuantumQuantum(QuantumInfo *quantum_info,
cristybb503372010-05-27 20:51:26 +0000816 const size_t quantum)
cristy3ed852e2009-09-05 21:47:34 +0000817{
818 assert(quantum_info != (QuantumInfo *) NULL);
819 assert(quantum_info->signature == MagickSignature);
820 quantum_info->quantum=quantum;
821}
822
823/*
824%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
825% %
826% %
827% %
828% S e t Q u a n t u m S c a l e %
829% %
830% %
831% %
832%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
833%
834% SetQuantumScale() sets the quantum scale.
835%
836% The format of the SetQuantumScale method is:
837%
838% void SetQuantumScale(QuantumInfo *quantum_info,const double scale)
839%
840% A description of each parameter follows:
841%
842% o quantum_info: the quantum info.
843%
844% o scale: the quantum scale.
845%
846*/
847MagickExport void SetQuantumScale(QuantumInfo *quantum_info,const double scale)
848{
849 assert(quantum_info != (QuantumInfo *) NULL);
850 assert(quantum_info->signature == MagickSignature);
851 quantum_info->scale=scale;
852}