/src/imagemagick/MagickCore/quantum.c
Line | Count | Source |
1 | | /* |
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 | | % Cristy % |
16 | | % October 1998 % |
17 | | % % |
18 | | % % |
19 | | % Copyright @ 1999 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 | | % https://imagemagick.org/license/ % |
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 "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" |
74 | | |
75 | | /* |
76 | | Define declarations. |
77 | | */ |
78 | 192k | #define QuantumSignature 0xab |
79 | | |
80 | | /* |
81 | | Forward declarations. |
82 | | */ |
83 | | static void |
84 | | DestroyQuantumPixels(QuantumInfo *); |
85 | | |
86 | | /* |
87 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
88 | | % % |
89 | | % % |
90 | | % % |
91 | | % A c q u i r e Q u a n t u m I n f o % |
92 | | % % |
93 | | % % |
94 | | % % |
95 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
96 | | % |
97 | | % AcquireQuantumInfo() allocates the QuantumInfo structure. |
98 | | % |
99 | | % The format of the AcquireQuantumInfo method is: |
100 | | % |
101 | | % QuantumInfo *AcquireQuantumInfo(const ImageInfo *image_info,Image *image) |
102 | | % |
103 | | % A description of each parameter follows: |
104 | | % |
105 | | % o image_info: the image info. |
106 | | % |
107 | | % o image: the image. |
108 | | % |
109 | | */ |
110 | | MagickExport QuantumInfo *AcquireQuantumInfo(const ImageInfo *image_info, |
111 | | Image *image) |
112 | 180k | { |
113 | 180k | MagickBooleanType |
114 | 180k | status; |
115 | | |
116 | 180k | QuantumInfo |
117 | 180k | *quantum_info; |
118 | | |
119 | 180k | quantum_info=(QuantumInfo *) AcquireCriticalMemory(sizeof(*quantum_info)); |
120 | 180k | quantum_info->signature=MagickCoreSignature; |
121 | 180k | GetQuantumInfo(image_info,quantum_info); |
122 | 180k | if (image == (const Image *) NULL) |
123 | 0 | return(quantum_info); |
124 | 180k | status=SetQuantumDepth(image,quantum_info,image->depth); |
125 | 180k | quantum_info->endian=image->endian; |
126 | 180k | if (status == MagickFalse) |
127 | 0 | quantum_info=DestroyQuantumInfo(quantum_info); |
128 | 180k | return(quantum_info); |
129 | 180k | } |
130 | | |
131 | | /* |
132 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
133 | | % % |
134 | | % % |
135 | | % % |
136 | | + A c q u i r e Q u a n t u m P i x e l s % |
137 | | % % |
138 | | % % |
139 | | % % |
140 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
141 | | % |
142 | | % AcquireQuantumPixels() allocates the pixel staging areas. |
143 | | % |
144 | | % The format of the AcquireQuantumPixels method is: |
145 | | % |
146 | | % MagickBooleanType AcquireQuantumPixels(QuantumInfo *quantum_info, |
147 | | % const size_t extent) |
148 | | % |
149 | | % A description of each parameter follows: |
150 | | % |
151 | | % o quantum_info: the quantum info. |
152 | | % |
153 | | % o extent: the quantum info. |
154 | | % |
155 | | */ |
156 | | static MagickBooleanType AcquireQuantumPixels(QuantumInfo *quantum_info, |
157 | | const size_t extent) |
158 | 192k | { |
159 | 192k | ssize_t |
160 | 192k | i; |
161 | | |
162 | 192k | assert(quantum_info != (QuantumInfo *) NULL); |
163 | 192k | assert(quantum_info->signature == MagickCoreSignature); |
164 | 192k | quantum_info->number_threads=(size_t) GetMagickResourceLimit(ThreadResource); |
165 | 192k | quantum_info->pixels=(MemoryInfo **) AcquireQuantumMemory( |
166 | 192k | quantum_info->number_threads,sizeof(*quantum_info->pixels)); |
167 | 192k | if (quantum_info->pixels == (MemoryInfo **) NULL) |
168 | 0 | return(MagickFalse); |
169 | 192k | quantum_info->extent=extent; |
170 | 192k | (void) memset(quantum_info->pixels,0,quantum_info->number_threads* |
171 | 192k | sizeof(*quantum_info->pixels)); |
172 | 384k | for (i=0; i < (ssize_t) quantum_info->number_threads; i++) |
173 | 192k | { |
174 | 192k | unsigned char |
175 | 192k | *pixels; |
176 | | |
177 | 192k | quantum_info->pixels[i]=AcquireVirtualMemory(extent+1,sizeof(*pixels)); |
178 | 192k | if (quantum_info->pixels[i] == (MemoryInfo *) NULL) |
179 | 0 | { |
180 | 0 | DestroyQuantumPixels(quantum_info); |
181 | 0 | return(MagickFalse); |
182 | 0 | } |
183 | 192k | pixels=(unsigned char *) GetVirtualMemoryBlob(quantum_info->pixels[i]); |
184 | 192k | (void) memset(pixels,0,(extent+1)*sizeof(*pixels)); |
185 | 192k | pixels[extent]=QuantumSignature; |
186 | 192k | } |
187 | 192k | return(MagickTrue); |
188 | 192k | } |
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 | | */ |
213 | | MagickExport QuantumInfo *DestroyQuantumInfo(QuantumInfo *quantum_info) |
214 | 180k | { |
215 | 180k | assert(quantum_info != (QuantumInfo *) NULL); |
216 | 180k | assert(quantum_info->signature == MagickCoreSignature); |
217 | 180k | if (quantum_info->pixels != (MemoryInfo **) NULL) |
218 | 180k | DestroyQuantumPixels(quantum_info); |
219 | 180k | if (quantum_info->semaphore != (SemaphoreInfo *) NULL) |
220 | 180k | RelinquishSemaphoreInfo(&quantum_info->semaphore); |
221 | 180k | quantum_info->signature=(~MagickCoreSignature); |
222 | 180k | quantum_info=(QuantumInfo *) RelinquishMagickMemory(quantum_info); |
223 | 180k | return(quantum_info); |
224 | 180k | } |
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 | | */ |
248 | | static void DestroyQuantumPixels(QuantumInfo *quantum_info) |
249 | 192k | { |
250 | 192k | ssize_t |
251 | 192k | i; |
252 | | |
253 | 192k | assert(quantum_info != (QuantumInfo *) NULL); |
254 | 192k | assert(quantum_info->signature == MagickCoreSignature); |
255 | 192k | assert(quantum_info->pixels != (MemoryInfo **) NULL); |
256 | 384k | for (i=0; i < (ssize_t) quantum_info->number_threads; i++) |
257 | 192k | if (quantum_info->pixels[i] != (MemoryInfo *) NULL) |
258 | 192k | { |
259 | 192k | #ifndef NDEBUG |
260 | 192k | ssize_t |
261 | 192k | extent; |
262 | | |
263 | 192k | unsigned char |
264 | 192k | *pixels; |
265 | | |
266 | | /* |
267 | | Did we overrun our quantum buffer? |
268 | | */ |
269 | 192k | extent=(ssize_t) quantum_info->extent; |
270 | 192k | pixels=(unsigned char *) GetVirtualMemoryBlob(quantum_info->pixels[i]); |
271 | 192k | assert(pixels[extent] == QuantumSignature); |
272 | 192k | #endif |
273 | 192k | quantum_info->pixels[i]=RelinquishVirtualMemory( |
274 | 192k | quantum_info->pixels[i]); |
275 | 192k | } |
276 | 192k | quantum_info->pixels=(MemoryInfo **) RelinquishMagickMemory( |
277 | 192k | quantum_info->pixels); |
278 | 192k | } |
279 | | |
280 | | /* |
281 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
282 | | % % |
283 | | % % |
284 | | % % |
285 | | % G e t Q u a n t u m E x t e n t % |
286 | | % % |
287 | | % % |
288 | | % % |
289 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
290 | | % |
291 | | % GetQuantumExtent() returns the quantum pixel buffer extent. |
292 | | % |
293 | | % The format of the GetQuantumExtent method is: |
294 | | % |
295 | | % size_t GetQuantumExtent(Image *image,const QuantumInfo *quantum_info, |
296 | | % const QuantumType quantum_type) |
297 | | % |
298 | | % A description of each parameter follows: |
299 | | % |
300 | | % o image: the image. |
301 | | % |
302 | | % o quantum_info: the quantum info. |
303 | | % |
304 | | % o quantum_type: Declare which pixel components to transfer (red, green, |
305 | | % blue, opacity, RGB, or RGBA). |
306 | | % |
307 | | */ |
308 | | MagickExport size_t GetQuantumExtent(const Image *image, |
309 | | const QuantumInfo *quantum_info,const QuantumType quantum_type) |
310 | 11.4M | { |
311 | 11.4M | size_t |
312 | 11.4M | channels; |
313 | | |
314 | 11.4M | assert(quantum_info != (QuantumInfo *) NULL); |
315 | 11.4M | assert(quantum_info->signature == MagickCoreSignature); |
316 | 11.4M | channels=1; |
317 | 11.4M | switch (quantum_type) |
318 | 11.4M | { |
319 | 101k | case GrayAlphaQuantum: channels=2; break; |
320 | 23.5k | case IndexAlphaQuantum: channels=2; break; |
321 | 816k | case RGBQuantum: channels=3; break; |
322 | 0 | case BGRQuantum: channels=3; break; |
323 | 223k | case RGBAQuantum: channels=4; break; |
324 | 0 | case RGBOQuantum: channels=4; break; |
325 | 0 | case BGRAQuantum: channels=4; break; |
326 | 379k | case CMYKQuantum: channels=4; break; |
327 | 88.0k | case CMYKAQuantum: channels=5; break; |
328 | 659k | case MultispectralQuantum: channels=GetImageChannels(image); break; |
329 | 749 | case CbYCrAQuantum: channels=4; break; |
330 | 2.81k | case CbYCrQuantum: channels=3; break; |
331 | 5.04k | case CbYCrYQuantum: channels=4; break; |
332 | 9.10M | default: break; |
333 | 11.4M | } |
334 | 11.4M | if (quantum_info->pack == MagickFalse) |
335 | 109k | return((size_t) (channels*image->columns*((quantum_info->depth+7)/8))+ |
336 | 109k | (quantum_info->pad*image->columns)); |
337 | 11.2M | return((size_t) ((channels*image->columns*quantum_info->depth+7)/8)+ |
338 | 11.2M | (quantum_info->pad*image->columns)); |
339 | 11.4M | } |
340 | | |
341 | | /* |
342 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
343 | | % % |
344 | | % % |
345 | | % % |
346 | | % G e t Q u a n t u m E n d i a n % |
347 | | % % |
348 | | % % |
349 | | % % |
350 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
351 | | % |
352 | | % GetQuantumEndian() returns the quantum endian of the image. |
353 | | % |
354 | | % The endian of the GetQuantumEndian method is: |
355 | | % |
356 | | % EndianType GetQuantumEndian(const QuantumInfo *quantum_info) |
357 | | % |
358 | | % A description of each parameter follows: |
359 | | % |
360 | | % o quantum_info: the quantum info. |
361 | | % |
362 | | */ |
363 | | MagickExport EndianType GetQuantumEndian(const QuantumInfo *quantum_info) |
364 | 0 | { |
365 | 0 | assert(quantum_info != (QuantumInfo *) NULL); |
366 | 0 | assert(quantum_info->signature == MagickCoreSignature); |
367 | 0 | return(quantum_info->endian); |
368 | 0 | } |
369 | | |
370 | | /* |
371 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
372 | | % % |
373 | | % % |
374 | | % % |
375 | | % G e t Q u a n t u m F o r m a t % |
376 | | % % |
377 | | % % |
378 | | % % |
379 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
380 | | % |
381 | | % GetQuantumFormat() returns the quantum format of the image. |
382 | | % |
383 | | % The format of the GetQuantumFormat method is: |
384 | | % |
385 | | % QuantumFormatType GetQuantumFormat(const QuantumInfo *quantum_info) |
386 | | % |
387 | | % A description of each parameter follows: |
388 | | % |
389 | | % o quantum_info: the quantum info. |
390 | | % |
391 | | */ |
392 | | MagickExport QuantumFormatType GetQuantumFormat(const QuantumInfo *quantum_info) |
393 | 893 | { |
394 | 893 | assert(quantum_info != (QuantumInfo *) NULL); |
395 | 893 | assert(quantum_info->signature == MagickCoreSignature); |
396 | 893 | return(quantum_info->format); |
397 | 893 | } |
398 | | |
399 | | /* |
400 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
401 | | % % |
402 | | % % |
403 | | % % |
404 | | % G e t Q u a n t u m I n f o % |
405 | | % % |
406 | | % % |
407 | | % % |
408 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
409 | | % |
410 | | % GetQuantumInfo() initializes the QuantumInfo structure to default values. |
411 | | % |
412 | | % The format of the GetQuantumInfo method is: |
413 | | % |
414 | | % GetQuantumInfo(const ImageInfo *image_info,QuantumInfo *quantum_info) |
415 | | % |
416 | | % A description of each parameter follows: |
417 | | % |
418 | | % o image_info: the image info. |
419 | | % |
420 | | % o quantum_info: the quantum info. |
421 | | % |
422 | | */ |
423 | | MagickExport void GetQuantumInfo(const ImageInfo *image_info, |
424 | | QuantumInfo *quantum_info) |
425 | 180k | { |
426 | 180k | const char |
427 | 180k | *option; |
428 | | |
429 | 180k | assert(quantum_info != (QuantumInfo *) NULL); |
430 | 180k | (void) memset(quantum_info,0,sizeof(*quantum_info)); |
431 | 180k | quantum_info->quantum=8; |
432 | 180k | quantum_info->maximum=1.0; |
433 | 180k | quantum_info->scale=QuantumRange; |
434 | 180k | quantum_info->pack=MagickTrue; |
435 | 180k | quantum_info->semaphore=AcquireSemaphoreInfo(); |
436 | 180k | quantum_info->signature=MagickCoreSignature; |
437 | 180k | if (image_info == (const ImageInfo *) NULL) |
438 | 0 | return; |
439 | 180k | option=GetImageOption(image_info,"quantum:format"); |
440 | 180k | if (option != (char *) NULL) |
441 | 1.21k | quantum_info->format=(QuantumFormatType) ParseCommandOption( |
442 | 1.21k | MagickQuantumFormatOptions,MagickFalse,option); |
443 | 180k | option=GetImageOption(image_info,"quantum:minimum"); |
444 | 180k | if (option != (char *) NULL) |
445 | 0 | quantum_info->minimum=StringToDouble(option,(char **) NULL); |
446 | 180k | option=GetImageOption(image_info,"quantum:maximum"); |
447 | 180k | if (option != (char *) NULL) |
448 | 0 | quantum_info->maximum=StringToDouble(option,(char **) NULL); |
449 | 180k | if ((quantum_info->minimum == 0.0) && (quantum_info->maximum == 0.0)) |
450 | 0 | quantum_info->scale=0.0; |
451 | 180k | else |
452 | 180k | if (quantum_info->minimum == quantum_info->maximum) |
453 | 0 | { |
454 | 0 | quantum_info->scale=(double) QuantumRange/quantum_info->minimum; |
455 | 0 | quantum_info->minimum=0.0; |
456 | 0 | } |
457 | 180k | else |
458 | 180k | quantum_info->scale=(double) QuantumRange/(quantum_info->maximum- |
459 | 180k | quantum_info->minimum); |
460 | 180k | option=GetImageOption(image_info,"quantum:scale"); |
461 | 180k | if (option != (char *) NULL) |
462 | 0 | quantum_info->scale=StringToDouble(option,(char **) NULL); |
463 | 180k | option=GetImageOption(image_info,"quantum:polarity"); |
464 | 180k | if (option != (char *) NULL) |
465 | 0 | quantum_info->min_is_white=LocaleCompare(option,"min-is-white") == 0 ? |
466 | 0 | MagickTrue : MagickFalse; |
467 | 180k | quantum_info->endian=image_info->endian; |
468 | 180k | ResetQuantumState(quantum_info); |
469 | 180k | } |
470 | | |
471 | | /* |
472 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
473 | | % % |
474 | | % % |
475 | | % % |
476 | | % G e t Q u a n t u m P i x e l s % |
477 | | % % |
478 | | % % |
479 | | % % |
480 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
481 | | % |
482 | | % GetQuantumPixels() returns the quantum pixels. |
483 | | % |
484 | | % The format of the GetQuantumPixels method is: |
485 | | % |
486 | | % unsigned char *QuantumPixels GetQuantumPixels( |
487 | | % const QuantumInfo *quantum_info) |
488 | | % |
489 | | % A description of each parameter follows: |
490 | | % |
491 | | % o image: the image. |
492 | | % |
493 | | */ |
494 | | MagickExport unsigned char *GetQuantumPixels(const QuantumInfo *quantum_info) |
495 | 86.3k | { |
496 | 86.3k | const int |
497 | 86.3k | id = GetOpenMPThreadId(); |
498 | | |
499 | 86.3k | assert(quantum_info != (QuantumInfo *) NULL); |
500 | 86.3k | assert(quantum_info->signature == MagickCoreSignature); |
501 | 86.3k | return((unsigned char *) GetVirtualMemoryBlob(quantum_info->pixels[id])); |
502 | 86.3k | } |
503 | | |
504 | | /* |
505 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
506 | | % % |
507 | | % % |
508 | | % % |
509 | | % G e t Q u a n t u m T y p e % |
510 | | % % |
511 | | % % |
512 | | % % |
513 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
514 | | % |
515 | | % GetQuantumType() returns the quantum type of the image. |
516 | | % |
517 | | % The format of the GetQuantumType method is: |
518 | | % |
519 | | % QuantumType GetQuantumType(Image *image,ExceptionInfo *exception) |
520 | | % |
521 | | % A description of each parameter follows: |
522 | | % |
523 | | % o image: the image. |
524 | | % |
525 | | % o exception: return any errors or warnings in this structure. |
526 | | % |
527 | | */ |
528 | | MagickExport QuantumType GetQuantumType(Image *image,ExceptionInfo *exception) |
529 | 10.0k | { |
530 | 10.0k | QuantumType |
531 | 10.0k | quantum_type; |
532 | | |
533 | 10.0k | assert(image != (Image *) NULL); |
534 | 10.0k | assert(image->signature == MagickCoreSignature); |
535 | 10.0k | if (IsEventLogging() != MagickFalse) |
536 | 0 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
537 | 10.0k | (void) exception; |
538 | 10.0k | quantum_type=RGBQuantum; |
539 | 10.0k | if (image->alpha_trait != UndefinedPixelTrait) |
540 | 1.29k | quantum_type=RGBAQuantum; |
541 | 10.0k | if (image->colorspace == CMYKColorspace) |
542 | 1.64k | { |
543 | 1.64k | quantum_type=CMYKQuantum; |
544 | 1.64k | if (image->alpha_trait != UndefinedPixelTrait) |
545 | 368 | quantum_type=CMYKAQuantum; |
546 | 1.64k | } |
547 | 10.0k | if (IsGrayColorspace(image->colorspace) != MagickFalse) |
548 | 2.80k | { |
549 | 2.80k | quantum_type=GrayQuantum; |
550 | 2.80k | if (image->alpha_trait != UndefinedPixelTrait) |
551 | 247 | quantum_type=GrayAlphaQuantum; |
552 | 2.80k | } |
553 | 10.0k | if (image->storage_class == PseudoClass) |
554 | 403 | { |
555 | 403 | quantum_type=IndexQuantum; |
556 | 403 | if (image->alpha_trait != UndefinedPixelTrait) |
557 | 155 | quantum_type=IndexAlphaQuantum; |
558 | 403 | } |
559 | 10.0k | if (image->number_meta_channels != 0) |
560 | 355 | quantum_type=MultispectralQuantum; |
561 | 10.0k | return(quantum_type); |
562 | 10.0k | } |
563 | | |
564 | | /* |
565 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
566 | | % % |
567 | | % % |
568 | | % % |
569 | | + R e s e t Q u a n t u m S t a t e % |
570 | | % % |
571 | | % % |
572 | | % % |
573 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
574 | | % |
575 | | % ResetQuantumState() resets the quantum state. |
576 | | % |
577 | | % The format of the ResetQuantumState method is: |
578 | | % |
579 | | % void ResetQuantumState(QuantumInfo *quantum_info) |
580 | | % |
581 | | % A description of each parameter follows: |
582 | | % |
583 | | % o quantum_info: the quantum info. |
584 | | % |
585 | | */ |
586 | | MagickPrivate void ResetQuantumState(QuantumInfo *quantum_info) |
587 | 11.5M | { |
588 | 11.5M | static const unsigned int mask[32] = |
589 | 11.5M | { |
590 | 11.5M | 0x00000000U, 0x00000001U, 0x00000003U, 0x00000007U, 0x0000000fU, |
591 | 11.5M | 0x0000001fU, 0x0000003fU, 0x0000007fU, 0x000000ffU, 0x000001ffU, |
592 | 11.5M | 0x000003ffU, 0x000007ffU, 0x00000fffU, 0x00001fffU, 0x00003fffU, |
593 | 11.5M | 0x00007fffU, 0x0000ffffU, 0x0001ffffU, 0x0003ffffU, 0x0007ffffU, |
594 | 11.5M | 0x000fffffU, 0x001fffffU, 0x003fffffU, 0x007fffffU, 0x00ffffffU, |
595 | 11.5M | 0x01ffffffU, 0x03ffffffU, 0x07ffffffU, 0x0fffffffU, 0x1fffffffU, |
596 | 11.5M | 0x3fffffffU, 0x7fffffffU |
597 | 11.5M | }; |
598 | | |
599 | 11.5M | assert(quantum_info != (QuantumInfo *) NULL); |
600 | 11.5M | assert(quantum_info->signature == MagickCoreSignature); |
601 | 11.5M | quantum_info->state.inverse_scale=1.0; |
602 | 11.5M | if (fabs(quantum_info->scale) >= MagickEpsilon) |
603 | 11.5M | quantum_info->state.inverse_scale/=quantum_info->scale; |
604 | 11.5M | quantum_info->state.pixel=0U; |
605 | 11.5M | quantum_info->state.bits=0U; |
606 | 11.5M | quantum_info->state.mask=mask; |
607 | 11.5M | } |
608 | | |
609 | | /* |
610 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
611 | | % % |
612 | | % % |
613 | | % % |
614 | | % S e t Q u a n t u m F o r m a t % |
615 | | % % |
616 | | % % |
617 | | % % |
618 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
619 | | % |
620 | | % SetQuantumAlphaType() sets the quantum format. |
621 | | % |
622 | | % The format of the SetQuantumAlphaType method is: |
623 | | % |
624 | | % void SetQuantumAlphaType(QuantumInfo *quantum_info, |
625 | | % const QuantumAlphaType type) |
626 | | % |
627 | | % A description of each parameter follows: |
628 | | % |
629 | | % o quantum_info: the quantum info. |
630 | | % |
631 | | % o type: the alpha type (e.g. associate). |
632 | | % |
633 | | */ |
634 | | MagickExport void SetQuantumAlphaType(QuantumInfo *quantum_info, |
635 | | const QuantumAlphaType type) |
636 | 5.06k | { |
637 | 5.06k | assert(quantum_info != (QuantumInfo *) NULL); |
638 | 5.06k | assert(quantum_info->signature == MagickCoreSignature); |
639 | 5.06k | quantum_info->alpha_type=type; |
640 | 5.06k | } |
641 | | |
642 | | /* |
643 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
644 | | % % |
645 | | % % |
646 | | % % |
647 | | % S e t Q u a n t u m D e p t h % |
648 | | % % |
649 | | % % |
650 | | % % |
651 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
652 | | % |
653 | | % SetQuantumDepth() sets the quantum depth. |
654 | | % |
655 | | % The format of the SetQuantumDepth method is: |
656 | | % |
657 | | % MagickBooleanType SetQuantumDepth(const Image *image, |
658 | | % QuantumInfo *quantum_info,const size_t depth) |
659 | | % |
660 | | % A description of each parameter follows: |
661 | | % |
662 | | % o image: the image. |
663 | | % |
664 | | % o quantum_info: the quantum info. |
665 | | % |
666 | | % o depth: the quantum depth. |
667 | | % |
668 | | */ |
669 | | MagickExport MagickBooleanType SetQuantumDepth(const Image *image, |
670 | | QuantumInfo *quantum_info,const size_t depth) |
671 | 196k | { |
672 | | /* |
673 | | Allocate the quantum pixel buffer. |
674 | | */ |
675 | 196k | assert(image != (Image *) NULL); |
676 | 196k | assert(image->signature == MagickCoreSignature); |
677 | 196k | assert(quantum_info != (QuantumInfo *) NULL); |
678 | 196k | assert(quantum_info->signature == MagickCoreSignature); |
679 | 196k | if (IsEventLogging() != MagickFalse) |
680 | 0 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
681 | 196k | quantum_info->depth=MagickMin(depth,64); |
682 | 196k | if (quantum_info->format == FloatingPointQuantumFormat) |
683 | 1.39k | { |
684 | 1.39k | if (quantum_info->depth > 32) |
685 | 598 | quantum_info->depth=64; |
686 | 792 | else |
687 | 792 | if (quantum_info->depth > 24) |
688 | 566 | quantum_info->depth=32; |
689 | 226 | else |
690 | 226 | if (quantum_info->depth > 16) |
691 | 0 | quantum_info->depth=24; |
692 | 226 | else |
693 | 226 | quantum_info->depth=16; |
694 | 1.39k | } |
695 | 196k | return(SetQuantumExtent(image,quantum_info)); |
696 | 196k | } |
697 | | |
698 | | /* |
699 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
700 | | % % |
701 | | % % |
702 | | % % |
703 | | % S e t Q u a n t u m E n d i a n % |
704 | | % % |
705 | | % % |
706 | | % % |
707 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
708 | | % |
709 | | % SetQuantumEndian() sets the quantum endian. |
710 | | % |
711 | | % The endian of the SetQuantumEndian method is: |
712 | | % |
713 | | % MagickBooleanType SetQuantumEndian(const Image *image, |
714 | | % QuantumInfo *quantum_info,const EndianType endian) |
715 | | % |
716 | | % A description of each parameter follows: |
717 | | % |
718 | | % o image: the image. |
719 | | % |
720 | | % o quantum_info: the quantum info. |
721 | | % |
722 | | % o endian: the quantum endian. |
723 | | % |
724 | | */ |
725 | | MagickExport MagickBooleanType SetQuantumEndian(const Image *image, |
726 | | QuantumInfo *quantum_info,const EndianType endian) |
727 | 102k | { |
728 | 102k | assert(image != (Image *) NULL); |
729 | 102k | assert(image->signature == MagickCoreSignature); |
730 | 102k | assert(quantum_info != (QuantumInfo *) NULL); |
731 | 102k | assert(quantum_info->signature == MagickCoreSignature); |
732 | 102k | if (IsEventLogging() != MagickFalse) |
733 | 0 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
734 | 102k | quantum_info->endian=endian; |
735 | 102k | return(SetQuantumExtent(image,quantum_info)); |
736 | 102k | } |
737 | | |
738 | | /* |
739 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
740 | | % % |
741 | | % % |
742 | | % % |
743 | | % S e t Q u a n t u m E x t e n t % |
744 | | % % |
745 | | % % |
746 | | % % |
747 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
748 | | % |
749 | | % SetQuantumExtent() sets the quantum pixel buffer extent. |
750 | | % |
751 | | % The format of the SetQuantumExtent method is: |
752 | | % |
753 | | % MagickBooleanType SetQuantumExtent(Image *image, |
754 | | % QuantumInfo *quantum_info) |
755 | | % |
756 | | % A description of each parameter follows: |
757 | | % |
758 | | % o image: the image. |
759 | | % |
760 | | % o quantum_info: the quantum info. |
761 | | % |
762 | | */ |
763 | | MagickExport MagickBooleanType SetQuantumExtent(const Image *image, |
764 | | QuantumInfo *quantum_info) |
765 | 367k | { |
766 | 367k | size_t |
767 | 367k | extent, |
768 | 367k | quantum; |
769 | | |
770 | | /* |
771 | | Speculative allocation since we don't yet know the quantum type. |
772 | | */ |
773 | 367k | assert(image != (Image *) NULL); |
774 | 367k | assert(image->signature == MagickCoreSignature); |
775 | 367k | assert(quantum_info != (QuantumInfo *) NULL); |
776 | 367k | assert(quantum_info->signature == MagickCoreSignature); |
777 | 367k | quantum=(GetPixelChannels(image)+quantum_info->pad+3)* |
778 | 367k | ((quantum_info->depth+7)/8)*sizeof(double); |
779 | 367k | extent=MagickMax(image->columns,image->rows)*quantum; |
780 | 367k | if ((MagickMax(image->columns,image->rows) != 0) && |
781 | 367k | (quantum != (extent/MagickMax(image->columns,image->rows)))) |
782 | 0 | return(MagickFalse); |
783 | 367k | if (quantum_info->pixels != (MemoryInfo **) NULL) |
784 | 186k | { |
785 | 186k | if (extent <= quantum_info->extent) |
786 | 174k | return(MagickTrue); |
787 | 11.5k | DestroyQuantumPixels(quantum_info); |
788 | 11.5k | } |
789 | 192k | return(AcquireQuantumPixels(quantum_info,extent)); |
790 | 367k | } |
791 | | |
792 | | /* |
793 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
794 | | % % |
795 | | % % |
796 | | % % |
797 | | % S e t Q u a n t u m F o r m a t % |
798 | | % % |
799 | | % % |
800 | | % % |
801 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
802 | | % |
803 | | % SetQuantumFormat() sets the quantum format. |
804 | | % |
805 | | % The format of the SetQuantumFormat method is: |
806 | | % |
807 | | % MagickBooleanType SetQuantumFormat(const Image *image, |
808 | | % QuantumInfo *quantum_info,const QuantumFormatType format) |
809 | | % |
810 | | % A description of each parameter follows: |
811 | | % |
812 | | % o image: the image. |
813 | | % |
814 | | % o quantum_info: the quantum info. |
815 | | % |
816 | | % o format: the quantum format. |
817 | | % |
818 | | */ |
819 | | MagickExport MagickBooleanType SetQuantumFormat(const Image *image, |
820 | | QuantumInfo *quantum_info,const QuantumFormatType format) |
821 | 59.2k | { |
822 | 59.2k | assert(image != (Image *) NULL); |
823 | 59.2k | assert(image->signature == MagickCoreSignature); |
824 | 59.2k | assert(quantum_info != (QuantumInfo *) NULL); |
825 | 59.2k | assert(quantum_info->signature == MagickCoreSignature); |
826 | 59.2k | if (IsEventLogging() != MagickFalse) |
827 | 0 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
828 | 59.2k | quantum_info->format=format; |
829 | 59.2k | return(SetQuantumExtent(image,quantum_info)); |
830 | 59.2k | } |
831 | | |
832 | | /* |
833 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
834 | | % % |
835 | | % % |
836 | | % % |
837 | | % S e t Q u a n t u m I m a g e T y p e % |
838 | | % % |
839 | | % % |
840 | | % % |
841 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
842 | | % |
843 | | % SetQuantumImageType() sets the image type based on the quantum type. |
844 | | % |
845 | | % The format of the SetQuantumImageType method is: |
846 | | % |
847 | | % void ImageType SetQuantumImageType(Image *image, |
848 | | % const QuantumType quantum_type) |
849 | | % |
850 | | % A description of each parameter follows: |
851 | | % |
852 | | % o image: the image. |
853 | | % |
854 | | % o quantum_type: Declare which pixel components to transfer (red, green, |
855 | | % blue, opacity, RGB, or RGBA). |
856 | | % |
857 | | */ |
858 | | MagickExport void SetQuantumImageType(Image *image, |
859 | | const QuantumType quantum_type) |
860 | 80.7k | { |
861 | 80.7k | assert(image != (Image *) NULL); |
862 | 80.7k | assert(image->signature == MagickCoreSignature); |
863 | 80.7k | if (IsEventLogging() != MagickFalse) |
864 | 0 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
865 | 80.7k | switch (quantum_type) |
866 | 80.7k | { |
867 | 1.43k | case IndexQuantum: |
868 | 1.84k | case IndexAlphaQuantum: |
869 | 1.84k | { |
870 | 1.84k | image->type=PaletteType; |
871 | 1.84k | break; |
872 | 1.43k | } |
873 | 36.6k | case GrayQuantum: |
874 | 38.4k | case GrayAlphaQuantum: |
875 | 38.4k | { |
876 | 38.4k | image->type=GrayscaleType; |
877 | 38.4k | if (image->depth == 1) |
878 | 18.2k | image->type=BilevelType; |
879 | 38.4k | break; |
880 | 36.6k | } |
881 | 0 | case CyanQuantum: |
882 | 0 | case MagentaQuantum: |
883 | 0 | case YellowQuantum: |
884 | 0 | case BlackQuantum: |
885 | 5.02k | case CMYKQuantum: |
886 | 6.77k | case CMYKAQuantum: |
887 | 11.0k | case MultispectralQuantum: |
888 | 11.0k | { |
889 | 11.0k | image->type=ColorSeparationType; |
890 | 11.0k | break; |
891 | 6.77k | } |
892 | 29.4k | default: |
893 | 29.4k | { |
894 | 29.4k | image->type=TrueColorType; |
895 | 29.4k | break; |
896 | 6.77k | } |
897 | 80.7k | } |
898 | 80.7k | } |
899 | | |
900 | | /* |
901 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
902 | | % % |
903 | | % % |
904 | | % % |
905 | | % S e t Q u a n t u m M e t a C h a n n e l % |
906 | | % % |
907 | | % % |
908 | | % % |
909 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
910 | | % |
911 | | % SetQuantumMetaChannel() sets the quantum meta-channel that will exported or |
912 | | % imported when the quantum type is MultispectralQuantum. To unset the |
913 | | % meta-channel, set the meta-channel to -1. |
914 | | % |
915 | | % The format of the SetQuantumMetaChannel method is: |
916 | | % |
917 | | % void SetQuantumMetaChannel(const Image *image,QuantumInfo *quantum_info, |
918 | | % const ssize_t meta_channel) |
919 | | % |
920 | | % A description of each parameter follows: |
921 | | % |
922 | | % o image: the image. |
923 | | % |
924 | | % o quantum_info: the quantum info. |
925 | | % |
926 | | % o meta_channel: the meta channel. |
927 | | % |
928 | | */ |
929 | | MagickExport MagickBooleanType SetQuantumMetaChannel(const Image *image, |
930 | | QuantumInfo *quantum_info, const ssize_t meta_channel) |
931 | 26.4k | { |
932 | 26.4k | assert(quantum_info != (QuantumInfo *) NULL); |
933 | 26.4k | assert(quantum_info->signature == MagickCoreSignature); |
934 | 26.4k | if ((meta_channel < -1) || |
935 | 26.4k | (meta_channel >= (ssize_t) image->number_meta_channels)) |
936 | 262 | return(MagickFalse); |
937 | 26.2k | quantum_info->meta_channel=meta_channel+1; |
938 | 26.2k | return(MagickTrue); |
939 | 26.4k | } |
940 | | |
941 | | /* |
942 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
943 | | % % |
944 | | % % |
945 | | % % |
946 | | % S e t Q u a n t u m P a c k % |
947 | | % % |
948 | | % % |
949 | | % % |
950 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
951 | | % |
952 | | % SetQuantumPack() sets the quantum pack flag. |
953 | | % |
954 | | % The format of the SetQuantumPack method is: |
955 | | % |
956 | | % void SetQuantumPack(QuantumInfo *quantum_info, |
957 | | % const MagickBooleanType pack) |
958 | | % |
959 | | % A description of each parameter follows: |
960 | | % |
961 | | % o quantum_info: the quantum info. |
962 | | % |
963 | | % o pack: the pack flag. |
964 | | % |
965 | | */ |
966 | | MagickExport void SetQuantumPack(QuantumInfo *quantum_info, |
967 | | const MagickBooleanType pack) |
968 | 7.68k | { |
969 | 7.68k | assert(quantum_info != (QuantumInfo *) NULL); |
970 | 7.68k | assert(quantum_info->signature == MagickCoreSignature); |
971 | 7.68k | quantum_info->pack=pack; |
972 | 7.68k | } |
973 | | |
974 | | /* |
975 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
976 | | % % |
977 | | % % |
978 | | % % |
979 | | % S e t Q u a n t u m P a d % |
980 | | % % |
981 | | % % |
982 | | % % |
983 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
984 | | % |
985 | | % SetQuantumPad() sets the quantum pad. |
986 | | % |
987 | | % The format of the SetQuantumPad method is: |
988 | | % |
989 | | % MagickBooleanType SetQuantumPad(const Image *image, |
990 | | % QuantumInfo *quantum_info,const size_t pad) |
991 | | % |
992 | | % A description of each parameter follows: |
993 | | % |
994 | | % o image: the image. |
995 | | % |
996 | | % o quantum_info: the quantum info. |
997 | | % |
998 | | % o pad: the quantum pad. |
999 | | % |
1000 | | */ |
1001 | | MagickExport MagickBooleanType SetQuantumPad(const Image *image, |
1002 | | QuantumInfo *quantum_info,const size_t pad) |
1003 | 7.85k | { |
1004 | 7.85k | assert(image != (Image *) NULL); |
1005 | 7.85k | assert(image->signature == MagickCoreSignature); |
1006 | 7.85k | assert(quantum_info != (QuantumInfo *) NULL); |
1007 | 7.85k | assert(quantum_info->signature == MagickCoreSignature); |
1008 | 7.85k | if (IsEventLogging() != MagickFalse) |
1009 | 0 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
1010 | 7.85k | if (pad >= (MAGICK_SSIZE_MAX/GetImageChannels(image))) |
1011 | 0 | return(MagickFalse); |
1012 | 7.85k | quantum_info->pad=pad; |
1013 | 7.85k | return(SetQuantumExtent(image,quantum_info)); |
1014 | 7.85k | } |
1015 | | |
1016 | | /* |
1017 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1018 | | % % |
1019 | | % % |
1020 | | % % |
1021 | | % S e t Q u a n t u m M i n I s W h i t e % |
1022 | | % % |
1023 | | % % |
1024 | | % % |
1025 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1026 | | % |
1027 | | % SetQuantumMinIsWhite() sets the quantum min-is-white flag. |
1028 | | % |
1029 | | % The format of the SetQuantumMinIsWhite method is: |
1030 | | % |
1031 | | % void SetQuantumMinIsWhite(QuantumInfo *quantum_info, |
1032 | | % const MagickBooleanType min_is_white) |
1033 | | % |
1034 | | % A description of each parameter follows: |
1035 | | % |
1036 | | % o quantum_info: the quantum info. |
1037 | | % |
1038 | | % o min_is_white: the min-is-white flag. |
1039 | | % |
1040 | | */ |
1041 | | MagickExport void SetQuantumMinIsWhite(QuantumInfo *quantum_info, |
1042 | | const MagickBooleanType min_is_white) |
1043 | 16.5k | { |
1044 | 16.5k | assert(quantum_info != (QuantumInfo *) NULL); |
1045 | 16.5k | assert(quantum_info->signature == MagickCoreSignature); |
1046 | 16.5k | quantum_info->min_is_white=min_is_white; |
1047 | 16.5k | } |
1048 | | |
1049 | | /* |
1050 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1051 | | % % |
1052 | | % % |
1053 | | % % |
1054 | | % S e t Q u a n t u m Q u a n t u m % |
1055 | | % % |
1056 | | % % |
1057 | | % % |
1058 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1059 | | % |
1060 | | % SetQuantumQuantum() sets the quantum quantum. |
1061 | | % |
1062 | | % The format of the SetQuantumQuantum method is: |
1063 | | % |
1064 | | % void SetQuantumQuantum(QuantumInfo *quantum_info,const size_t quantum) |
1065 | | % |
1066 | | % A description of each parameter follows: |
1067 | | % |
1068 | | % o quantum_info: the quantum info. |
1069 | | % |
1070 | | % o quantum: the quantum quantum. |
1071 | | % |
1072 | | */ |
1073 | | MagickExport void SetQuantumQuantum(QuantumInfo *quantum_info, |
1074 | | const size_t quantum) |
1075 | 7.68k | { |
1076 | 7.68k | assert(quantum_info != (QuantumInfo *) NULL); |
1077 | 7.68k | assert(quantum_info->signature == MagickCoreSignature); |
1078 | 7.68k | quantum_info->quantum=quantum; |
1079 | 7.68k | } |
1080 | | |
1081 | | /* |
1082 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1083 | | % % |
1084 | | % % |
1085 | | % % |
1086 | | % S e t Q u a n t u m S c a l e % |
1087 | | % % |
1088 | | % % |
1089 | | % % |
1090 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1091 | | % |
1092 | | % SetQuantumScale() sets the quantum scale. |
1093 | | % |
1094 | | % The format of the SetQuantumScale method is: |
1095 | | % |
1096 | | % void SetQuantumScale(QuantumInfo *quantum_info,const double scale) |
1097 | | % |
1098 | | % A description of each parameter follows: |
1099 | | % |
1100 | | % o quantum_info: the quantum info. |
1101 | | % |
1102 | | % o scale: the quantum scale. |
1103 | | % |
1104 | | */ |
1105 | | MagickExport void SetQuantumScale(QuantumInfo *quantum_info,const double scale) |
1106 | 2.73k | { |
1107 | 2.73k | assert(quantum_info != (QuantumInfo *) NULL); |
1108 | 2.73k | assert(quantum_info->signature == MagickCoreSignature); |
1109 | 2.73k | quantum_info->scale=scale; |
1110 | 2.73k | } |