/src/imagemagick/MagickCore/quantum-export.c
Line | Count | Source (jump to first uncovered line) |
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 | | % EEEEE X X PPPP OOO RRRR TTTTT % |
13 | | % E X X P P O O R R T % |
14 | | % EEE X PPPP O O RRRR T % |
15 | | % E X X P O O R R T % |
16 | | % EEEEE X X P OOO R R T % |
17 | | % % |
18 | | % MagickCore Methods to Export Quantum Pixels % |
19 | | % % |
20 | | % Software Design % |
21 | | % Cristy % |
22 | | % October 1998 % |
23 | | % % |
24 | | % % |
25 | | % Copyright @ 1999 ImageMagick Studio LLC, a non-profit organization % |
26 | | % dedicated to making software imaging solutions freely available. % |
27 | | % % |
28 | | % You may not use this file except in compliance with the License. You may % |
29 | | % obtain a copy of the License at % |
30 | | % % |
31 | | % https://imagemagick.org/script/license.php % |
32 | | % % |
33 | | % Unless required by applicable law or agreed to in writing, software % |
34 | | % distributed under the License is distributed on an "AS IS" BASIS, % |
35 | | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % |
36 | | % See the License for the specific language governing permissions and % |
37 | | % limitations under the License. % |
38 | | % % |
39 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
40 | | % |
41 | | % |
42 | | */ |
43 | | |
44 | | /* |
45 | | Include declarations. |
46 | | */ |
47 | | #include "MagickCore/studio.h" |
48 | | #include "MagickCore/property.h" |
49 | | #include "MagickCore/blob.h" |
50 | | #include "MagickCore/blob-private.h" |
51 | | #include "MagickCore/color-private.h" |
52 | | #include "MagickCore/exception.h" |
53 | | #include "MagickCore/exception-private.h" |
54 | | #include "MagickCore/cache.h" |
55 | | #include "MagickCore/constitute.h" |
56 | | #include "MagickCore/delegate.h" |
57 | | #include "MagickCore/geometry.h" |
58 | | #include "MagickCore/list.h" |
59 | | #include "MagickCore/magick.h" |
60 | | #include "MagickCore/memory_.h" |
61 | | #include "MagickCore/monitor.h" |
62 | | #include "MagickCore/option.h" |
63 | | #include "MagickCore/pixel.h" |
64 | | #include "MagickCore/pixel-accessor.h" |
65 | | #include "MagickCore/quantum.h" |
66 | | #include "MagickCore/quantum-private.h" |
67 | | #include "MagickCore/resource_.h" |
68 | | #include "MagickCore/semaphore.h" |
69 | | #include "MagickCore/statistic.h" |
70 | | #include "MagickCore/stream.h" |
71 | | #include "MagickCore/string_.h" |
72 | | #include "MagickCore/utility.h" |
73 | | |
74 | | /* |
75 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
76 | | % % |
77 | | % % |
78 | | % % |
79 | | + E x p o r t Q u a n t u m P i x e l s % |
80 | | % % |
81 | | % % |
82 | | % % |
83 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
84 | | % |
85 | | % ExportQuantumPixels() transfers one or more pixel components from the image |
86 | | % pixel cache to a user supplied buffer. The pixels are returned in network |
87 | | % byte order. It returns the number of exported pixels. |
88 | | % |
89 | | % The format of the ExportQuantumPixels method is: |
90 | | % |
91 | | % size_t ExportQuantumPixels(const Image *image,CacheView *image_view, |
92 | | % QuantumInfo *quantum_info,const QuantumType quantum_type, |
93 | | % unsigned char *magick_restrict pixels,ExceptionInfo *exception) |
94 | | % |
95 | | % A description of each parameter follows: |
96 | | % |
97 | | % o image: the image. |
98 | | % |
99 | | % o image_view: the image cache view. |
100 | | % |
101 | | % o quantum_info: the quantum info. |
102 | | % |
103 | | % o quantum_type: Declare which pixel components to transfer (RGB, RGBA, |
104 | | % etc). |
105 | | % |
106 | | % o pixels: The components are transferred to this buffer. |
107 | | % |
108 | | % o exception: return any errors or warnings in this structure. |
109 | | % |
110 | | */ |
111 | | |
112 | | static inline unsigned char *PopQuantumDoublePixel(QuantumInfo *quantum_info, |
113 | | const double pixel,unsigned char *magick_restrict pixels) |
114 | 8.07k | { |
115 | 8.07k | double |
116 | 8.07k | *p; |
117 | | |
118 | 8.07k | unsigned char |
119 | 8.07k | quantum[8]; |
120 | | |
121 | 8.07k | (void) memset(quantum,0,sizeof(quantum)); |
122 | 8.07k | p=(double *) quantum; |
123 | 8.07k | *p=(double) (pixel*quantum_info->state.inverse_scale+quantum_info->minimum); |
124 | 8.07k | if (quantum_info->endian == LSBEndian) |
125 | 6.70k | { |
126 | 6.70k | *pixels++=quantum[0]; |
127 | 6.70k | *pixels++=quantum[1]; |
128 | 6.70k | *pixels++=quantum[2]; |
129 | 6.70k | *pixels++=quantum[3]; |
130 | 6.70k | *pixels++=quantum[4]; |
131 | 6.70k | *pixels++=quantum[5]; |
132 | 6.70k | *pixels++=quantum[6]; |
133 | 6.70k | *pixels++=quantum[7]; |
134 | 6.70k | return(pixels); |
135 | 6.70k | } |
136 | 1.36k | *pixels++=quantum[7]; |
137 | 1.36k | *pixels++=quantum[6]; |
138 | 1.36k | *pixels++=quantum[5]; |
139 | 1.36k | *pixels++=quantum[4]; |
140 | 1.36k | *pixels++=quantum[3]; |
141 | 1.36k | *pixels++=quantum[2]; |
142 | 1.36k | *pixels++=quantum[1]; |
143 | 1.36k | *pixels++=quantum[0]; |
144 | 1.36k | return(pixels); |
145 | 8.07k | } |
146 | | |
147 | | static inline unsigned char *PopQuantumFloatPixel(QuantumInfo *quantum_info, |
148 | | const float pixel,unsigned char *magick_restrict pixels) |
149 | 473k | { |
150 | 473k | float |
151 | 473k | *p; |
152 | | |
153 | 473k | unsigned char |
154 | 473k | quantum[4]; |
155 | | |
156 | 473k | (void) memset(quantum,0,sizeof(quantum)); |
157 | 473k | p=(float *) quantum; |
158 | 473k | *p=(float) ((double) pixel*quantum_info->state.inverse_scale+ |
159 | 473k | quantum_info->minimum); |
160 | 473k | if (quantum_info->endian == LSBEndian) |
161 | 191k | { |
162 | 191k | *pixels++=quantum[0]; |
163 | 191k | *pixels++=quantum[1]; |
164 | 191k | *pixels++=quantum[2]; |
165 | 191k | *pixels++=quantum[3]; |
166 | 191k | return(pixels); |
167 | 191k | } |
168 | 281k | *pixels++=quantum[3]; |
169 | 281k | *pixels++=quantum[2]; |
170 | 281k | *pixels++=quantum[1]; |
171 | 281k | *pixels++=quantum[0]; |
172 | 281k | return(pixels); |
173 | 473k | } |
174 | | |
175 | | static inline unsigned char *PopQuantumPixel(QuantumInfo *quantum_info, |
176 | | const QuantumAny pixel,unsigned char *magick_restrict pixels) |
177 | 2.74M | { |
178 | 2.74M | ssize_t |
179 | 2.74M | i; |
180 | | |
181 | 2.74M | size_t |
182 | 2.74M | quantum_bits; |
183 | | |
184 | 2.74M | if (quantum_info->state.bits == 0UL) |
185 | 56.5k | quantum_info->state.bits=8U; |
186 | 6.77M | for (i=(ssize_t) quantum_info->depth; i > 0L; ) |
187 | 4.03M | { |
188 | 4.03M | quantum_bits=(size_t) i; |
189 | 4.03M | if (quantum_bits > quantum_info->state.bits) |
190 | 1.28M | quantum_bits=quantum_info->state.bits; |
191 | 4.03M | i-=(ssize_t) quantum_bits; |
192 | 4.03M | if (i < 0) |
193 | 0 | i=0; |
194 | 4.03M | if (quantum_info->state.bits == 8UL) |
195 | 1.80M | *pixels='\0'; |
196 | 4.03M | quantum_info->state.bits-=quantum_bits; |
197 | 4.03M | *pixels|=(((pixel >> i) &~ (((QuantumAny) ~0UL) << quantum_bits)) << |
198 | 4.03M | quantum_info->state.bits); |
199 | 4.03M | if (quantum_info->state.bits == 0UL) |
200 | 1.77M | { |
201 | 1.77M | pixels++; |
202 | 1.77M | quantum_info->state.bits=8UL; |
203 | 1.77M | } |
204 | 4.03M | } |
205 | 2.74M | return(pixels); |
206 | 2.74M | } |
207 | | |
208 | | static inline unsigned char *PopQuantumLongPixel(QuantumInfo *quantum_info, |
209 | | const size_t pixel,unsigned char *magick_restrict pixels) |
210 | 0 | { |
211 | 0 | ssize_t |
212 | 0 | i; |
213 | |
|
214 | 0 | size_t |
215 | 0 | quantum_bits; |
216 | |
|
217 | 0 | if (quantum_info->state.bits == 0U) |
218 | 0 | quantum_info->state.bits=32UL; |
219 | 0 | for (i=(ssize_t) quantum_info->depth; i > 0; ) |
220 | 0 | { |
221 | 0 | quantum_bits=(size_t) i; |
222 | 0 | if (quantum_bits > quantum_info->state.bits) |
223 | 0 | quantum_bits=quantum_info->state.bits; |
224 | 0 | quantum_info->state.pixel|=(((pixel >> ((ssize_t) quantum_info->depth-i)) & |
225 | 0 | quantum_info->state.mask[quantum_bits]) << (32U- |
226 | 0 | quantum_info->state.bits)); |
227 | 0 | i-=(ssize_t) quantum_bits; |
228 | 0 | quantum_info->state.bits-=quantum_bits; |
229 | 0 | if (quantum_info->state.bits == 0U) |
230 | 0 | { |
231 | 0 | pixels=PopLongPixel(quantum_info->endian,quantum_info->state.pixel, |
232 | 0 | pixels); |
233 | 0 | quantum_info->state.pixel=0U; |
234 | 0 | quantum_info->state.bits=32U; |
235 | 0 | } |
236 | 0 | } |
237 | 0 | return(pixels); |
238 | 0 | } |
239 | | |
240 | | static void ExportAlphaQuantum(const Image *image,QuantumInfo *quantum_info, |
241 | | const MagickSizeType number_pixels,const Quantum *magick_restrict p, |
242 | | unsigned char *magick_restrict q) |
243 | 0 | { |
244 | 0 | QuantumAny |
245 | 0 | range; |
246 | |
|
247 | 0 | ssize_t |
248 | 0 | x; |
249 | |
|
250 | 0 | switch (quantum_info->depth) |
251 | 0 | { |
252 | 0 | case 8: |
253 | 0 | { |
254 | 0 | unsigned char |
255 | 0 | pixel; |
256 | |
|
257 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
258 | 0 | { |
259 | 0 | pixel=ScaleQuantumToChar(GetPixelAlpha(image,p)); |
260 | 0 | q=PopCharPixel(pixel,q); |
261 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
262 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
263 | 0 | } |
264 | 0 | break; |
265 | 0 | } |
266 | 0 | case 16: |
267 | 0 | { |
268 | 0 | unsigned short |
269 | 0 | pixel; |
270 | |
|
271 | 0 | if (quantum_info->format == FloatingPointQuantumFormat) |
272 | 0 | { |
273 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
274 | 0 | { |
275 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
276 | 0 | GetPixelAlpha(image,p)); |
277 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
278 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
279 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
280 | 0 | } |
281 | 0 | break; |
282 | 0 | } |
283 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
284 | 0 | { |
285 | 0 | pixel=ScaleQuantumToShort(GetPixelAlpha(image,p)); |
286 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
287 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
288 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
289 | 0 | } |
290 | 0 | break; |
291 | 0 | } |
292 | 0 | case 32: |
293 | 0 | { |
294 | 0 | unsigned int |
295 | 0 | pixel; |
296 | |
|
297 | 0 | if (quantum_info->format == FloatingPointQuantumFormat) |
298 | 0 | { |
299 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
300 | 0 | { |
301 | 0 | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelAlpha(image,p),q); |
302 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
303 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
304 | 0 | } |
305 | 0 | break; |
306 | 0 | } |
307 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
308 | 0 | { |
309 | 0 | pixel=ScaleQuantumToLong(GetPixelAlpha(image,p)); |
310 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
311 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
312 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
313 | 0 | } |
314 | 0 | break; |
315 | 0 | } |
316 | 0 | case 64: |
317 | 0 | { |
318 | 0 | if (quantum_info->format == FloatingPointQuantumFormat) |
319 | 0 | { |
320 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
321 | 0 | { |
322 | 0 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelAlpha(image,p),q); |
323 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
324 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
325 | 0 | } |
326 | 0 | break; |
327 | 0 | } |
328 | 0 | magick_fallthrough; |
329 | 0 | } |
330 | 0 | default: |
331 | 0 | { |
332 | 0 | range=GetQuantumRange(quantum_info->depth); |
333 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
334 | 0 | { |
335 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p), |
336 | 0 | range),q); |
337 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
338 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
339 | 0 | } |
340 | 0 | break; |
341 | 0 | } |
342 | 0 | } |
343 | 0 | } |
344 | | |
345 | | static void ExportBGRQuantum(const Image *image,QuantumInfo *quantum_info, |
346 | | const MagickSizeType number_pixels,const Quantum *magick_restrict p, |
347 | | unsigned char *magick_restrict q) |
348 | 0 | { |
349 | 0 | QuantumAny |
350 | 0 | range; |
351 | |
|
352 | 0 | ssize_t |
353 | 0 | x; |
354 | |
|
355 | 0 | ssize_t |
356 | 0 | bit; |
357 | |
|
358 | 0 | switch (quantum_info->depth) |
359 | 0 | { |
360 | 0 | case 8: |
361 | 0 | { |
362 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
363 | 0 | { |
364 | 0 | q=PopCharPixel(ScaleQuantumToChar(GetPixelBlue(image,p)),q); |
365 | 0 | q=PopCharPixel(ScaleQuantumToChar(GetPixelGreen(image,p)),q); |
366 | 0 | q=PopCharPixel(ScaleQuantumToChar(GetPixelRed(image,p)),q); |
367 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
368 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
369 | 0 | } |
370 | 0 | break; |
371 | 0 | } |
372 | 0 | case 10: |
373 | 0 | { |
374 | 0 | unsigned int |
375 | 0 | pixel; |
376 | |
|
377 | 0 | range=GetQuantumRange(quantum_info->depth); |
378 | 0 | if (quantum_info->pack == MagickFalse) |
379 | 0 | { |
380 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
381 | 0 | { |
382 | 0 | pixel=(unsigned int) ( |
383 | 0 | ScaleQuantumToAny(GetPixelRed(image,p),range) << 22 | |
384 | 0 | ScaleQuantumToAny(GetPixelGreen(image,p),range) << 12 | |
385 | 0 | ScaleQuantumToAny(GetPixelBlue(image,p),range) << 2); |
386 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
387 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
388 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
389 | 0 | } |
390 | 0 | break; |
391 | 0 | } |
392 | 0 | if (quantum_info->quantum == 32UL) |
393 | 0 | { |
394 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
395 | 0 | { |
396 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); |
397 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
398 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), |
399 | 0 | range); |
400 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
401 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); |
402 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
403 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
404 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
405 | 0 | } |
406 | 0 | break; |
407 | 0 | } |
408 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
409 | 0 | { |
410 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); |
411 | 0 | q=PopQuantumPixel(quantum_info,pixel,q); |
412 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range); |
413 | 0 | q=PopQuantumPixel(quantum_info,pixel,q); |
414 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); |
415 | 0 | q=PopQuantumPixel(quantum_info,pixel,q); |
416 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
417 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
418 | 0 | } |
419 | 0 | break; |
420 | 0 | } |
421 | 0 | case 12: |
422 | 0 | { |
423 | 0 | unsigned int |
424 | 0 | pixel; |
425 | |
|
426 | 0 | range=GetQuantumRange(quantum_info->depth); |
427 | 0 | if (quantum_info->pack == MagickFalse) |
428 | 0 | { |
429 | 0 | for (x=0; x < (ssize_t) (3*number_pixels-1); x+=2) |
430 | 0 | { |
431 | 0 | switch (x % 3) |
432 | 0 | { |
433 | 0 | default: |
434 | 0 | case 0: |
435 | 0 | { |
436 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p), |
437 | 0 | range); |
438 | 0 | break; |
439 | 0 | } |
440 | 0 | case 1: |
441 | 0 | { |
442 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), |
443 | 0 | range); |
444 | 0 | break; |
445 | 0 | } |
446 | 0 | case 2: |
447 | 0 | { |
448 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p), |
449 | 0 | range); |
450 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
451 | 0 | break; |
452 | 0 | } |
453 | 0 | } |
454 | 0 | q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel << 4), |
455 | 0 | q); |
456 | 0 | switch ((x+1) % 3) |
457 | 0 | { |
458 | 0 | default: |
459 | 0 | case 0: |
460 | 0 | { |
461 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p), |
462 | 0 | range); |
463 | 0 | break; |
464 | 0 | } |
465 | 0 | case 1: |
466 | 0 | { |
467 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), |
468 | 0 | range); |
469 | 0 | break; |
470 | 0 | } |
471 | 0 | case 2: |
472 | 0 | { |
473 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p), |
474 | 0 | range); |
475 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
476 | 0 | break; |
477 | 0 | } |
478 | 0 | } |
479 | 0 | q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel << 4), |
480 | 0 | q); |
481 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
482 | 0 | } |
483 | 0 | for (bit=0; bit < (ssize_t) (3*number_pixels % 2); bit++) |
484 | 0 | { |
485 | 0 | switch ((x+bit) % 3) |
486 | 0 | { |
487 | 0 | default: |
488 | 0 | case 0: |
489 | 0 | { |
490 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p), |
491 | 0 | range); |
492 | 0 | break; |
493 | 0 | } |
494 | 0 | case 1: |
495 | 0 | { |
496 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), |
497 | 0 | range); |
498 | 0 | break; |
499 | 0 | } |
500 | 0 | case 2: |
501 | 0 | { |
502 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p), |
503 | 0 | range); |
504 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
505 | 0 | break; |
506 | 0 | } |
507 | 0 | } |
508 | 0 | q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel << 4), |
509 | 0 | q); |
510 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
511 | 0 | } |
512 | 0 | if (bit != 0) |
513 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
514 | 0 | break; |
515 | 0 | } |
516 | 0 | if (quantum_info->quantum == 32UL) |
517 | 0 | { |
518 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
519 | 0 | { |
520 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); |
521 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
522 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), |
523 | 0 | range); |
524 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
525 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); |
526 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
527 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
528 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
529 | 0 | } |
530 | 0 | break; |
531 | 0 | } |
532 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
533 | 0 | { |
534 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); |
535 | 0 | q=PopQuantumPixel(quantum_info,pixel,q); |
536 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range); |
537 | 0 | q=PopQuantumPixel(quantum_info,pixel,q); |
538 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); |
539 | 0 | q=PopQuantumPixel(quantum_info,pixel,q); |
540 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
541 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
542 | 0 | } |
543 | 0 | break; |
544 | 0 | } |
545 | 0 | case 16: |
546 | 0 | { |
547 | 0 | unsigned short |
548 | 0 | pixel; |
549 | |
|
550 | 0 | if (quantum_info->format == FloatingPointQuantumFormat) |
551 | 0 | { |
552 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
553 | 0 | { |
554 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
555 | 0 | GetPixelBlue(image,p)); |
556 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
557 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
558 | 0 | GetPixelGreen(image,p)); |
559 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
560 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
561 | 0 | GetPixelRed(image,p)); |
562 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
563 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
564 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
565 | 0 | } |
566 | 0 | break; |
567 | 0 | } |
568 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
569 | 0 | { |
570 | 0 | pixel=ScaleQuantumToShort(GetPixelBlue(image,p)); |
571 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
572 | 0 | pixel=ScaleQuantumToShort(GetPixelGreen(image,p)); |
573 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
574 | 0 | pixel=ScaleQuantumToShort(GetPixelRed(image,p)); |
575 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
576 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
577 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
578 | 0 | } |
579 | 0 | break; |
580 | 0 | } |
581 | 0 | case 32: |
582 | 0 | { |
583 | 0 | unsigned int |
584 | 0 | pixel; |
585 | |
|
586 | 0 | if (quantum_info->format == FloatingPointQuantumFormat) |
587 | 0 | { |
588 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
589 | 0 | { |
590 | 0 | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelRed(image,p),q); |
591 | 0 | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q); |
592 | 0 | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q); |
593 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
594 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
595 | 0 | } |
596 | 0 | break; |
597 | 0 | } |
598 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
599 | 0 | { |
600 | 0 | pixel=ScaleQuantumToLong(GetPixelBlue(image,p)); |
601 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
602 | 0 | pixel=ScaleQuantumToLong(GetPixelGreen(image,p)); |
603 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
604 | 0 | pixel=ScaleQuantumToLong(GetPixelRed(image,p)); |
605 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
606 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
607 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
608 | 0 | } |
609 | 0 | break; |
610 | 0 | } |
611 | 0 | case 64: |
612 | 0 | { |
613 | 0 | if (quantum_info->format == FloatingPointQuantumFormat) |
614 | 0 | { |
615 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
616 | 0 | { |
617 | 0 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelRed(image,p),q); |
618 | 0 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q); |
619 | 0 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q); |
620 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
621 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
622 | 0 | } |
623 | 0 | break; |
624 | 0 | } |
625 | 0 | magick_fallthrough; |
626 | 0 | } |
627 | 0 | default: |
628 | 0 | { |
629 | 0 | range=GetQuantumRange(quantum_info->depth); |
630 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
631 | 0 | { |
632 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p), |
633 | 0 | range),q); |
634 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p), |
635 | 0 | range),q); |
636 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p), |
637 | 0 | range),q); |
638 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
639 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
640 | 0 | } |
641 | 0 | break; |
642 | 0 | } |
643 | 0 | } |
644 | 0 | } |
645 | | |
646 | | static void ExportBGRAQuantum(const Image *image,QuantumInfo *quantum_info, |
647 | | const MagickSizeType number_pixels,const Quantum *magick_restrict p, |
648 | | unsigned char *magick_restrict q) |
649 | 0 | { |
650 | 0 | QuantumAny |
651 | 0 | range; |
652 | |
|
653 | 0 | ssize_t |
654 | 0 | x; |
655 | |
|
656 | 0 | switch (quantum_info->depth) |
657 | 0 | { |
658 | 0 | case 8: |
659 | 0 | { |
660 | 0 | unsigned char |
661 | 0 | pixel; |
662 | |
|
663 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
664 | 0 | { |
665 | 0 | pixel=ScaleQuantumToChar(GetPixelBlue(image,p)); |
666 | 0 | q=PopCharPixel(pixel,q); |
667 | 0 | pixel=ScaleQuantumToChar(GetPixelGreen(image,p)); |
668 | 0 | q=PopCharPixel(pixel,q); |
669 | 0 | pixel=ScaleQuantumToChar(GetPixelRed(image,p)); |
670 | 0 | q=PopCharPixel(pixel,q); |
671 | 0 | pixel=ScaleQuantumToChar(GetPixelAlpha(image,p)); |
672 | 0 | q=PopCharPixel(pixel,q); |
673 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
674 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
675 | 0 | } |
676 | 0 | break; |
677 | 0 | } |
678 | 0 | case 10: |
679 | 0 | { |
680 | 0 | unsigned int |
681 | 0 | pixel; |
682 | |
|
683 | 0 | range=GetQuantumRange(quantum_info->depth); |
684 | 0 | if (quantum_info->pack == MagickFalse) |
685 | 0 | { |
686 | 0 | ssize_t |
687 | 0 | i; |
688 | |
|
689 | 0 | size_t |
690 | 0 | quantum; |
691 | |
|
692 | 0 | ssize_t |
693 | 0 | n; |
694 | |
|
695 | 0 | n=0; |
696 | 0 | quantum=0; |
697 | 0 | pixel=0; |
698 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
699 | 0 | { |
700 | 0 | for (i=0; i < 4; i++) |
701 | 0 | { |
702 | 0 | switch (i) |
703 | 0 | { |
704 | 0 | case 0: quantum=(size_t) GetPixelRed(image,p); break; |
705 | 0 | case 1: quantum=(size_t) GetPixelGreen(image,p); break; |
706 | 0 | case 2: quantum=(size_t) GetPixelBlue(image,p); break; |
707 | 0 | case 3: quantum=(size_t) GetPixelAlpha(image,p); break; |
708 | 0 | } |
709 | 0 | switch (n % 3) |
710 | 0 | { |
711 | 0 | case 0: |
712 | 0 | { |
713 | 0 | pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum, |
714 | 0 | range) << 22); |
715 | 0 | break; |
716 | 0 | } |
717 | 0 | case 1: |
718 | 0 | { |
719 | 0 | pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum, |
720 | 0 | range) << 12); |
721 | 0 | break; |
722 | 0 | } |
723 | 0 | case 2: |
724 | 0 | { |
725 | 0 | pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum, |
726 | 0 | range) << 2); |
727 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
728 | 0 | pixel=0; |
729 | 0 | break; |
730 | 0 | } |
731 | 0 | } |
732 | 0 | n++; |
733 | 0 | } |
734 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
735 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
736 | 0 | } |
737 | 0 | break; |
738 | 0 | } |
739 | 0 | if (quantum_info->quantum == 32UL) |
740 | 0 | { |
741 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
742 | 0 | { |
743 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); |
744 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
745 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), |
746 | 0 | range); |
747 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
748 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); |
749 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
750 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelAlpha(image,p), |
751 | 0 | range); |
752 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
753 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
754 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
755 | 0 | } |
756 | 0 | break; |
757 | 0 | } |
758 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
759 | 0 | { |
760 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); |
761 | 0 | q=PopQuantumPixel(quantum_info,pixel,q); |
762 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range); |
763 | 0 | q=PopQuantumPixel(quantum_info,pixel,q); |
764 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); |
765 | 0 | q=PopQuantumPixel(quantum_info,pixel,q); |
766 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelAlpha(image,p),range); |
767 | 0 | q=PopQuantumPixel(quantum_info,pixel,q); |
768 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
769 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
770 | 0 | } |
771 | 0 | break; |
772 | 0 | } |
773 | 0 | case 16: |
774 | 0 | { |
775 | 0 | unsigned short |
776 | 0 | pixel; |
777 | |
|
778 | 0 | if (quantum_info->format == FloatingPointQuantumFormat) |
779 | 0 | { |
780 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
781 | 0 | { |
782 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
783 | 0 | GetPixelBlue(image,p)); |
784 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
785 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
786 | 0 | GetPixelGreen(image,p)); |
787 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
788 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
789 | 0 | GetPixelRed(image,p)); |
790 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
791 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
792 | 0 | GetPixelAlpha(image,p)); |
793 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
794 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
795 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
796 | 0 | } |
797 | 0 | break; |
798 | 0 | } |
799 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
800 | 0 | { |
801 | 0 | pixel=ScaleQuantumToShort(GetPixelBlue(image,p)); |
802 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
803 | 0 | pixel=ScaleQuantumToShort(GetPixelGreen(image,p)); |
804 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
805 | 0 | pixel=ScaleQuantumToShort(GetPixelRed(image,p)); |
806 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
807 | 0 | pixel=ScaleQuantumToShort(GetPixelAlpha(image,p)); |
808 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
809 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
810 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
811 | 0 | } |
812 | 0 | break; |
813 | 0 | } |
814 | 0 | case 32: |
815 | 0 | { |
816 | 0 | unsigned int |
817 | 0 | pixel; |
818 | |
|
819 | 0 | if (quantum_info->format == FloatingPointQuantumFormat) |
820 | 0 | { |
821 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
822 | 0 | { |
823 | 0 | float |
824 | 0 | float_pixel; |
825 | |
|
826 | 0 | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelRed(image,p),q); |
827 | 0 | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q); |
828 | 0 | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q); |
829 | 0 | float_pixel=(float) GetPixelAlpha(image,p); |
830 | 0 | q=PopQuantumFloatPixel(quantum_info,float_pixel,q); |
831 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
832 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
833 | 0 | } |
834 | 0 | break; |
835 | 0 | } |
836 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
837 | 0 | { |
838 | 0 | pixel=ScaleQuantumToLong(GetPixelBlue(image,p)); |
839 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
840 | 0 | pixel=ScaleQuantumToLong(GetPixelGreen(image,p)); |
841 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
842 | 0 | pixel=ScaleQuantumToLong(GetPixelRed(image,p)); |
843 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
844 | 0 | pixel=ScaleQuantumToLong(GetPixelAlpha(image,p)); |
845 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
846 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
847 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
848 | 0 | } |
849 | 0 | break; |
850 | 0 | } |
851 | 0 | case 64: |
852 | 0 | { |
853 | 0 | if (quantum_info->format == FloatingPointQuantumFormat) |
854 | 0 | { |
855 | 0 | double |
856 | 0 | pixel; |
857 | |
|
858 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
859 | 0 | { |
860 | 0 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelRed(image,p),q); |
861 | 0 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q); |
862 | 0 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q); |
863 | 0 | pixel=(double) GetPixelAlpha(image,p); |
864 | 0 | q=PopQuantumDoublePixel(quantum_info,pixel,q); |
865 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
866 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
867 | 0 | } |
868 | 0 | break; |
869 | 0 | } |
870 | 0 | magick_fallthrough; |
871 | 0 | } |
872 | 0 | default: |
873 | 0 | { |
874 | 0 | range=GetQuantumRange(quantum_info->depth); |
875 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
876 | 0 | { |
877 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p), |
878 | 0 | range),q); |
879 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p), |
880 | 0 | range),q); |
881 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p), |
882 | 0 | range),q); |
883 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p), |
884 | 0 | range),q); |
885 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
886 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
887 | 0 | } |
888 | 0 | break; |
889 | 0 | } |
890 | 0 | } |
891 | 0 | } |
892 | | |
893 | | static void ExportBGROQuantum(const Image *image,QuantumInfo *quantum_info, |
894 | | const MagickSizeType number_pixels,const Quantum *magick_restrict p, |
895 | | unsigned char *magick_restrict q) |
896 | 0 | { |
897 | 0 | QuantumAny |
898 | 0 | range; |
899 | |
|
900 | 0 | ssize_t |
901 | 0 | x; |
902 | |
|
903 | 0 | switch (quantum_info->depth) |
904 | 0 | { |
905 | 0 | case 8: |
906 | 0 | { |
907 | 0 | unsigned char |
908 | 0 | pixel; |
909 | |
|
910 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
911 | 0 | { |
912 | 0 | pixel=ScaleQuantumToChar(GetPixelBlue(image,p)); |
913 | 0 | q=PopCharPixel(pixel,q); |
914 | 0 | pixel=ScaleQuantumToChar(GetPixelGreen(image,p)); |
915 | 0 | q=PopCharPixel(pixel,q); |
916 | 0 | pixel=ScaleQuantumToChar(GetPixelRed(image,p)); |
917 | 0 | q=PopCharPixel(pixel,q); |
918 | 0 | pixel=ScaleQuantumToChar(GetPixelOpacity(image,p)); |
919 | 0 | q=PopCharPixel(pixel,q); |
920 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
921 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
922 | 0 | } |
923 | 0 | break; |
924 | 0 | } |
925 | 0 | case 10: |
926 | 0 | { |
927 | 0 | unsigned int |
928 | 0 | pixel; |
929 | |
|
930 | 0 | range=GetQuantumRange(quantum_info->depth); |
931 | 0 | if (quantum_info->pack == MagickFalse) |
932 | 0 | { |
933 | 0 | ssize_t |
934 | 0 | i; |
935 | |
|
936 | 0 | size_t |
937 | 0 | quantum; |
938 | |
|
939 | 0 | ssize_t |
940 | 0 | n; |
941 | |
|
942 | 0 | n=0; |
943 | 0 | quantum=0; |
944 | 0 | pixel=0; |
945 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
946 | 0 | { |
947 | 0 | for (i=0; i < 4; i++) |
948 | 0 | { |
949 | 0 | switch (i) |
950 | 0 | { |
951 | 0 | case 0: quantum=(size_t) GetPixelRed(image,p); break; |
952 | 0 | case 1: quantum=(size_t) GetPixelGreen(image,p); break; |
953 | 0 | case 2: quantum=(size_t) GetPixelBlue(image,p); break; |
954 | 0 | case 3: quantum=(size_t) GetPixelOpacity(image,p); break; |
955 | 0 | } |
956 | 0 | switch (n % 3) |
957 | 0 | { |
958 | 0 | case 0: |
959 | 0 | { |
960 | 0 | pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum, |
961 | 0 | range) << 22); |
962 | 0 | break; |
963 | 0 | } |
964 | 0 | case 1: |
965 | 0 | { |
966 | 0 | pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum, |
967 | 0 | range) << 12); |
968 | 0 | break; |
969 | 0 | } |
970 | 0 | case 2: |
971 | 0 | { |
972 | 0 | pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum, |
973 | 0 | range) << 2); |
974 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
975 | 0 | pixel=0; |
976 | 0 | break; |
977 | 0 | } |
978 | 0 | } |
979 | 0 | n++; |
980 | 0 | } |
981 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
982 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
983 | 0 | } |
984 | 0 | break; |
985 | 0 | } |
986 | 0 | if (quantum_info->quantum == 32UL) |
987 | 0 | { |
988 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
989 | 0 | { |
990 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); |
991 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
992 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), |
993 | 0 | range); |
994 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
995 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); |
996 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
997 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelOpacity(image,p), |
998 | 0 | range); |
999 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
1000 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1001 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
1002 | 0 | } |
1003 | 0 | break; |
1004 | 0 | } |
1005 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
1006 | 0 | { |
1007 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); |
1008 | 0 | q=PopQuantumPixel(quantum_info,pixel,q); |
1009 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range); |
1010 | 0 | q=PopQuantumPixel(quantum_info,pixel,q); |
1011 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); |
1012 | 0 | q=PopQuantumPixel(quantum_info,pixel,q); |
1013 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelOpacity(image,p),range); |
1014 | 0 | q=PopQuantumPixel(quantum_info,pixel,q); |
1015 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1016 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
1017 | 0 | } |
1018 | 0 | break; |
1019 | 0 | } |
1020 | 0 | case 16: |
1021 | 0 | { |
1022 | 0 | unsigned short |
1023 | 0 | pixel; |
1024 | |
|
1025 | 0 | if (quantum_info->format == FloatingPointQuantumFormat) |
1026 | 0 | { |
1027 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
1028 | 0 | { |
1029 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
1030 | 0 | GetPixelBlue(image,p)); |
1031 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
1032 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
1033 | 0 | GetPixelGreen(image,p)); |
1034 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
1035 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
1036 | 0 | GetPixelRed(image,p)); |
1037 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
1038 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
1039 | 0 | GetPixelOpacity(image,p)); |
1040 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
1041 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1042 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
1043 | 0 | } |
1044 | 0 | break; |
1045 | 0 | } |
1046 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
1047 | 0 | { |
1048 | 0 | pixel=ScaleQuantumToShort(GetPixelBlue(image,p)); |
1049 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
1050 | 0 | pixel=ScaleQuantumToShort(GetPixelGreen(image,p)); |
1051 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
1052 | 0 | pixel=ScaleQuantumToShort(GetPixelRed(image,p)); |
1053 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
1054 | 0 | pixel=ScaleQuantumToShort(GetPixelOpacity(image,p)); |
1055 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
1056 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1057 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
1058 | 0 | } |
1059 | 0 | break; |
1060 | 0 | } |
1061 | 0 | case 32: |
1062 | 0 | { |
1063 | 0 | unsigned int |
1064 | 0 | pixel; |
1065 | |
|
1066 | 0 | if (quantum_info->format == FloatingPointQuantumFormat) |
1067 | 0 | { |
1068 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
1069 | 0 | { |
1070 | 0 | float |
1071 | 0 | float_pixel; |
1072 | |
|
1073 | 0 | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelRed(image,p),q); |
1074 | 0 | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q); |
1075 | 0 | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q); |
1076 | 0 | float_pixel=(float) GetPixelOpacity(image,p); |
1077 | 0 | q=PopQuantumFloatPixel(quantum_info,float_pixel,q); |
1078 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1079 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
1080 | 0 | } |
1081 | 0 | break; |
1082 | 0 | } |
1083 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
1084 | 0 | { |
1085 | 0 | pixel=ScaleQuantumToLong(GetPixelBlue(image,p)); |
1086 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
1087 | 0 | pixel=ScaleQuantumToLong(GetPixelGreen(image,p)); |
1088 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
1089 | 0 | pixel=ScaleQuantumToLong(GetPixelRed(image,p)); |
1090 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
1091 | 0 | pixel=ScaleQuantumToLong(GetPixelOpacity(image,p)); |
1092 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
1093 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1094 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
1095 | 0 | } |
1096 | 0 | break; |
1097 | 0 | } |
1098 | 0 | case 64: |
1099 | 0 | { |
1100 | 0 | if (quantum_info->format == FloatingPointQuantumFormat) |
1101 | 0 | { |
1102 | 0 | double |
1103 | 0 | pixel; |
1104 | |
|
1105 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
1106 | 0 | { |
1107 | 0 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelRed(image,p),q); |
1108 | 0 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q); |
1109 | 0 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q); |
1110 | 0 | pixel=(double) GetPixelOpacity(image,p); |
1111 | 0 | q=PopQuantumDoublePixel(quantum_info,pixel,q); |
1112 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1113 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
1114 | 0 | } |
1115 | 0 | break; |
1116 | 0 | } |
1117 | 0 | magick_fallthrough; |
1118 | 0 | } |
1119 | 0 | default: |
1120 | 0 | { |
1121 | 0 | range=GetQuantumRange(quantum_info->depth); |
1122 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
1123 | 0 | { |
1124 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p), |
1125 | 0 | range),q); |
1126 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p), |
1127 | 0 | range),q); |
1128 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p), |
1129 | 0 | range),q); |
1130 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelOpacity(image,p), |
1131 | 0 | range),q); |
1132 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1133 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
1134 | 0 | } |
1135 | 0 | break; |
1136 | 0 | } |
1137 | 0 | } |
1138 | 0 | } |
1139 | | |
1140 | | static void ExportBlackQuantum(const Image *image,QuantumInfo *quantum_info, |
1141 | | const MagickSizeType number_pixels,const Quantum *magick_restrict p, |
1142 | | unsigned char *magick_restrict q,ExceptionInfo *exception) |
1143 | 0 | { |
1144 | 0 | QuantumAny |
1145 | 0 | range; |
1146 | |
|
1147 | 0 | ssize_t |
1148 | 0 | x; |
1149 | |
|
1150 | 0 | assert(exception != (ExceptionInfo *) NULL); |
1151 | 0 | assert(exception->signature == MagickCoreSignature); |
1152 | 0 | if (image->colorspace != CMYKColorspace) |
1153 | 0 | { |
1154 | 0 | (void) ThrowMagickException(exception,GetMagickModule(),ImageError, |
1155 | 0 | "ColorSeparatedImageRequired","`%s'",image->filename); |
1156 | 0 | return; |
1157 | 0 | } |
1158 | 0 | switch (quantum_info->depth) |
1159 | 0 | { |
1160 | 0 | case 8: |
1161 | 0 | { |
1162 | 0 | unsigned char |
1163 | 0 | pixel; |
1164 | |
|
1165 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
1166 | 0 | { |
1167 | 0 | pixel=ScaleQuantumToChar(GetPixelBlack(image,p)); |
1168 | 0 | q=PopCharPixel(pixel,q); |
1169 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1170 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
1171 | 0 | } |
1172 | 0 | break; |
1173 | 0 | } |
1174 | 0 | case 16: |
1175 | 0 | { |
1176 | 0 | unsigned short |
1177 | 0 | pixel; |
1178 | |
|
1179 | 0 | if (quantum_info->format == FloatingPointQuantumFormat) |
1180 | 0 | { |
1181 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
1182 | 0 | { |
1183 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
1184 | 0 | GetPixelBlack(image,p)); |
1185 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
1186 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1187 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
1188 | 0 | } |
1189 | 0 | break; |
1190 | 0 | } |
1191 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
1192 | 0 | { |
1193 | 0 | pixel=ScaleQuantumToShort(GetPixelBlack(image,p)); |
1194 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
1195 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1196 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
1197 | 0 | } |
1198 | 0 | break; |
1199 | 0 | } |
1200 | 0 | case 32: |
1201 | 0 | { |
1202 | 0 | unsigned int |
1203 | 0 | pixel; |
1204 | |
|
1205 | 0 | if (quantum_info->format == FloatingPointQuantumFormat) |
1206 | 0 | { |
1207 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
1208 | 0 | { |
1209 | 0 | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelBlack(image,p),q); |
1210 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1211 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
1212 | 0 | } |
1213 | 0 | break; |
1214 | 0 | } |
1215 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
1216 | 0 | { |
1217 | 0 | pixel=ScaleQuantumToLong(GetPixelBlack(image,p)); |
1218 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
1219 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1220 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
1221 | 0 | } |
1222 | 0 | break; |
1223 | 0 | } |
1224 | 0 | case 64: |
1225 | 0 | { |
1226 | 0 | if (quantum_info->format == FloatingPointQuantumFormat) |
1227 | 0 | { |
1228 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
1229 | 0 | { |
1230 | 0 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelBlack(image,p),q); |
1231 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1232 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
1233 | 0 | } |
1234 | 0 | break; |
1235 | 0 | } |
1236 | 0 | magick_fallthrough; |
1237 | 0 | } |
1238 | 0 | default: |
1239 | 0 | { |
1240 | 0 | range=GetQuantumRange(quantum_info->depth); |
1241 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
1242 | 0 | { |
1243 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlack(image,p), |
1244 | 0 | range),q); |
1245 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1246 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
1247 | 0 | } |
1248 | 0 | break; |
1249 | 0 | } |
1250 | 0 | } |
1251 | 0 | } |
1252 | | |
1253 | | static void ExportBlueQuantum(const Image *image,QuantumInfo *quantum_info, |
1254 | | const MagickSizeType number_pixels,const Quantum *magick_restrict p, |
1255 | | unsigned char *magick_restrict q) |
1256 | 51.6k | { |
1257 | 51.6k | QuantumAny |
1258 | 51.6k | range; |
1259 | | |
1260 | 51.6k | ssize_t |
1261 | 51.6k | x; |
1262 | | |
1263 | 51.6k | switch (quantum_info->depth) |
1264 | 51.6k | { |
1265 | 40.4k | case 8: |
1266 | 40.4k | { |
1267 | 40.4k | unsigned char |
1268 | 40.4k | pixel; |
1269 | | |
1270 | 413k | for (x=0; x < (ssize_t) number_pixels; x++) |
1271 | 373k | { |
1272 | 373k | pixel=ScaleQuantumToChar(GetPixelBlue(image,p)); |
1273 | 373k | q=PopCharPixel(pixel,q); |
1274 | 373k | p+=(ptrdiff_t) GetPixelChannels(image); |
1275 | 373k | q+=(ptrdiff_t) quantum_info->pad; |
1276 | 373k | } |
1277 | 40.4k | break; |
1278 | 0 | } |
1279 | 7.23k | case 16: |
1280 | 7.23k | { |
1281 | 7.23k | unsigned short |
1282 | 7.23k | pixel; |
1283 | | |
1284 | 7.23k | if (quantum_info->format == FloatingPointQuantumFormat) |
1285 | 0 | { |
1286 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
1287 | 0 | { |
1288 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
1289 | 0 | GetPixelBlue(image,p)); |
1290 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
1291 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1292 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
1293 | 0 | } |
1294 | 0 | break; |
1295 | 0 | } |
1296 | 33.3k | for (x=0; x < (ssize_t) number_pixels; x++) |
1297 | 26.0k | { |
1298 | 26.0k | pixel=ScaleQuantumToShort(GetPixelBlue(image,p)); |
1299 | 26.0k | q=PopShortPixel(quantum_info->endian,pixel,q); |
1300 | 26.0k | p+=(ptrdiff_t) GetPixelChannels(image); |
1301 | 26.0k | q+=(ptrdiff_t) quantum_info->pad; |
1302 | 26.0k | } |
1303 | 7.23k | break; |
1304 | 7.23k | } |
1305 | 1.79k | case 32: |
1306 | 1.79k | { |
1307 | 1.79k | unsigned int |
1308 | 1.79k | pixel; |
1309 | | |
1310 | 1.79k | if (quantum_info->format == FloatingPointQuantumFormat) |
1311 | 987 | { |
1312 | 5.47k | for (x=0; x < (ssize_t) number_pixels; x++) |
1313 | 4.48k | { |
1314 | 4.48k | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q); |
1315 | 4.48k | p+=(ptrdiff_t) GetPixelChannels(image); |
1316 | 4.48k | q+=(ptrdiff_t) quantum_info->pad; |
1317 | 4.48k | } |
1318 | 987 | break; |
1319 | 987 | } |
1320 | 8.01k | for (x=0; x < (ssize_t) number_pixels; x++) |
1321 | 7.20k | { |
1322 | 7.20k | pixel=ScaleQuantumToLong(GetPixelBlue(image,p)); |
1323 | 7.20k | q=PopLongPixel(quantum_info->endian,pixel,q); |
1324 | 7.20k | p+=(ptrdiff_t) GetPixelChannels(image); |
1325 | 7.20k | q+=(ptrdiff_t) quantum_info->pad; |
1326 | 7.20k | } |
1327 | 808 | break; |
1328 | 1.79k | } |
1329 | 2.14k | case 64: |
1330 | 2.14k | { |
1331 | 2.14k | if (quantum_info->format == FloatingPointQuantumFormat) |
1332 | 464 | { |
1333 | 1.44k | for (x=0; x < (ssize_t) number_pixels; x++) |
1334 | 977 | { |
1335 | 977 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q); |
1336 | 977 | p+=(ptrdiff_t) GetPixelChannels(image); |
1337 | 977 | q+=(ptrdiff_t) quantum_info->pad; |
1338 | 977 | } |
1339 | 464 | break; |
1340 | 464 | } |
1341 | 1.67k | magick_fallthrough; |
1342 | 1.67k | } |
1343 | 1.67k | default: |
1344 | 1.67k | { |
1345 | 1.67k | range=GetQuantumRange(quantum_info->depth); |
1346 | 9.95k | for (x=0; x < (ssize_t) number_pixels; x++) |
1347 | 8.27k | { |
1348 | 8.27k | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p), |
1349 | 8.27k | range),q); |
1350 | 8.27k | p+=(ptrdiff_t) GetPixelChannels(image); |
1351 | 8.27k | q+=(ptrdiff_t) quantum_info->pad; |
1352 | 8.27k | } |
1353 | 1.67k | break; |
1354 | 1.67k | } |
1355 | 51.6k | } |
1356 | 51.6k | } |
1357 | | |
1358 | | static void ExportCbYCrYQuantum(const Image *image,QuantumInfo *quantum_info, |
1359 | | const MagickSizeType number_pixels,const Quantum *magick_restrict p, |
1360 | | unsigned char *magick_restrict q) |
1361 | 0 | { |
1362 | 0 | Quantum |
1363 | 0 | cbcr[4]; |
1364 | |
|
1365 | 0 | ssize_t |
1366 | 0 | i, |
1367 | 0 | x; |
1368 | |
|
1369 | 0 | unsigned int |
1370 | 0 | pixel; |
1371 | |
|
1372 | 0 | size_t |
1373 | 0 | quantum; |
1374 | |
|
1375 | 0 | ssize_t |
1376 | 0 | n; |
1377 | |
|
1378 | 0 | n=0; |
1379 | 0 | quantum=0; |
1380 | 0 | switch (quantum_info->depth) |
1381 | 0 | { |
1382 | 0 | case 10: |
1383 | 0 | { |
1384 | 0 | if (quantum_info->pack == MagickFalse) |
1385 | 0 | { |
1386 | 0 | for (x=0; x < (ssize_t) number_pixels; x+=2) |
1387 | 0 | { |
1388 | 0 | for (i=0; i < 4; i++) |
1389 | 0 | { |
1390 | 0 | switch (n % 3) |
1391 | 0 | { |
1392 | 0 | case 0: |
1393 | 0 | { |
1394 | 0 | quantum=(size_t) GetPixelRed(image,p); |
1395 | 0 | break; |
1396 | 0 | } |
1397 | 0 | case 1: |
1398 | 0 | { |
1399 | 0 | quantum=(size_t) GetPixelGreen(image,p); |
1400 | 0 | break; |
1401 | 0 | } |
1402 | 0 | case 2: |
1403 | 0 | { |
1404 | 0 | quantum=(size_t) GetPixelBlue(image,p); |
1405 | 0 | break; |
1406 | 0 | } |
1407 | 0 | } |
1408 | 0 | cbcr[i]=(Quantum) quantum; |
1409 | 0 | n++; |
1410 | 0 | } |
1411 | 0 | pixel=(unsigned int) ((size_t) (cbcr[1]) << 22 | (size_t) |
1412 | 0 | (cbcr[0]) << 12 | (size_t) (cbcr[2]) << 2); |
1413 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
1414 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1415 | 0 | pixel=(unsigned int) ((size_t) (cbcr[3]) << 22 | (size_t) |
1416 | 0 | (cbcr[0]) << 12 | (size_t) (cbcr[2]) << 2); |
1417 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
1418 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1419 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
1420 | 0 | } |
1421 | 0 | break; |
1422 | 0 | } |
1423 | 0 | break; |
1424 | 0 | } |
1425 | 0 | default: |
1426 | 0 | { |
1427 | 0 | QuantumAny |
1428 | 0 | range; |
1429 | |
|
1430 | 0 | for (x=0; x < (ssize_t) number_pixels; x+=2) |
1431 | 0 | { |
1432 | 0 | for (i=0; i < 4; i++) |
1433 | 0 | { |
1434 | 0 | switch (n % 3) |
1435 | 0 | { |
1436 | 0 | case 0: |
1437 | 0 | { |
1438 | 0 | quantum=(size_t) GetPixelRed(image,p); |
1439 | 0 | break; |
1440 | 0 | } |
1441 | 0 | case 1: |
1442 | 0 | { |
1443 | 0 | quantum=(size_t) GetPixelGreen(image,p); |
1444 | 0 | break; |
1445 | 0 | } |
1446 | 0 | case 2: |
1447 | 0 | { |
1448 | 0 | quantum=(size_t) GetPixelBlue(image,p); |
1449 | 0 | break; |
1450 | 0 | } |
1451 | 0 | } |
1452 | 0 | cbcr[i]=(Quantum) quantum; |
1453 | 0 | n++; |
1454 | 0 | } |
1455 | 0 | range=GetQuantumRange(quantum_info->depth); |
1456 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[1],range),q); |
1457 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[0],range),q); |
1458 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[2],range),q); |
1459 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1460 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[3],range),q); |
1461 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[0],range),q); |
1462 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[2],range),q); |
1463 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1464 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
1465 | 0 | } |
1466 | 0 | break; |
1467 | 0 | } |
1468 | 0 | } |
1469 | 0 | } |
1470 | | |
1471 | | static void ExportCMYKQuantum(const Image *image,QuantumInfo *quantum_info, |
1472 | | const MagickSizeType number_pixels,const Quantum *magick_restrict p, |
1473 | | unsigned char *magick_restrict q,ExceptionInfo *exception) |
1474 | 27.1k | { |
1475 | 27.1k | ssize_t |
1476 | 27.1k | x; |
1477 | | |
1478 | 27.1k | assert(exception != (ExceptionInfo *) NULL); |
1479 | 27.1k | assert(exception->signature == MagickCoreSignature); |
1480 | 27.1k | if (image->colorspace != CMYKColorspace) |
1481 | 0 | { |
1482 | 0 | (void) ThrowMagickException(exception,GetMagickModule(),ImageError, |
1483 | 0 | "ColorSeparatedImageRequired","`%s'",image->filename); |
1484 | 0 | return; |
1485 | 0 | } |
1486 | 27.1k | switch (quantum_info->depth) |
1487 | 27.1k | { |
1488 | 3.80k | case 8: |
1489 | 3.80k | { |
1490 | 3.80k | unsigned char |
1491 | 3.80k | pixel; |
1492 | | |
1493 | 102k | for (x=0; x < (ssize_t) number_pixels; x++) |
1494 | 98.8k | { |
1495 | 98.8k | pixel=ScaleQuantumToChar(GetPixelRed(image,p)); |
1496 | 98.8k | q=PopCharPixel(pixel,q); |
1497 | 98.8k | pixel=ScaleQuantumToChar(GetPixelGreen(image,p)); |
1498 | 98.8k | q=PopCharPixel(pixel,q); |
1499 | 98.8k | pixel=ScaleQuantumToChar(GetPixelBlue(image,p)); |
1500 | 98.8k | q=PopCharPixel(pixel,q); |
1501 | 98.8k | pixel=ScaleQuantumToChar(GetPixelBlack(image,p)); |
1502 | 98.8k | q=PopCharPixel(pixel,q); |
1503 | 98.8k | p+=(ptrdiff_t) GetPixelChannels(image); |
1504 | 98.8k | q+=(ptrdiff_t) quantum_info->pad; |
1505 | 98.8k | } |
1506 | 3.80k | break; |
1507 | 0 | } |
1508 | 9.55k | case 16: |
1509 | 9.55k | { |
1510 | 9.55k | unsigned short |
1511 | 9.55k | pixel; |
1512 | | |
1513 | 9.55k | if (quantum_info->format == FloatingPointQuantumFormat) |
1514 | 5.51k | { |
1515 | 23.2k | for (x=0; x < (ssize_t) number_pixels; x++) |
1516 | 17.7k | { |
1517 | 17.7k | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
1518 | 17.7k | GetPixelRed(image,p)); |
1519 | 17.7k | q=PopShortPixel(quantum_info->endian,pixel,q); |
1520 | 17.7k | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
1521 | 17.7k | GetPixelGreen(image,p)); |
1522 | 17.7k | q=PopShortPixel(quantum_info->endian,pixel,q); |
1523 | 17.7k | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
1524 | 17.7k | GetPixelBlue(image,p)); |
1525 | 17.7k | q=PopShortPixel(quantum_info->endian,pixel,q); |
1526 | 17.7k | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
1527 | 17.7k | GetPixelBlack(image,p)); |
1528 | 17.7k | q=PopShortPixel(quantum_info->endian,pixel,q); |
1529 | 17.7k | p+=(ptrdiff_t) GetPixelChannels(image); |
1530 | 17.7k | q+=(ptrdiff_t) quantum_info->pad; |
1531 | 17.7k | } |
1532 | 5.51k | break; |
1533 | 5.51k | } |
1534 | 3.08M | for (x=0; x < (ssize_t) number_pixels; x++) |
1535 | 3.07M | { |
1536 | 3.07M | pixel=ScaleQuantumToShort(GetPixelRed(image,p)); |
1537 | 3.07M | q=PopShortPixel(quantum_info->endian,pixel,q); |
1538 | 3.07M | pixel=ScaleQuantumToShort(GetPixelGreen(image,p)); |
1539 | 3.07M | q=PopShortPixel(quantum_info->endian,pixel,q); |
1540 | 3.07M | pixel=ScaleQuantumToShort(GetPixelBlue(image,p)); |
1541 | 3.07M | q=PopShortPixel(quantum_info->endian,pixel,q); |
1542 | 3.07M | pixel=ScaleQuantumToShort(GetPixelBlack(image,p)); |
1543 | 3.07M | q=PopShortPixel(quantum_info->endian,pixel,q); |
1544 | 3.07M | p+=(ptrdiff_t) GetPixelChannels(image); |
1545 | 3.07M | q+=(ptrdiff_t) quantum_info->pad; |
1546 | 3.07M | } |
1547 | 4.04k | break; |
1548 | 9.55k | } |
1549 | 11.2k | case 32: |
1550 | 11.2k | { |
1551 | 11.2k | unsigned int |
1552 | 11.2k | pixel; |
1553 | | |
1554 | 11.2k | if (quantum_info->format == FloatingPointQuantumFormat) |
1555 | 3.04k | { |
1556 | 16.7k | for (x=0; x < (ssize_t) number_pixels; x++) |
1557 | 13.6k | { |
1558 | 13.6k | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelRed(image,p),q); |
1559 | 13.6k | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q); |
1560 | 13.6k | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q); |
1561 | 13.6k | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelBlack(image,p),q); |
1562 | 13.6k | p+=(ptrdiff_t) GetPixelChannels(image); |
1563 | 13.6k | q+=(ptrdiff_t) quantum_info->pad; |
1564 | 13.6k | } |
1565 | 3.04k | break; |
1566 | 3.04k | } |
1567 | 9.52M | for (x=0; x < (ssize_t) number_pixels; x++) |
1568 | 9.51M | { |
1569 | 9.51M | pixel=ScaleQuantumToLong(GetPixelRed(image,p)); |
1570 | 9.51M | q=PopLongPixel(quantum_info->endian,pixel,q); |
1571 | 9.51M | pixel=ScaleQuantumToLong(GetPixelGreen(image,p)); |
1572 | 9.51M | q=PopLongPixel(quantum_info->endian,pixel,q); |
1573 | 9.51M | pixel=ScaleQuantumToLong(GetPixelBlue(image,p)); |
1574 | 9.51M | q=PopLongPixel(quantum_info->endian,pixel,q); |
1575 | 9.51M | pixel=ScaleQuantumToLong(GetPixelBlack(image,p)); |
1576 | 9.51M | q=PopLongPixel(quantum_info->endian,pixel,q); |
1577 | 9.51M | p+=(ptrdiff_t) GetPixelChannels(image); |
1578 | 9.51M | q+=(ptrdiff_t) quantum_info->pad; |
1579 | 9.51M | } |
1580 | 8.24k | break; |
1581 | 11.2k | } |
1582 | 219 | case 64: |
1583 | 219 | { |
1584 | 219 | if (quantum_info->format == FloatingPointQuantumFormat) |
1585 | 130 | { |
1586 | 350 | for (x=0; x < (ssize_t) number_pixels; x++) |
1587 | 220 | { |
1588 | 220 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelRed(image,p),q); |
1589 | 220 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q); |
1590 | 220 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q); |
1591 | 220 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelBlack(image,p),q); |
1592 | 220 | p+=(ptrdiff_t) GetPixelChannels(image); |
1593 | 220 | q+=(ptrdiff_t) quantum_info->pad; |
1594 | 220 | } |
1595 | 130 | break; |
1596 | 130 | } |
1597 | 89 | magick_fallthrough; |
1598 | 89 | } |
1599 | 2.42k | default: |
1600 | 2.42k | { |
1601 | 2.42k | QuantumAny |
1602 | 2.42k | range; |
1603 | | |
1604 | 2.42k | range=GetQuantumRange(quantum_info->depth); |
1605 | 203k | for (x=0; x < (ssize_t) number_pixels; x++) |
1606 | 200k | { |
1607 | 200k | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p), |
1608 | 200k | range),q); |
1609 | 200k | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p), |
1610 | 200k | range),q); |
1611 | 200k | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p), |
1612 | 200k | range),q); |
1613 | 200k | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlack(image,p), |
1614 | 200k | range),q); |
1615 | 200k | p+=(ptrdiff_t) GetPixelChannels(image); |
1616 | 200k | q+=(ptrdiff_t) quantum_info->pad; |
1617 | 200k | } |
1618 | 2.42k | break; |
1619 | 89 | } |
1620 | 27.1k | } |
1621 | 27.1k | } |
1622 | | |
1623 | | static void ExportCMYKAQuantum(const Image *image,QuantumInfo *quantum_info, |
1624 | | const MagickSizeType number_pixels,const Quantum *magick_restrict p, |
1625 | | unsigned char *magick_restrict q,ExceptionInfo *exception) |
1626 | 34.3k | { |
1627 | 34.3k | ssize_t |
1628 | 34.3k | x; |
1629 | | |
1630 | 34.3k | assert(exception != (ExceptionInfo *) NULL); |
1631 | 34.3k | assert(exception->signature == MagickCoreSignature); |
1632 | 34.3k | if (image->colorspace != CMYKColorspace) |
1633 | 0 | { |
1634 | 0 | (void) ThrowMagickException(exception,GetMagickModule(),ImageError, |
1635 | 0 | "ColorSeparatedImageRequired","`%s'",image->filename); |
1636 | 0 | return; |
1637 | 0 | } |
1638 | 34.3k | switch (quantum_info->depth) |
1639 | 34.3k | { |
1640 | 3.17k | case 8: |
1641 | 3.17k | { |
1642 | 3.17k | unsigned char |
1643 | 3.17k | pixel; |
1644 | | |
1645 | 177k | for (x=0; x < (ssize_t) number_pixels; x++) |
1646 | 174k | { |
1647 | 174k | pixel=ScaleQuantumToChar(GetPixelRed(image,p)); |
1648 | 174k | q=PopCharPixel(pixel,q); |
1649 | 174k | pixel=ScaleQuantumToChar(GetPixelGreen(image,p)); |
1650 | 174k | q=PopCharPixel(pixel,q); |
1651 | 174k | pixel=ScaleQuantumToChar(GetPixelBlue(image,p)); |
1652 | 174k | q=PopCharPixel(pixel,q); |
1653 | 174k | pixel=ScaleQuantumToChar(GetPixelBlack(image,p)); |
1654 | 174k | q=PopCharPixel(pixel,q); |
1655 | 174k | pixel=ScaleQuantumToChar(GetPixelAlpha(image,p)); |
1656 | 174k | q=PopCharPixel(pixel,q); |
1657 | 174k | p+=(ptrdiff_t) GetPixelChannels(image); |
1658 | 174k | q+=(ptrdiff_t) quantum_info->pad; |
1659 | 174k | } |
1660 | 3.17k | break; |
1661 | 0 | } |
1662 | 6.41k | case 16: |
1663 | 6.41k | { |
1664 | 6.41k | unsigned short |
1665 | 6.41k | pixel; |
1666 | | |
1667 | 6.41k | if (quantum_info->format == FloatingPointQuantumFormat) |
1668 | 3.27k | { |
1669 | 20.9k | for (x=0; x < (ssize_t) number_pixels; x++) |
1670 | 17.6k | { |
1671 | 17.6k | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
1672 | 17.6k | GetPixelRed(image,p)); |
1673 | 17.6k | q=PopShortPixel(quantum_info->endian,pixel,q); |
1674 | 17.6k | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
1675 | 17.6k | GetPixelGreen(image,p)); |
1676 | 17.6k | q=PopShortPixel(quantum_info->endian,pixel,q); |
1677 | 17.6k | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
1678 | 17.6k | GetPixelBlue(image,p)); |
1679 | 17.6k | q=PopShortPixel(quantum_info->endian,pixel,q); |
1680 | 17.6k | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
1681 | 17.6k | GetPixelBlack(image,p)); |
1682 | 17.6k | q=PopShortPixel(quantum_info->endian,pixel,q); |
1683 | 17.6k | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
1684 | 17.6k | GetPixelAlpha(image,p)); |
1685 | 17.6k | q=PopShortPixel(quantum_info->endian,pixel,q); |
1686 | 17.6k | p+=(ptrdiff_t) GetPixelChannels(image); |
1687 | 17.6k | q+=(ptrdiff_t) quantum_info->pad; |
1688 | 17.6k | } |
1689 | 3.27k | break; |
1690 | 3.27k | } |
1691 | 42.7k | for (x=0; x < (ssize_t) number_pixels; x++) |
1692 | 39.5k | { |
1693 | 39.5k | pixel=ScaleQuantumToShort(GetPixelRed(image,p)); |
1694 | 39.5k | q=PopShortPixel(quantum_info->endian,pixel,q); |
1695 | 39.5k | pixel=ScaleQuantumToShort(GetPixelGreen(image,p)); |
1696 | 39.5k | q=PopShortPixel(quantum_info->endian,pixel,q); |
1697 | 39.5k | pixel=ScaleQuantumToShort(GetPixelBlue(image,p)); |
1698 | 39.5k | q=PopShortPixel(quantum_info->endian,pixel,q); |
1699 | 39.5k | pixel=ScaleQuantumToShort(GetPixelBlack(image,p)); |
1700 | 39.5k | q=PopShortPixel(quantum_info->endian,pixel,q); |
1701 | 39.5k | pixel=ScaleQuantumToShort(GetPixelAlpha(image,p)); |
1702 | 39.5k | q=PopShortPixel(quantum_info->endian,pixel,q); |
1703 | 39.5k | p+=(ptrdiff_t) GetPixelChannels(image); |
1704 | 39.5k | q+=(ptrdiff_t) quantum_info->pad; |
1705 | 39.5k | } |
1706 | 3.14k | break; |
1707 | 6.41k | } |
1708 | 21.6k | case 32: |
1709 | 21.6k | { |
1710 | 21.6k | unsigned int |
1711 | 21.6k | pixel; |
1712 | | |
1713 | 21.6k | if (quantum_info->format == FloatingPointQuantumFormat) |
1714 | 3.50k | { |
1715 | 14.2k | for (x=0; x < (ssize_t) number_pixels; x++) |
1716 | 10.7k | { |
1717 | 10.7k | q=PopQuantumFloatPixel(quantum_info,(float) |
1718 | 10.7k | GetPixelRed(image,p),q); |
1719 | 10.7k | q=PopQuantumFloatPixel(quantum_info,(float) |
1720 | 10.7k | GetPixelGreen(image,p),q); |
1721 | 10.7k | q=PopQuantumFloatPixel(quantum_info,(float) |
1722 | 10.7k | GetPixelBlue(image,p),q); |
1723 | 10.7k | q=PopQuantumFloatPixel(quantum_info,(float) |
1724 | 10.7k | GetPixelBlack(image,p),q); |
1725 | 10.7k | q=PopQuantumFloatPixel(quantum_info,(float) |
1726 | 10.7k | GetPixelAlpha(image,p),q); |
1727 | 10.7k | p+=(ptrdiff_t) GetPixelChannels(image); |
1728 | 10.7k | q+=(ptrdiff_t) quantum_info->pad; |
1729 | 10.7k | } |
1730 | 3.50k | break; |
1731 | 3.50k | } |
1732 | 33.3M | for (x=0; x < (ssize_t) number_pixels; x++) |
1733 | 33.3M | { |
1734 | 33.3M | pixel=ScaleQuantumToLong(GetPixelRed(image,p)); |
1735 | 33.3M | q=PopLongPixel(quantum_info->endian,pixel,q); |
1736 | 33.3M | pixel=ScaleQuantumToLong(GetPixelGreen(image,p)); |
1737 | 33.3M | q=PopLongPixel(quantum_info->endian,pixel,q); |
1738 | 33.3M | pixel=ScaleQuantumToLong(GetPixelBlue(image,p)); |
1739 | 33.3M | q=PopLongPixel(quantum_info->endian,pixel,q); |
1740 | 33.3M | pixel=ScaleQuantumToLong(GetPixelBlack(image,p)); |
1741 | 33.3M | q=PopLongPixel(quantum_info->endian,pixel,q); |
1742 | 33.3M | pixel=ScaleQuantumToLong(GetPixelAlpha(image,p)); |
1743 | 33.3M | q=PopLongPixel(quantum_info->endian,pixel,q); |
1744 | 33.3M | p+=(ptrdiff_t) GetPixelChannels(image); |
1745 | 33.3M | q+=(ptrdiff_t) quantum_info->pad; |
1746 | 33.3M | } |
1747 | 18.1k | break; |
1748 | 21.6k | } |
1749 | 209 | case 64: |
1750 | 209 | { |
1751 | 209 | if (quantum_info->format == FloatingPointQuantumFormat) |
1752 | 123 | { |
1753 | 332 | for (x=0; x < (ssize_t) number_pixels; x++) |
1754 | 209 | { |
1755 | 209 | q=PopQuantumDoublePixel(quantum_info,(double) |
1756 | 209 | GetPixelRed(image,p),q); |
1757 | 209 | q=PopQuantumDoublePixel(quantum_info,(double) |
1758 | 209 | GetPixelGreen(image,p),q); |
1759 | 209 | q=PopQuantumDoublePixel(quantum_info,(double) |
1760 | 209 | GetPixelBlue(image,p),q); |
1761 | 209 | q=PopQuantumDoublePixel(quantum_info,(double) |
1762 | 209 | GetPixelBlack(image,p),q); |
1763 | 209 | q=PopQuantumDoublePixel(quantum_info,(double) |
1764 | 209 | GetPixelAlpha(image,p),q); |
1765 | 209 | p+=(ptrdiff_t) GetPixelChannels(image); |
1766 | 209 | q+=(ptrdiff_t) quantum_info->pad; |
1767 | 209 | } |
1768 | 123 | break; |
1769 | 123 | } |
1770 | 86 | magick_fallthrough; |
1771 | 86 | } |
1772 | 2.98k | default: |
1773 | 2.98k | { |
1774 | 2.98k | QuantumAny |
1775 | 2.98k | range; |
1776 | | |
1777 | 2.98k | range=GetQuantumRange(quantum_info->depth); |
1778 | 58.2k | for (x=0; x < (ssize_t) number_pixels; x++) |
1779 | 55.2k | { |
1780 | 55.2k | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p), |
1781 | 55.2k | range),q); |
1782 | 55.2k | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p), |
1783 | 55.2k | range),q); |
1784 | 55.2k | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p), |
1785 | 55.2k | range),q); |
1786 | 55.2k | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlack(image,p), |
1787 | 55.2k | range),q); |
1788 | 55.2k | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p), |
1789 | 55.2k | range),q); |
1790 | 55.2k | p+=(ptrdiff_t) GetPixelChannels(image); |
1791 | 55.2k | q+=(ptrdiff_t) quantum_info->pad; |
1792 | 55.2k | } |
1793 | 2.98k | break; |
1794 | 86 | } |
1795 | 34.3k | } |
1796 | 34.3k | } |
1797 | | |
1798 | | static void ExportCMYKOQuantum(const Image *image,QuantumInfo *quantum_info, |
1799 | | const MagickSizeType number_pixels,const Quantum *magick_restrict p, |
1800 | | unsigned char *magick_restrict q,ExceptionInfo *exception) |
1801 | 0 | { |
1802 | 0 | ssize_t |
1803 | 0 | x; |
1804 | |
|
1805 | 0 | assert(exception != (ExceptionInfo *) NULL); |
1806 | 0 | assert(exception->signature == MagickCoreSignature); |
1807 | 0 | if (image->colorspace != CMYKColorspace) |
1808 | 0 | { |
1809 | 0 | (void) ThrowMagickException(exception,GetMagickModule(),ImageError, |
1810 | 0 | "ColorSeparatedImageRequired","`%s'",image->filename); |
1811 | 0 | return; |
1812 | 0 | } |
1813 | 0 | switch (quantum_info->depth) |
1814 | 0 | { |
1815 | 0 | case 8: |
1816 | 0 | { |
1817 | 0 | unsigned char |
1818 | 0 | pixel; |
1819 | |
|
1820 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
1821 | 0 | { |
1822 | 0 | pixel=ScaleQuantumToChar(GetPixelRed(image,p)); |
1823 | 0 | q=PopCharPixel(pixel,q); |
1824 | 0 | pixel=ScaleQuantumToChar(GetPixelGreen(image,p)); |
1825 | 0 | q=PopCharPixel(pixel,q); |
1826 | 0 | pixel=ScaleQuantumToChar(GetPixelBlue(image,p)); |
1827 | 0 | q=PopCharPixel(pixel,q); |
1828 | 0 | pixel=ScaleQuantumToChar(GetPixelBlack(image,p)); |
1829 | 0 | q=PopCharPixel(pixel,q); |
1830 | 0 | pixel=ScaleQuantumToChar(GetPixelOpacity(image,p)); |
1831 | 0 | q=PopCharPixel(pixel,q); |
1832 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1833 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
1834 | 0 | } |
1835 | 0 | break; |
1836 | 0 | } |
1837 | 0 | case 16: |
1838 | 0 | { |
1839 | 0 | unsigned short |
1840 | 0 | pixel; |
1841 | |
|
1842 | 0 | if (quantum_info->format == FloatingPointQuantumFormat) |
1843 | 0 | { |
1844 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
1845 | 0 | { |
1846 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
1847 | 0 | GetPixelRed(image,p)); |
1848 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
1849 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
1850 | 0 | GetPixelGreen(image,p)); |
1851 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
1852 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
1853 | 0 | GetPixelBlue(image,p)); |
1854 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
1855 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
1856 | 0 | GetPixelBlack(image,p)); |
1857 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
1858 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
1859 | 0 | GetPixelOpacity(image,p)); |
1860 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
1861 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1862 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
1863 | 0 | } |
1864 | 0 | break; |
1865 | 0 | } |
1866 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
1867 | 0 | { |
1868 | 0 | pixel=ScaleQuantumToShort(GetPixelRed(image,p)); |
1869 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
1870 | 0 | pixel=ScaleQuantumToShort(GetPixelGreen(image,p)); |
1871 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
1872 | 0 | pixel=ScaleQuantumToShort(GetPixelBlue(image,p)); |
1873 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
1874 | 0 | pixel=ScaleQuantumToShort(GetPixelBlack(image,p)); |
1875 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
1876 | 0 | pixel=ScaleQuantumToShort(GetPixelOpacity(image,p)); |
1877 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
1878 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1879 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
1880 | 0 | } |
1881 | 0 | break; |
1882 | 0 | } |
1883 | 0 | case 32: |
1884 | 0 | { |
1885 | 0 | unsigned int |
1886 | 0 | pixel; |
1887 | |
|
1888 | 0 | if (quantum_info->format == FloatingPointQuantumFormat) |
1889 | 0 | { |
1890 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
1891 | 0 | { |
1892 | 0 | float |
1893 | 0 | float_pixel; |
1894 | |
|
1895 | 0 | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelRed(image,p),q); |
1896 | 0 | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q); |
1897 | 0 | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q); |
1898 | 0 | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelBlack(image,p),q); |
1899 | 0 | float_pixel=(float) (GetPixelOpacity(image,p)); |
1900 | 0 | q=PopQuantumFloatPixel(quantum_info,float_pixel,q); |
1901 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1902 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
1903 | 0 | } |
1904 | 0 | break; |
1905 | 0 | } |
1906 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
1907 | 0 | { |
1908 | 0 | pixel=ScaleQuantumToLong(GetPixelRed(image,p)); |
1909 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
1910 | 0 | pixel=ScaleQuantumToLong(GetPixelGreen(image,p)); |
1911 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
1912 | 0 | pixel=ScaleQuantumToLong(GetPixelBlue(image,p)); |
1913 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
1914 | 0 | pixel=ScaleQuantumToLong(GetPixelBlack(image,p)); |
1915 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
1916 | 0 | pixel=ScaleQuantumToLong(GetPixelOpacity(image,p)); |
1917 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
1918 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1919 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
1920 | 0 | } |
1921 | 0 | break; |
1922 | 0 | } |
1923 | 0 | case 64: |
1924 | 0 | { |
1925 | 0 | if (quantum_info->format == FloatingPointQuantumFormat) |
1926 | 0 | { |
1927 | 0 | double |
1928 | 0 | pixel; |
1929 | |
|
1930 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
1931 | 0 | { |
1932 | 0 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelRed(image,p),q); |
1933 | 0 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q); |
1934 | 0 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q); |
1935 | 0 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelBlack(image,p),q); |
1936 | 0 | pixel=(double) (GetPixelOpacity(image,p)); |
1937 | 0 | q=PopQuantumDoublePixel(quantum_info,pixel,q); |
1938 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1939 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
1940 | 0 | } |
1941 | 0 | break; |
1942 | 0 | } |
1943 | 0 | magick_fallthrough; |
1944 | 0 | } |
1945 | 0 | default: |
1946 | 0 | { |
1947 | 0 | QuantumAny |
1948 | 0 | range; |
1949 | |
|
1950 | 0 | range=GetQuantumRange(quantum_info->depth); |
1951 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
1952 | 0 | { |
1953 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p), |
1954 | 0 | range),q); |
1955 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p), |
1956 | 0 | range),q); |
1957 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p), |
1958 | 0 | range),q); |
1959 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlack(image,p), |
1960 | 0 | range),q); |
1961 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelOpacity(image,p), |
1962 | 0 | range),q); |
1963 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
1964 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
1965 | 0 | } |
1966 | 0 | break; |
1967 | 0 | } |
1968 | 0 | } |
1969 | 0 | } |
1970 | | |
1971 | | static void ExportGrayQuantum(const Image *image,QuantumInfo *quantum_info, |
1972 | | const MagickSizeType number_pixels,const Quantum *magick_restrict p, |
1973 | | unsigned char *magick_restrict q) |
1974 | 786k | { |
1975 | 786k | QuantumAny |
1976 | 786k | range; |
1977 | | |
1978 | 786k | ssize_t |
1979 | 786k | x; |
1980 | | |
1981 | 786k | switch (quantum_info->depth) |
1982 | 786k | { |
1983 | 222k | case 1: |
1984 | 222k | { |
1985 | 222k | double |
1986 | 222k | threshold; |
1987 | | |
1988 | 222k | unsigned char |
1989 | 222k | black, |
1990 | 222k | white; |
1991 | | |
1992 | 222k | ssize_t |
1993 | 222k | bit; |
1994 | | |
1995 | 222k | black=0x00; |
1996 | 222k | white=0x01; |
1997 | 222k | if (quantum_info->min_is_white != MagickFalse) |
1998 | 17.2k | { |
1999 | 17.2k | black=0x01; |
2000 | 17.2k | white=0x00; |
2001 | 17.2k | } |
2002 | 222k | threshold=(double) QuantumRange/2.0; |
2003 | 28.4M | for (x=((ssize_t) number_pixels-7); x > 0; x-=8) |
2004 | 28.2M | { |
2005 | 28.2M | *q='\0'; |
2006 | 28.2M | *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 7; |
2007 | 28.2M | p+=(ptrdiff_t) GetPixelChannels(image); |
2008 | 28.2M | *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 6; |
2009 | 28.2M | p+=(ptrdiff_t) GetPixelChannels(image); |
2010 | 28.2M | *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 5; |
2011 | 28.2M | p+=(ptrdiff_t) GetPixelChannels(image); |
2012 | 28.2M | *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 4; |
2013 | 28.2M | p+=(ptrdiff_t) GetPixelChannels(image); |
2014 | 28.2M | *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 3; |
2015 | 28.2M | p+=(ptrdiff_t) GetPixelChannels(image); |
2016 | 28.2M | *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 2; |
2017 | 28.2M | p+=(ptrdiff_t) GetPixelChannels(image); |
2018 | 28.2M | *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 1; |
2019 | 28.2M | p+=(ptrdiff_t) GetPixelChannels(image); |
2020 | 28.2M | *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 0; |
2021 | 28.2M | p+=(ptrdiff_t) GetPixelChannels(image); |
2022 | 28.2M | q++; |
2023 | 28.2M | } |
2024 | 222k | if ((number_pixels % 8) != 0) |
2025 | 127k | { |
2026 | 127k | *q='\0'; |
2027 | 665k | for (bit=7; bit >= (ssize_t) (8-(number_pixels % 8)); bit--) |
2028 | 537k | { |
2029 | 537k | *q|=(GetPixelLuma(image,p) < threshold ? black : white) << bit; |
2030 | 537k | p+=(ptrdiff_t) GetPixelChannels(image); |
2031 | 537k | } |
2032 | 127k | q++; |
2033 | 127k | } |
2034 | 222k | break; |
2035 | 0 | } |
2036 | 13.0k | case 4: |
2037 | 13.0k | { |
2038 | 13.0k | unsigned char |
2039 | 13.0k | pixel; |
2040 | | |
2041 | 58.9k | for (x=0; x < (ssize_t) (number_pixels-1) ; x+=2) |
2042 | 45.9k | { |
2043 | 45.9k | pixel=ScaleQuantumToChar(ClampToQuantum(GetPixelLuma(image,p))); |
2044 | 45.9k | *q=(((pixel >> 4) & 0xf) << 4); |
2045 | 45.9k | p+=(ptrdiff_t) GetPixelChannels(image); |
2046 | 45.9k | pixel=ScaleQuantumToChar(ClampToQuantum(GetPixelLuma(image,p))); |
2047 | 45.9k | *q|=pixel >> 4; |
2048 | 45.9k | p+=(ptrdiff_t) GetPixelChannels(image); |
2049 | 45.9k | q++; |
2050 | 45.9k | } |
2051 | 13.0k | if ((number_pixels % 2) != 0) |
2052 | 9.54k | { |
2053 | 9.54k | pixel=ScaleQuantumToChar(ClampToQuantum(GetPixelLuma(image,p))); |
2054 | 9.54k | *q=(((pixel >> 4) & 0xf) << 4); |
2055 | 9.54k | p+=(ptrdiff_t) GetPixelChannels(image); |
2056 | 9.54k | q++; |
2057 | 9.54k | } |
2058 | 13.0k | break; |
2059 | 0 | } |
2060 | 466k | case 8: |
2061 | 466k | { |
2062 | 466k | unsigned char |
2063 | 466k | pixel; |
2064 | | |
2065 | 212M | for (x=0; x < (ssize_t) number_pixels; x++) |
2066 | 211M | { |
2067 | 211M | pixel=ScaleQuantumToChar(ClampToQuantum(GetPixelLuma(image,p))); |
2068 | 211M | q=PopCharPixel(pixel,q); |
2069 | 211M | p+=(ptrdiff_t) GetPixelChannels(image); |
2070 | 211M | q+=(ptrdiff_t) quantum_info->pad; |
2071 | 211M | } |
2072 | 466k | break; |
2073 | 0 | } |
2074 | 3.92k | case 10: |
2075 | 3.92k | { |
2076 | 3.92k | range=GetQuantumRange(quantum_info->depth); |
2077 | 3.92k | if (quantum_info->pack == MagickFalse) |
2078 | 2.07k | { |
2079 | 2.07k | unsigned int |
2080 | 2.07k | pixel; |
2081 | | |
2082 | 9.27k | for (x=0; x < (ssize_t) (number_pixels-2); x+=3) |
2083 | 7.19k | { |
2084 | 7.19k | pixel=(unsigned int) (ScaleQuantumToAny(ClampToQuantum( |
2085 | 7.19k | GetPixelLuma(image,p+2*GetPixelChannels(image))),range) << 22 | |
2086 | 7.19k | ScaleQuantumToAny(ClampToQuantum(GetPixelLuma(image,p+ |
2087 | 7.19k | GetPixelChannels(image))),range) << 12 | ScaleQuantumToAny( |
2088 | 7.19k | ClampToQuantum(GetPixelLuma(image,p)),range) << 2); |
2089 | 7.19k | q=PopLongPixel(quantum_info->endian,pixel,q); |
2090 | 7.19k | p+=(ptrdiff_t) 3*GetPixelChannels(image); |
2091 | 7.19k | q+=(ptrdiff_t) quantum_info->pad; |
2092 | 7.19k | } |
2093 | 2.07k | if (x < (ssize_t) number_pixels) |
2094 | 1.81k | { |
2095 | 1.81k | pixel=0U; |
2096 | 1.81k | if (x++ < (ssize_t) (number_pixels-1)) |
2097 | 1.14k | pixel|=ScaleQuantumToAny(ClampToQuantum(GetPixelLuma(image,p+ |
2098 | 1.14k | GetPixelChannels(image))),range) << 12; |
2099 | 1.81k | if (x++ < (ssize_t) number_pixels) |
2100 | 1.14k | pixel|=ScaleQuantumToAny(ClampToQuantum(GetPixelLuma(image,p)), |
2101 | 1.14k | range) << 2; |
2102 | 1.81k | q=PopLongPixel(quantum_info->endian,pixel,q); |
2103 | 1.81k | } |
2104 | 2.07k | break; |
2105 | 2.07k | } |
2106 | 19.5k | for (x=0; x < (ssize_t) number_pixels; x++) |
2107 | 17.7k | { |
2108 | 17.7k | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(ClampToQuantum( |
2109 | 17.7k | GetPixelLuma(image,p)),range),q); |
2110 | 17.7k | p+=(ptrdiff_t) GetPixelChannels(image); |
2111 | 17.7k | q+=(ptrdiff_t) quantum_info->pad; |
2112 | 17.7k | } |
2113 | 1.84k | break; |
2114 | 3.92k | } |
2115 | 6.81k | case 12: |
2116 | 6.81k | { |
2117 | 6.81k | unsigned short |
2118 | 6.81k | pixel; |
2119 | | |
2120 | 6.81k | range=GetQuantumRange(quantum_info->depth); |
2121 | 6.81k | if (quantum_info->pack == MagickFalse) |
2122 | 4.03k | { |
2123 | 14.0k | for (x=0; x < (ssize_t) number_pixels; x++) |
2124 | 10.0k | { |
2125 | 10.0k | pixel=ScaleQuantumToShort(ClampToQuantum(GetPixelLuma(image,p))); |
2126 | 10.0k | q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel >> 4), |
2127 | 10.0k | q); |
2128 | 10.0k | p+=(ptrdiff_t) GetPixelChannels(image); |
2129 | 10.0k | q+=(ptrdiff_t) quantum_info->pad; |
2130 | 10.0k | } |
2131 | 4.03k | break; |
2132 | 4.03k | } |
2133 | 37.5k | for (x=0; x < (ssize_t) number_pixels; x++) |
2134 | 34.7k | { |
2135 | 34.7k | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(ClampToQuantum( |
2136 | 34.7k | GetPixelLuma(image,p)),range),q); |
2137 | 34.7k | p+=(ptrdiff_t) GetPixelChannels(image); |
2138 | 34.7k | q+=(ptrdiff_t) quantum_info->pad; |
2139 | 34.7k | } |
2140 | 2.77k | break; |
2141 | 6.81k | } |
2142 | 34.4k | case 16: |
2143 | 34.4k | { |
2144 | 34.4k | unsigned short |
2145 | 34.4k | pixel; |
2146 | | |
2147 | 34.4k | if (quantum_info->format == FloatingPointQuantumFormat) |
2148 | 1.38k | { |
2149 | 8.80k | for (x=0; x < (ssize_t) number_pixels; x++) |
2150 | 7.42k | { |
2151 | 7.42k | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
2152 | 7.42k | GetPixelLuma(image,p)); |
2153 | 7.42k | q=PopShortPixel(quantum_info->endian,pixel,q); |
2154 | 7.42k | p+=(ptrdiff_t) GetPixelChannels(image); |
2155 | 7.42k | q+=(ptrdiff_t) quantum_info->pad; |
2156 | 7.42k | } |
2157 | 1.38k | break; |
2158 | 1.38k | } |
2159 | 29.0M | for (x=0; x < (ssize_t) number_pixels; x++) |
2160 | 29.0M | { |
2161 | 29.0M | pixel=ScaleQuantumToShort(ClampToQuantum(GetPixelLuma(image,p))); |
2162 | 29.0M | q=PopShortPixel(quantum_info->endian,pixel,q); |
2163 | 29.0M | p+=(ptrdiff_t) GetPixelChannels(image); |
2164 | 29.0M | q+=(ptrdiff_t) quantum_info->pad; |
2165 | 29.0M | } |
2166 | 33.0k | break; |
2167 | 34.4k | } |
2168 | 23.4k | case 32: |
2169 | 23.4k | { |
2170 | 23.4k | unsigned int |
2171 | 23.4k | pixel; |
2172 | | |
2173 | 23.4k | if (quantum_info->format == FloatingPointQuantumFormat) |
2174 | 15.9k | { |
2175 | 54.9k | for (x=0; x < (ssize_t) number_pixels; x++) |
2176 | 38.9k | { |
2177 | 38.9k | float |
2178 | 38.9k | float_pixel; |
2179 | | |
2180 | 38.9k | float_pixel=(float) GetPixelLuma(image,p); |
2181 | 38.9k | q=PopQuantumFloatPixel(quantum_info,float_pixel,q); |
2182 | 38.9k | p+=(ptrdiff_t) GetPixelChannels(image); |
2183 | 38.9k | q+=(ptrdiff_t) quantum_info->pad; |
2184 | 38.9k | } |
2185 | 15.9k | break; |
2186 | 15.9k | } |
2187 | 7.90M | for (x=0; x < (ssize_t) number_pixels; x++) |
2188 | 7.89M | { |
2189 | 7.89M | pixel=ScaleQuantumToLong(ClampToQuantum(GetPixelLuma(image,p))); |
2190 | 7.89M | q=PopLongPixel(quantum_info->endian,pixel,q); |
2191 | 7.89M | p+=(ptrdiff_t) GetPixelChannels(image); |
2192 | 7.89M | q+=(ptrdiff_t) quantum_info->pad; |
2193 | 7.89M | } |
2194 | 7.51k | break; |
2195 | 23.4k | } |
2196 | 805 | case 64: |
2197 | 805 | { |
2198 | 805 | if (quantum_info->format == FloatingPointQuantumFormat) |
2199 | 171 | { |
2200 | 747 | for (x=0; x < (ssize_t) number_pixels; x++) |
2201 | 576 | { |
2202 | 576 | double |
2203 | 576 | pixel; |
2204 | | |
2205 | 576 | pixel=GetPixelLuma(image,p); |
2206 | 576 | q=PopQuantumDoublePixel(quantum_info,pixel,q); |
2207 | 576 | p+=(ptrdiff_t) GetPixelChannels(image); |
2208 | 576 | q+=(ptrdiff_t) quantum_info->pad; |
2209 | 576 | } |
2210 | 171 | break; |
2211 | 171 | } |
2212 | 634 | magick_fallthrough; |
2213 | 634 | } |
2214 | 14.9k | default: |
2215 | 14.9k | { |
2216 | 14.9k | range=GetQuantumRange(quantum_info->depth); |
2217 | 71.0k | for (x=0; x < (ssize_t) number_pixels; x++) |
2218 | 56.0k | { |
2219 | 56.0k | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(ClampToQuantum( |
2220 | 56.0k | GetPixelLuma(image,p)),range),q); |
2221 | 56.0k | p+=(ptrdiff_t) GetPixelChannels(image); |
2222 | 56.0k | q+=(ptrdiff_t) quantum_info->pad; |
2223 | 56.0k | } |
2224 | 14.9k | break; |
2225 | 634 | } |
2226 | 786k | } |
2227 | 786k | } |
2228 | | |
2229 | | static void ExportGrayAlphaQuantum(const Image *image,QuantumInfo *quantum_info, |
2230 | | const MagickSizeType number_pixels,const Quantum *magick_restrict p, |
2231 | | unsigned char *magick_restrict q) |
2232 | 30.1k | { |
2233 | 30.1k | QuantumAny |
2234 | 30.1k | range; |
2235 | | |
2236 | 30.1k | ssize_t |
2237 | 30.1k | x; |
2238 | | |
2239 | 30.1k | switch (quantum_info->depth) |
2240 | 30.1k | { |
2241 | 2.87k | case 1: |
2242 | 2.87k | { |
2243 | 2.87k | double |
2244 | 2.87k | threshold; |
2245 | | |
2246 | 2.87k | unsigned char |
2247 | 2.87k | black, |
2248 | 2.87k | pixel, |
2249 | 2.87k | white; |
2250 | | |
2251 | 2.87k | ssize_t |
2252 | 2.87k | bit; |
2253 | | |
2254 | 2.87k | black=0x00; |
2255 | 2.87k | white=0x01; |
2256 | 2.87k | if (quantum_info->min_is_white != MagickFalse) |
2257 | 0 | { |
2258 | 0 | black=0x01; |
2259 | 0 | white=0x00; |
2260 | 0 | } |
2261 | 2.87k | threshold=(double) QuantumRange/2.0; |
2262 | 10.6k | for (x=((ssize_t) number_pixels-3); x > 0; x-=4) |
2263 | 7.76k | { |
2264 | 7.76k | *q='\0'; |
2265 | 7.76k | *q|=(GetPixelLuma(image,p) > threshold ? black : white) << 7; |
2266 | 7.76k | pixel=(unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ? |
2267 | 5.43k | 0x00 : 0x01); |
2268 | 7.76k | *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 6); |
2269 | 7.76k | p+=(ptrdiff_t) GetPixelChannels(image); |
2270 | 7.76k | *q|=(GetPixelLuma(image,p) > threshold ? black : white) << 5; |
2271 | 7.76k | pixel=(unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ? |
2272 | 5.38k | 0x00 : 0x01); |
2273 | 7.76k | *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 4); |
2274 | 7.76k | p+=(ptrdiff_t) GetPixelChannels(image); |
2275 | 7.76k | *q|=(GetPixelLuma(image,p) > threshold ? black : white) << 3; |
2276 | 7.76k | pixel=(unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ? |
2277 | 5.49k | 0x00 : 0x01); |
2278 | 7.76k | *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 2); |
2279 | 7.76k | p+=(ptrdiff_t) GetPixelChannels(image); |
2280 | 7.76k | *q|=(GetPixelLuma(image,p) > threshold ? black : white) << 1; |
2281 | 7.76k | pixel=(unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ? |
2282 | 5.73k | 0x00 : 0x01); |
2283 | 7.76k | *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 0); |
2284 | 7.76k | p+=(ptrdiff_t) GetPixelChannels(image); |
2285 | 7.76k | q++; |
2286 | 7.76k | } |
2287 | 2.87k | if ((number_pixels % 4) != 0) |
2288 | 2.14k | { |
2289 | 2.14k | *q='\0'; |
2290 | 5.63k | for (bit=0; bit <= (ssize_t) (number_pixels % 4); bit+=2) |
2291 | 3.49k | { |
2292 | 3.49k | *q|=(GetPixelLuma(image,p) > threshold ? black : white) << |
2293 | 3.49k | (7-bit); |
2294 | 3.49k | pixel=(unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ? |
2295 | 2.22k | 0x00 : 0x01); |
2296 | 3.49k | *q|=(((int) pixel != 0 ? 0x00 : 0x01) << (unsigned char) |
2297 | 3.49k | (7-bit-1)); |
2298 | 3.49k | p+=(ptrdiff_t) GetPixelChannels(image); |
2299 | 3.49k | } |
2300 | 2.14k | q++; |
2301 | 2.14k | } |
2302 | 2.87k | break; |
2303 | 0 | } |
2304 | 3.83k | case 4: |
2305 | 3.83k | { |
2306 | 3.83k | unsigned char |
2307 | 3.83k | pixel; |
2308 | | |
2309 | 71.8k | for (x=0; x < (ssize_t) number_pixels ; x++) |
2310 | 68.0k | { |
2311 | 68.0k | pixel=ScaleQuantumToChar(ClampToQuantum(GetPixelLuma(image,p))); |
2312 | 68.0k | *q=(((pixel >> 4) & 0xf) << 4); |
2313 | 68.0k | pixel=(unsigned char) (16.0*QuantumScale*(double) |
2314 | 68.0k | GetPixelAlpha(image,p)+0.5); |
2315 | 68.0k | *q|=pixel & 0xf; |
2316 | 68.0k | p+=(ptrdiff_t) GetPixelChannels(image); |
2317 | 68.0k | q++; |
2318 | 68.0k | } |
2319 | 3.83k | break; |
2320 | 0 | } |
2321 | 5.08k | case 8: |
2322 | 5.08k | { |
2323 | 5.08k | unsigned char |
2324 | 5.08k | pixel; |
2325 | | |
2326 | 4.40M | for (x=0; x < (ssize_t) number_pixels; x++) |
2327 | 4.39M | { |
2328 | 4.39M | pixel=ScaleQuantumToChar(ClampToQuantum(GetPixelLuma(image,p))); |
2329 | 4.39M | q=PopCharPixel(pixel,q); |
2330 | 4.39M | pixel=ScaleQuantumToChar(GetPixelAlpha(image,p)); |
2331 | 4.39M | q=PopCharPixel(pixel,q); |
2332 | 4.39M | p+=(ptrdiff_t) GetPixelChannels(image); |
2333 | 4.39M | q+=(ptrdiff_t) quantum_info->pad; |
2334 | 4.39M | } |
2335 | 5.08k | break; |
2336 | 0 | } |
2337 | 4.68k | case 16: |
2338 | 4.68k | { |
2339 | 4.68k | unsigned short |
2340 | 4.68k | pixel; |
2341 | | |
2342 | 4.68k | if (quantum_info->format == FloatingPointQuantumFormat) |
2343 | 1.43k | { |
2344 | 6.29k | for (x=0; x < (ssize_t) number_pixels; x++) |
2345 | 4.86k | { |
2346 | 4.86k | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
2347 | 4.86k | GetPixelLuma(image,p)); |
2348 | 4.86k | q=PopShortPixel(quantum_info->endian,pixel,q); |
2349 | 4.86k | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
2350 | 4.86k | GetPixelAlpha(image,p)); |
2351 | 4.86k | q=PopShortPixel(quantum_info->endian,pixel,q); |
2352 | 4.86k | p+=(ptrdiff_t) GetPixelChannels(image); |
2353 | 4.86k | q+=(ptrdiff_t) quantum_info->pad; |
2354 | 4.86k | } |
2355 | 1.43k | break; |
2356 | 1.43k | } |
2357 | 37.5k | for (x=0; x < (ssize_t) number_pixels; x++) |
2358 | 34.2k | { |
2359 | 34.2k | pixel=ScaleQuantumToShort(ClampToQuantum(GetPixelLuma(image,p))); |
2360 | 34.2k | q=PopShortPixel(quantum_info->endian,pixel,q); |
2361 | 34.2k | pixel=ScaleQuantumToShort(GetPixelAlpha(image,p)); |
2362 | 34.2k | q=PopShortPixel(quantum_info->endian,pixel,q); |
2363 | 34.2k | p+=(ptrdiff_t) GetPixelChannels(image); |
2364 | 34.2k | q+=(ptrdiff_t) quantum_info->pad; |
2365 | 34.2k | } |
2366 | 3.25k | break; |
2367 | 4.68k | } |
2368 | 10.8k | case 32: |
2369 | 10.8k | { |
2370 | 10.8k | unsigned int |
2371 | 10.8k | pixel; |
2372 | | |
2373 | 10.8k | if (quantum_info->format == FloatingPointQuantumFormat) |
2374 | 5.26k | { |
2375 | 29.0k | for (x=0; x < (ssize_t) number_pixels; x++) |
2376 | 23.7k | { |
2377 | 23.7k | float |
2378 | 23.7k | float_pixel; |
2379 | | |
2380 | 23.7k | float_pixel=(float) GetPixelLuma(image,p); |
2381 | 23.7k | q=PopQuantumFloatPixel(quantum_info,float_pixel,q); |
2382 | 23.7k | float_pixel=(float) (GetPixelAlpha(image,p)); |
2383 | 23.7k | q=PopQuantumFloatPixel(quantum_info,float_pixel,q); |
2384 | 23.7k | p+=(ptrdiff_t) GetPixelChannels(image); |
2385 | 23.7k | q+=(ptrdiff_t) quantum_info->pad; |
2386 | 23.7k | } |
2387 | 5.26k | break; |
2388 | 5.26k | } |
2389 | 3.89M | for (x=0; x < (ssize_t) number_pixels; x++) |
2390 | 3.88M | { |
2391 | 3.88M | pixel=ScaleQuantumToLong(ClampToQuantum(GetPixelLuma(image,p))); |
2392 | 3.88M | q=PopLongPixel(quantum_info->endian,pixel,q); |
2393 | 3.88M | pixel=ScaleQuantumToLong(GetPixelAlpha(image,p)); |
2394 | 3.88M | q=PopLongPixel(quantum_info->endian,pixel,q); |
2395 | 3.88M | p+=(ptrdiff_t) GetPixelChannels(image); |
2396 | 3.88M | q+=(ptrdiff_t) quantum_info->pad; |
2397 | 3.88M | } |
2398 | 5.58k | break; |
2399 | 10.8k | } |
2400 | 307 | case 64: |
2401 | 307 | { |
2402 | 307 | if (quantum_info->format == FloatingPointQuantumFormat) |
2403 | 147 | { |
2404 | 386 | for (x=0; x < (ssize_t) number_pixels; x++) |
2405 | 239 | { |
2406 | 239 | double |
2407 | 239 | pixel; |
2408 | | |
2409 | 239 | pixel=GetPixelLuma(image,p); |
2410 | 239 | q=PopQuantumDoublePixel(quantum_info,pixel,q); |
2411 | 239 | pixel=(double) (GetPixelAlpha(image,p)); |
2412 | 239 | q=PopQuantumDoublePixel(quantum_info,pixel,q); |
2413 | 239 | p+=(ptrdiff_t) GetPixelChannels(image); |
2414 | 239 | q+=(ptrdiff_t) quantum_info->pad; |
2415 | 239 | } |
2416 | 147 | break; |
2417 | 147 | } |
2418 | 160 | magick_fallthrough; |
2419 | 160 | } |
2420 | 2.68k | default: |
2421 | 2.68k | { |
2422 | 2.68k | range=GetQuantumRange(quantum_info->depth); |
2423 | 17.8k | for (x=0; x < (ssize_t) number_pixels; x++) |
2424 | 15.1k | { |
2425 | 15.1k | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(ClampToQuantum( |
2426 | 15.1k | GetPixelLuma(image,p)),range),q); |
2427 | 15.1k | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p), |
2428 | 15.1k | range),q); |
2429 | 15.1k | p+=(ptrdiff_t) GetPixelChannels(image); |
2430 | 15.1k | q+=(ptrdiff_t) quantum_info->pad; |
2431 | 15.1k | } |
2432 | 2.68k | break; |
2433 | 160 | } |
2434 | 30.1k | } |
2435 | 30.1k | } |
2436 | | |
2437 | | static void ExportGreenQuantum(const Image *image,QuantumInfo *quantum_info, |
2438 | | const MagickSizeType number_pixels,const Quantum *magick_restrict p, |
2439 | | unsigned char *magick_restrict q) |
2440 | 51.6k | { |
2441 | 51.6k | QuantumAny |
2442 | 51.6k | range; |
2443 | | |
2444 | 51.6k | ssize_t |
2445 | 51.6k | x; |
2446 | | |
2447 | 51.6k | switch (quantum_info->depth) |
2448 | 51.6k | { |
2449 | 40.4k | case 8: |
2450 | 40.4k | { |
2451 | 40.4k | unsigned char |
2452 | 40.4k | pixel; |
2453 | | |
2454 | 413k | for (x=0; x < (ssize_t) number_pixels; x++) |
2455 | 373k | { |
2456 | 373k | pixel=ScaleQuantumToChar(GetPixelGreen(image,p)); |
2457 | 373k | q=PopCharPixel(pixel,q); |
2458 | 373k | p+=(ptrdiff_t) GetPixelChannels(image); |
2459 | 373k | q+=(ptrdiff_t) quantum_info->pad; |
2460 | 373k | } |
2461 | 40.4k | break; |
2462 | 0 | } |
2463 | 7.23k | case 16: |
2464 | 7.23k | { |
2465 | 7.23k | unsigned short |
2466 | 7.23k | pixel; |
2467 | | |
2468 | 7.23k | if (quantum_info->format == FloatingPointQuantumFormat) |
2469 | 0 | { |
2470 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
2471 | 0 | { |
2472 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
2473 | 0 | GetPixelGreen(image,p)); |
2474 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
2475 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
2476 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
2477 | 0 | } |
2478 | 0 | break; |
2479 | 0 | } |
2480 | 33.3k | for (x=0; x < (ssize_t) number_pixels; x++) |
2481 | 26.0k | { |
2482 | 26.0k | pixel=ScaleQuantumToShort(GetPixelGreen(image,p)); |
2483 | 26.0k | q=PopShortPixel(quantum_info->endian,pixel,q); |
2484 | 26.0k | p+=(ptrdiff_t) GetPixelChannels(image); |
2485 | 26.0k | q+=(ptrdiff_t) quantum_info->pad; |
2486 | 26.0k | } |
2487 | 7.23k | break; |
2488 | 7.23k | } |
2489 | 1.79k | case 32: |
2490 | 1.79k | { |
2491 | 1.79k | unsigned int |
2492 | 1.79k | pixel; |
2493 | | |
2494 | 1.79k | if (quantum_info->format == FloatingPointQuantumFormat) |
2495 | 987 | { |
2496 | 5.47k | for (x=0; x < (ssize_t) number_pixels; x++) |
2497 | 4.48k | { |
2498 | 4.48k | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q); |
2499 | 4.48k | p+=(ptrdiff_t) GetPixelChannels(image); |
2500 | 4.48k | q+=(ptrdiff_t) quantum_info->pad; |
2501 | 4.48k | } |
2502 | 987 | break; |
2503 | 987 | } |
2504 | 8.01k | for (x=0; x < (ssize_t) number_pixels; x++) |
2505 | 7.20k | { |
2506 | 7.20k | pixel=ScaleQuantumToLong(GetPixelGreen(image,p)); |
2507 | 7.20k | q=PopLongPixel(quantum_info->endian,pixel,q); |
2508 | 7.20k | p+=(ptrdiff_t) GetPixelChannels(image); |
2509 | 7.20k | q+=(ptrdiff_t) quantum_info->pad; |
2510 | 7.20k | } |
2511 | 808 | break; |
2512 | 1.79k | } |
2513 | 2.14k | case 64: |
2514 | 2.14k | { |
2515 | 2.14k | if (quantum_info->format == FloatingPointQuantumFormat) |
2516 | 464 | { |
2517 | 1.44k | for (x=0; x < (ssize_t) number_pixels; x++) |
2518 | 977 | { |
2519 | 977 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q); |
2520 | 977 | p+=(ptrdiff_t) GetPixelChannels(image); |
2521 | 977 | q+=(ptrdiff_t) quantum_info->pad; |
2522 | 977 | } |
2523 | 464 | break; |
2524 | 464 | } |
2525 | 1.67k | magick_fallthrough; |
2526 | 1.67k | } |
2527 | 1.67k | default: |
2528 | 1.67k | { |
2529 | 1.67k | range=GetQuantumRange(quantum_info->depth); |
2530 | 9.95k | for (x=0; x < (ssize_t) number_pixels; x++) |
2531 | 8.27k | { |
2532 | 8.27k | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p), |
2533 | 8.27k | range),q); |
2534 | 8.27k | p+=(ptrdiff_t) GetPixelChannels(image); |
2535 | 8.27k | q+=(ptrdiff_t) quantum_info->pad; |
2536 | 8.27k | } |
2537 | 1.67k | break; |
2538 | 1.67k | } |
2539 | 51.6k | } |
2540 | 51.6k | } |
2541 | | |
2542 | | static void ExportIndexQuantum(const Image *image,QuantumInfo *quantum_info, |
2543 | | const MagickSizeType number_pixels,const Quantum *magick_restrict p, |
2544 | | unsigned char *magick_restrict q,ExceptionInfo *exception) |
2545 | 186k | { |
2546 | 186k | ssize_t |
2547 | 186k | x; |
2548 | | |
2549 | 186k | ssize_t |
2550 | 186k | bit; |
2551 | | |
2552 | 186k | if (image->storage_class != PseudoClass) |
2553 | 35 | { |
2554 | 35 | (void) ThrowMagickException(exception,GetMagickModule(),ImageError, |
2555 | 35 | "ColormappedImageRequired","`%s'",image->filename); |
2556 | 35 | return; |
2557 | 35 | } |
2558 | 186k | switch (quantum_info->depth) |
2559 | 186k | { |
2560 | 0 | case 1: |
2561 | 0 | { |
2562 | 0 | unsigned char |
2563 | 0 | pixel; |
2564 | |
|
2565 | 0 | for (x=((ssize_t) number_pixels-7); x > 0; x-=8) |
2566 | 0 | { |
2567 | 0 | pixel=(unsigned char) ((ssize_t) GetPixelIndex(image,p)); |
2568 | 0 | *q=((pixel & 0x01) << 7); |
2569 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
2570 | 0 | pixel=(unsigned char) ((ssize_t) GetPixelIndex(image,p)); |
2571 | 0 | *q|=((pixel & 0x01) << 6); |
2572 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
2573 | 0 | pixel=(unsigned char) ((ssize_t) GetPixelIndex(image,p)); |
2574 | 0 | *q|=((pixel & 0x01) << 5); |
2575 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
2576 | 0 | pixel=(unsigned char) ((ssize_t) GetPixelIndex(image,p)); |
2577 | 0 | *q|=((pixel & 0x01) << 4); |
2578 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
2579 | 0 | pixel=(unsigned char) ((ssize_t) GetPixelIndex(image,p)); |
2580 | 0 | *q|=((pixel & 0x01) << 3); |
2581 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
2582 | 0 | pixel=(unsigned char) ((ssize_t) GetPixelIndex(image,p)); |
2583 | 0 | *q|=((pixel & 0x01) << 2); |
2584 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
2585 | 0 | pixel=(unsigned char) ((ssize_t) GetPixelIndex(image,p)); |
2586 | 0 | *q|=((pixel & 0x01) << 1); |
2587 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
2588 | 0 | pixel=(unsigned char) ((ssize_t) GetPixelIndex(image,p)); |
2589 | 0 | *q|=((pixel & 0x01) << 0); |
2590 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
2591 | 0 | q++; |
2592 | 0 | } |
2593 | 0 | if ((number_pixels % 8) != 0) |
2594 | 0 | { |
2595 | 0 | *q='\0'; |
2596 | 0 | for (bit=7; bit >= (ssize_t) (8-(number_pixels % 8)); bit--) |
2597 | 0 | { |
2598 | 0 | pixel=(unsigned char) ((ssize_t) GetPixelIndex(image,p)); |
2599 | 0 | *q|=((pixel & 0x01) << (unsigned char) bit); |
2600 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
2601 | 0 | } |
2602 | 0 | q++; |
2603 | 0 | } |
2604 | 0 | break; |
2605 | 0 | } |
2606 | 34.8k | case 4: |
2607 | 34.8k | { |
2608 | 34.8k | unsigned char |
2609 | 34.8k | pixel; |
2610 | | |
2611 | 6.20M | for (x=0; x < (ssize_t) (number_pixels-1) ; x+=2) |
2612 | 6.17M | { |
2613 | 6.17M | pixel=(unsigned char) ((ssize_t) GetPixelIndex(image,p)); |
2614 | 6.17M | *q=((pixel & 0xf) << 4); |
2615 | 6.17M | p+=(ptrdiff_t) GetPixelChannels(image); |
2616 | 6.17M | pixel=(unsigned char) ((ssize_t) GetPixelIndex(image,p)); |
2617 | 6.17M | *q|=((pixel & 0xf) << 0); |
2618 | 6.17M | p+=(ptrdiff_t) GetPixelChannels(image); |
2619 | 6.17M | q++; |
2620 | 6.17M | } |
2621 | 34.8k | if ((number_pixels % 2) != 0) |
2622 | 19.6k | { |
2623 | 19.6k | pixel=(unsigned char) ((ssize_t) GetPixelIndex(image,p)); |
2624 | 19.6k | *q=((pixel & 0xf) << 4); |
2625 | 19.6k | p+=(ptrdiff_t) GetPixelChannels(image); |
2626 | 19.6k | q++; |
2627 | 19.6k | } |
2628 | 34.8k | break; |
2629 | 0 | } |
2630 | 141k | case 8: |
2631 | 141k | { |
2632 | 93.8M | for (x=0; x < (ssize_t) number_pixels; x++) |
2633 | 93.7M | { |
2634 | 93.7M | q=PopCharPixel((unsigned char) ((ssize_t) GetPixelIndex(image,p)),q); |
2635 | 93.7M | p+=(ptrdiff_t) GetPixelChannels(image); |
2636 | 93.7M | q+=(ptrdiff_t) quantum_info->pad; |
2637 | 93.7M | } |
2638 | 141k | break; |
2639 | 0 | } |
2640 | 4.70k | case 16: |
2641 | 4.70k | { |
2642 | 4.70k | if (quantum_info->format == FloatingPointQuantumFormat) |
2643 | 0 | { |
2644 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
2645 | 0 | { |
2646 | 0 | q=PopShortPixel(quantum_info->endian,SinglePrecisionToHalf( |
2647 | 0 | QuantumScale*(double) GetPixelIndex(image,p)),q); |
2648 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
2649 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
2650 | 0 | } |
2651 | 0 | break; |
2652 | 0 | } |
2653 | 7.08M | for (x=0; x < (ssize_t) number_pixels; x++) |
2654 | 7.07M | { |
2655 | 7.07M | q=PopShortPixel(quantum_info->endian,(unsigned short) |
2656 | 7.07M | GetPixelIndex(image,p),q); |
2657 | 7.07M | p+=(ptrdiff_t) GetPixelChannels(image); |
2658 | 7.07M | q+=(ptrdiff_t) quantum_info->pad; |
2659 | 7.07M | } |
2660 | 4.70k | break; |
2661 | 4.70k | } |
2662 | 4.20k | case 32: |
2663 | 4.20k | { |
2664 | 4.20k | if (quantum_info->format == FloatingPointQuantumFormat) |
2665 | 0 | { |
2666 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
2667 | 0 | { |
2668 | 0 | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelIndex(image,p),q); |
2669 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
2670 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
2671 | 0 | } |
2672 | 0 | break; |
2673 | 0 | } |
2674 | 6.81M | for (x=0; x < (ssize_t) number_pixels; x++) |
2675 | 6.81M | { |
2676 | 6.81M | q=PopLongPixel(quantum_info->endian,(unsigned int) |
2677 | 6.81M | GetPixelIndex(image,p),q); |
2678 | 6.81M | p+=(ptrdiff_t) GetPixelChannels(image); |
2679 | 6.81M | q+=(ptrdiff_t) quantum_info->pad; |
2680 | 6.81M | } |
2681 | 4.20k | break; |
2682 | 4.20k | } |
2683 | 0 | case 64: |
2684 | 0 | { |
2685 | 0 | if (quantum_info->format == FloatingPointQuantumFormat) |
2686 | 0 | { |
2687 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
2688 | 0 | { |
2689 | 0 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelIndex(image,p),q); |
2690 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
2691 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
2692 | 0 | } |
2693 | 0 | break; |
2694 | 0 | } |
2695 | 0 | magick_fallthrough; |
2696 | 0 | } |
2697 | 603 | default: |
2698 | 603 | { |
2699 | 6.29k | for (x=0; x < (ssize_t) number_pixels; x++) |
2700 | 5.69k | { |
2701 | 5.69k | q=PopQuantumPixel(quantum_info,(QuantumAny) GetPixelIndex(image,p),q); |
2702 | 5.69k | p+=(ptrdiff_t) GetPixelChannels(image); |
2703 | 5.69k | q+=(ptrdiff_t) quantum_info->pad; |
2704 | 5.69k | } |
2705 | 603 | break; |
2706 | 0 | } |
2707 | 186k | } |
2708 | 186k | } |
2709 | | |
2710 | | static void ExportIndexAlphaQuantum(const Image *image, |
2711 | | QuantumInfo *quantum_info,const MagickSizeType number_pixels, |
2712 | | const Quantum *magick_restrict p,unsigned char *magick_restrict q, |
2713 | | ExceptionInfo *exception) |
2714 | 9.87k | { |
2715 | 9.87k | ssize_t |
2716 | 9.87k | x; |
2717 | | |
2718 | 9.87k | ssize_t |
2719 | 9.87k | bit; |
2720 | | |
2721 | 9.87k | if (image->storage_class != PseudoClass) |
2722 | 0 | { |
2723 | 0 | (void) ThrowMagickException(exception,GetMagickModule(),ImageError, |
2724 | 0 | "ColormappedImageRequired","`%s'",image->filename); |
2725 | 0 | return; |
2726 | 0 | } |
2727 | 9.87k | switch (quantum_info->depth) |
2728 | 9.87k | { |
2729 | 0 | case 1: |
2730 | 0 | { |
2731 | 0 | unsigned char |
2732 | 0 | pixel; |
2733 | |
|
2734 | 0 | for (x=((ssize_t) number_pixels-3); x > 0; x-=4) |
2735 | 0 | { |
2736 | 0 | pixel=(unsigned char) ((ssize_t) GetPixelIndex(image,p)); |
2737 | 0 | *q=((pixel & 0x01) << 7); |
2738 | 0 | pixel=(unsigned char) (GetPixelAlpha(image,p) == (Quantum) |
2739 | 0 | TransparentAlpha ? 1 : 0); |
2740 | 0 | *q|=((pixel & 0x01) << 6); |
2741 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
2742 | 0 | pixel=(unsigned char) ((ssize_t) GetPixelIndex(image,p)); |
2743 | 0 | *q|=((pixel & 0x01) << 5); |
2744 | 0 | pixel=(unsigned char) (GetPixelAlpha(image,p) == (Quantum) |
2745 | 0 | TransparentAlpha ? 1 : 0); |
2746 | 0 | *q|=((pixel & 0x01) << 4); |
2747 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
2748 | 0 | pixel=(unsigned char) ((ssize_t) GetPixelIndex(image,p)); |
2749 | 0 | *q|=((pixel & 0x01) << 3); |
2750 | 0 | pixel=(unsigned char) (GetPixelAlpha(image,p) == (Quantum) |
2751 | 0 | TransparentAlpha ? 1 : 0); |
2752 | 0 | *q|=((pixel & 0x01) << 2); |
2753 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
2754 | 0 | pixel=(unsigned char) ((ssize_t) GetPixelIndex(image,p)); |
2755 | 0 | *q|=((pixel & 0x01) << 1); |
2756 | 0 | pixel=(unsigned char) (GetPixelAlpha(image,p) == (Quantum) |
2757 | 0 | TransparentAlpha ? 1 : 0); |
2758 | 0 | *q|=((pixel & 0x01) << 0); |
2759 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
2760 | 0 | q++; |
2761 | 0 | } |
2762 | 0 | if ((number_pixels % 4) != 0) |
2763 | 0 | { |
2764 | 0 | *q='\0'; |
2765 | 0 | for (bit=3; bit >= (ssize_t) (4-(number_pixels % 4)); bit-=2) |
2766 | 0 | { |
2767 | 0 | pixel=(unsigned char) ((ssize_t) GetPixelIndex(image,p)); |
2768 | 0 | *q|=((pixel & 0x01) << (unsigned char) (bit+4)); |
2769 | 0 | pixel=(unsigned char) (GetPixelAlpha(image,p) == (Quantum) |
2770 | 0 | TransparentAlpha ? 1 : 0); |
2771 | 0 | *q|=((pixel & 0x01) << (unsigned char) (bit+4-1)); |
2772 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
2773 | 0 | } |
2774 | 0 | q++; |
2775 | 0 | } |
2776 | 0 | break; |
2777 | 0 | } |
2778 | 0 | case 4: |
2779 | 0 | { |
2780 | 0 | unsigned char |
2781 | 0 | pixel; |
2782 | |
|
2783 | 0 | for (x=0; x < (ssize_t) number_pixels ; x++) |
2784 | 0 | { |
2785 | 0 | pixel=(unsigned char) ((ssize_t) GetPixelIndex(image,p)); |
2786 | 0 | *q=((pixel & 0xf) << 4); |
2787 | 0 | pixel=(unsigned char) (16.0*QuantumScale*(double) |
2788 | 0 | GetPixelAlpha(image,p)+0.5); |
2789 | 0 | *q|=((pixel & 0xf) << 0); |
2790 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
2791 | 0 | q++; |
2792 | 0 | } |
2793 | 0 | break; |
2794 | 0 | } |
2795 | 6.34k | case 8: |
2796 | 6.34k | { |
2797 | 6.34k | unsigned char |
2798 | 6.34k | pixel; |
2799 | | |
2800 | 7.77M | for (x=0; x < (ssize_t) number_pixels; x++) |
2801 | 7.76M | { |
2802 | 7.76M | q=PopCharPixel((unsigned char) ((ssize_t) GetPixelIndex(image,p)),q); |
2803 | 7.76M | pixel=ScaleQuantumToChar(GetPixelAlpha(image,p)); |
2804 | 7.76M | q=PopCharPixel(pixel,q); |
2805 | 7.76M | p+=(ptrdiff_t) GetPixelChannels(image); |
2806 | 7.76M | q+=(ptrdiff_t) quantum_info->pad; |
2807 | 7.76M | } |
2808 | 6.34k | break; |
2809 | 0 | } |
2810 | 2.04k | case 16: |
2811 | 2.04k | { |
2812 | 2.04k | unsigned short |
2813 | 2.04k | pixel; |
2814 | | |
2815 | 2.04k | if (quantum_info->format == FloatingPointQuantumFormat) |
2816 | 0 | { |
2817 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
2818 | 0 | { |
2819 | 0 | q=PopShortPixel(quantum_info->endian,(unsigned short) |
2820 | 0 | ((ssize_t) GetPixelIndex(image,p)),q); |
2821 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
2822 | 0 | GetPixelAlpha(image,p)); |
2823 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
2824 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
2825 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
2826 | 0 | } |
2827 | 0 | break; |
2828 | 0 | } |
2829 | 10.0k | for (x=0; x < (ssize_t) number_pixels; x++) |
2830 | 7.97k | { |
2831 | 7.97k | q=PopShortPixel(quantum_info->endian,(unsigned short) |
2832 | 7.97k | ((ssize_t) GetPixelIndex(image,p)),q); |
2833 | 7.97k | pixel=ScaleQuantumToShort(GetPixelAlpha(image,p)); |
2834 | 7.97k | q=PopShortPixel(quantum_info->endian,pixel,q); |
2835 | 7.97k | p+=(ptrdiff_t) GetPixelChannels(image); |
2836 | 7.97k | q+=(ptrdiff_t) quantum_info->pad; |
2837 | 7.97k | } |
2838 | 2.04k | break; |
2839 | 2.04k | } |
2840 | 1.49k | case 32: |
2841 | 1.49k | { |
2842 | 1.49k | unsigned int |
2843 | 1.49k | pixel; |
2844 | | |
2845 | 1.49k | if (quantum_info->format == FloatingPointQuantumFormat) |
2846 | 0 | { |
2847 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
2848 | 0 | { |
2849 | 0 | float |
2850 | 0 | float_pixel; |
2851 | |
|
2852 | 0 | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelIndex(image,p),q); |
2853 | 0 | float_pixel=(float) GetPixelAlpha(image,p); |
2854 | 0 | q=PopQuantumFloatPixel(quantum_info,float_pixel,q); |
2855 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
2856 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
2857 | 0 | } |
2858 | 0 | break; |
2859 | 0 | } |
2860 | 5.28k | for (x=0; x < (ssize_t) number_pixels; x++) |
2861 | 3.79k | { |
2862 | 3.79k | q=PopLongPixel(quantum_info->endian,(unsigned int) |
2863 | 3.79k | GetPixelIndex(image,p),q); |
2864 | 3.79k | pixel=ScaleQuantumToLong(GetPixelAlpha(image,p)); |
2865 | 3.79k | q=PopLongPixel(quantum_info->endian,pixel,q); |
2866 | 3.79k | p+=(ptrdiff_t) GetPixelChannels(image); |
2867 | 3.79k | q+=(ptrdiff_t) quantum_info->pad; |
2868 | 3.79k | } |
2869 | 1.49k | break; |
2870 | 1.49k | } |
2871 | 0 | case 64: |
2872 | 0 | { |
2873 | 0 | if (quantum_info->format == FloatingPointQuantumFormat) |
2874 | 0 | { |
2875 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
2876 | 0 | { |
2877 | 0 | double |
2878 | 0 | pixel; |
2879 | |
|
2880 | 0 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelIndex(image,p),q); |
2881 | 0 | pixel=(double) GetPixelAlpha(image,p); |
2882 | 0 | q=PopQuantumDoublePixel(quantum_info,pixel,q); |
2883 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
2884 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
2885 | 0 | } |
2886 | 0 | break; |
2887 | 0 | } |
2888 | 0 | magick_fallthrough; |
2889 | 0 | } |
2890 | 0 | default: |
2891 | 0 | { |
2892 | 0 | QuantumAny |
2893 | 0 | range; |
2894 | |
|
2895 | 0 | range=GetQuantumRange(quantum_info->depth); |
2896 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
2897 | 0 | { |
2898 | 0 | q=PopQuantumPixel(quantum_info,(QuantumAny) GetPixelIndex(image,p),q); |
2899 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p), |
2900 | 0 | range),q); |
2901 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
2902 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
2903 | 0 | } |
2904 | 0 | break; |
2905 | 0 | } |
2906 | 9.87k | } |
2907 | 9.87k | } |
2908 | | |
2909 | | static void ExportMultispectralQuantum(const Image *image, |
2910 | | QuantumInfo *quantum_info,const MagickSizeType number_pixels, |
2911 | | const Quantum *magick_restrict p,unsigned char *magick_restrict q, |
2912 | | ExceptionInfo *exception) |
2913 | 23.9k | { |
2914 | 23.9k | ssize_t |
2915 | 23.9k | i, |
2916 | 23.9k | x; |
2917 | | |
2918 | 23.9k | if (image->number_meta_channels == 0) |
2919 | 0 | { |
2920 | 0 | (void) ThrowMagickException(exception,GetMagickModule(),ImageError, |
2921 | 0 | "MultispectralImageRequired","`%s'",image->filename); |
2922 | 0 | return; |
2923 | 0 | } |
2924 | 23.9k | switch (quantum_info->depth) |
2925 | 23.9k | { |
2926 | 3.30k | case 8: |
2927 | 3.30k | { |
2928 | 3.30k | unsigned char |
2929 | 3.30k | pixel; |
2930 | | |
2931 | 475k | for (x=0; x < (ssize_t) number_pixels; x++) |
2932 | 472k | { |
2933 | 3.93M | for (i=0; i < (ssize_t) GetImageChannels(image); i++) |
2934 | 3.45M | { |
2935 | 3.45M | pixel=ScaleQuantumToChar(p[i]); |
2936 | 3.45M | q=PopCharPixel(pixel,q); |
2937 | 3.45M | } |
2938 | 472k | p+=(ptrdiff_t) GetPixelChannels(image); |
2939 | 472k | q+=(ptrdiff_t) quantum_info->pad; |
2940 | 472k | } |
2941 | 3.30k | break; |
2942 | 0 | } |
2943 | 9.09k | case 16: |
2944 | 9.09k | { |
2945 | 9.09k | unsigned short |
2946 | 9.09k | pixel; |
2947 | | |
2948 | 9.09k | if (quantum_info->format == FloatingPointQuantumFormat) |
2949 | 4.08k | { |
2950 | 978k | for (x=0; x < (ssize_t) number_pixels; x++) |
2951 | 974k | { |
2952 | 6.79M | for (i=0; i < (ssize_t) GetImageChannels(image); i++) |
2953 | 5.82M | { |
2954 | 5.82M | pixel=SinglePrecisionToHalf(QuantumScale*(double) p[i]); |
2955 | 5.82M | q=PopShortPixel(quantum_info->endian,pixel,q); |
2956 | 5.82M | } |
2957 | 974k | p+=(ptrdiff_t) GetPixelChannels(image); |
2958 | 974k | q+=(ptrdiff_t) quantum_info->pad; |
2959 | 974k | } |
2960 | 4.08k | break; |
2961 | 4.08k | } |
2962 | 1.21M | for (x=0; x < (ssize_t) number_pixels; x++) |
2963 | 1.20M | { |
2964 | 4.28M | for (i=0; i < (ssize_t) GetImageChannels(image); i++) |
2965 | 3.07M | { |
2966 | 3.07M | pixel=ScaleQuantumToShort(p[i]); |
2967 | 3.07M | q=PopShortPixel(quantum_info->endian,pixel,q); |
2968 | 3.07M | } |
2969 | 1.20M | p+=(ptrdiff_t) GetPixelChannels(image); |
2970 | 1.20M | q+=(ptrdiff_t) quantum_info->pad; |
2971 | 1.20M | } |
2972 | 5.01k | break; |
2973 | 9.09k | } |
2974 | 8.22k | case 32: |
2975 | 8.22k | { |
2976 | 8.22k | unsigned int |
2977 | 8.22k | pixel; |
2978 | | |
2979 | 8.22k | if (quantum_info->format == FloatingPointQuantumFormat) |
2980 | 3.49k | { |
2981 | 21.2k | for (x=0; x < (ssize_t) number_pixels; x++) |
2982 | 17.7k | { |
2983 | 141k | for (i=0; i < (ssize_t) GetImageChannels(image); i++) |
2984 | 124k | q=PopQuantumFloatPixel(quantum_info,(float) p[i],q); |
2985 | 17.7k | p+=(ptrdiff_t) GetPixelChannels(image); |
2986 | 17.7k | q+=(ptrdiff_t) quantum_info->pad; |
2987 | 17.7k | } |
2988 | 3.49k | break; |
2989 | 3.49k | } |
2990 | 1.52M | for (x=0; x < (ssize_t) number_pixels; x++) |
2991 | 1.52M | { |
2992 | 22.2M | for (i=0; i < (ssize_t) GetImageChannels(image); i++) |
2993 | 20.6M | { |
2994 | 20.6M | pixel=ScaleQuantumToLong(p[i]); |
2995 | 20.6M | q=PopLongPixel(quantum_info->endian,pixel,q); |
2996 | 20.6M | } |
2997 | 1.52M | p+=(ptrdiff_t) GetPixelChannels(image); |
2998 | 1.52M | q+=(ptrdiff_t) quantum_info->pad; |
2999 | 1.52M | } |
3000 | 4.72k | break; |
3001 | 8.22k | } |
3002 | 275 | case 64: |
3003 | 275 | { |
3004 | 275 | if (quantum_info->format == FloatingPointQuantumFormat) |
3005 | 161 | { |
3006 | 418 | for (x=0; x < (ssize_t) number_pixels; x++) |
3007 | 257 | { |
3008 | 1.36k | for (i=0; i < (ssize_t) GetImageChannels(image); i++) |
3009 | 1.11k | q=PopQuantumDoublePixel(quantum_info,(double) p[i],q); |
3010 | 257 | p+=(ptrdiff_t) GetPixelChannels(image); |
3011 | 257 | q+=(ptrdiff_t) quantum_info->pad; |
3012 | 257 | } |
3013 | 161 | break; |
3014 | 161 | } |
3015 | 114 | magick_fallthrough; |
3016 | 114 | } |
3017 | 3.16k | default: |
3018 | 3.16k | { |
3019 | 3.16k | QuantumAny |
3020 | 3.16k | range; |
3021 | | |
3022 | 3.16k | range=GetQuantumRange(quantum_info->depth); |
3023 | 49.6k | for (x=0; x < (ssize_t) number_pixels; x++) |
3024 | 46.4k | { |
3025 | 235k | for (i=0; i < (ssize_t) GetImageChannels(image); i++) |
3026 | 189k | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(p[i],range),q); |
3027 | 46.4k | p+=(ptrdiff_t) GetPixelChannels(image); |
3028 | 46.4k | q+=(ptrdiff_t) quantum_info->pad; |
3029 | 46.4k | } |
3030 | 3.16k | break; |
3031 | 114 | } |
3032 | 23.9k | } |
3033 | 23.9k | } |
3034 | | |
3035 | | static void ExportOpacityQuantum(const Image *image,QuantumInfo *quantum_info, |
3036 | | const MagickSizeType number_pixels,const Quantum *magick_restrict p, |
3037 | | unsigned char *magick_restrict q) |
3038 | 0 | { |
3039 | 0 | QuantumAny |
3040 | 0 | range; |
3041 | |
|
3042 | 0 | ssize_t |
3043 | 0 | x; |
3044 | |
|
3045 | 0 | switch (quantum_info->depth) |
3046 | 0 | { |
3047 | 0 | case 8: |
3048 | 0 | { |
3049 | 0 | unsigned char |
3050 | 0 | pixel; |
3051 | |
|
3052 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
3053 | 0 | { |
3054 | 0 | pixel=ScaleQuantumToChar(GetPixelOpacity(image,p)); |
3055 | 0 | q=PopCharPixel(pixel,q); |
3056 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
3057 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
3058 | 0 | } |
3059 | 0 | break; |
3060 | 0 | } |
3061 | 0 | case 16: |
3062 | 0 | { |
3063 | 0 | unsigned short |
3064 | 0 | pixel; |
3065 | |
|
3066 | 0 | if (quantum_info->format == FloatingPointQuantumFormat) |
3067 | 0 | { |
3068 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
3069 | 0 | { |
3070 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
3071 | 0 | GetPixelOpacity(image,p)); |
3072 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
3073 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
3074 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
3075 | 0 | } |
3076 | 0 | break; |
3077 | 0 | } |
3078 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
3079 | 0 | { |
3080 | 0 | pixel=ScaleQuantumToShort(GetPixelOpacity(image,p)); |
3081 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
3082 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
3083 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
3084 | 0 | } |
3085 | 0 | break; |
3086 | 0 | } |
3087 | 0 | case 32: |
3088 | 0 | { |
3089 | 0 | unsigned int |
3090 | 0 | pixel; |
3091 | |
|
3092 | 0 | if (quantum_info->format == FloatingPointQuantumFormat) |
3093 | 0 | { |
3094 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
3095 | 0 | { |
3096 | 0 | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelOpacity(image,p),q); |
3097 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
3098 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
3099 | 0 | } |
3100 | 0 | break; |
3101 | 0 | } |
3102 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
3103 | 0 | { |
3104 | 0 | pixel=ScaleQuantumToLong(GetPixelOpacity(image,p)); |
3105 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
3106 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
3107 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
3108 | 0 | } |
3109 | 0 | break; |
3110 | 0 | } |
3111 | 0 | case 64: |
3112 | 0 | { |
3113 | 0 | if (quantum_info->format == FloatingPointQuantumFormat) |
3114 | 0 | { |
3115 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
3116 | 0 | { |
3117 | 0 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelOpacity(image,p),q); |
3118 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
3119 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
3120 | 0 | } |
3121 | 0 | break; |
3122 | 0 | } |
3123 | 0 | magick_fallthrough; |
3124 | 0 | } |
3125 | 0 | default: |
3126 | 0 | { |
3127 | 0 | range=GetQuantumRange(quantum_info->depth); |
3128 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
3129 | 0 | { |
3130 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny( |
3131 | 0 | GetPixelOpacity(image,p),range),q); |
3132 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
3133 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
3134 | 0 | } |
3135 | 0 | break; |
3136 | 0 | } |
3137 | 0 | } |
3138 | 0 | } |
3139 | | |
3140 | | static void ExportRedQuantum(const Image *image,QuantumInfo *quantum_info, |
3141 | | const MagickSizeType number_pixels,const Quantum *magick_restrict p, |
3142 | | unsigned char *magick_restrict q) |
3143 | 52.1k | { |
3144 | 52.1k | QuantumAny |
3145 | 52.1k | range; |
3146 | | |
3147 | 52.1k | ssize_t |
3148 | 52.1k | x; |
3149 | | |
3150 | 52.1k | switch (quantum_info->depth) |
3151 | 52.1k | { |
3152 | 40.4k | case 8: |
3153 | 40.4k | { |
3154 | 40.4k | unsigned char |
3155 | 40.4k | pixel; |
3156 | | |
3157 | 413k | for (x=0; x < (ssize_t) number_pixels; x++) |
3158 | 373k | { |
3159 | 373k | pixel=ScaleQuantumToChar(GetPixelRed(image,p)); |
3160 | 373k | q=PopCharPixel(pixel,q); |
3161 | 373k | p+=(ptrdiff_t) GetPixelChannels(image); |
3162 | 373k | q+=(ptrdiff_t) quantum_info->pad; |
3163 | 373k | } |
3164 | 40.4k | break; |
3165 | 0 | } |
3166 | 7.75k | case 16: |
3167 | 7.75k | { |
3168 | 7.75k | unsigned short |
3169 | 7.75k | pixel; |
3170 | | |
3171 | 7.75k | if (quantum_info->format == FloatingPointQuantumFormat) |
3172 | 0 | { |
3173 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
3174 | 0 | { |
3175 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
3176 | 0 | GetPixelRed(image,p)); |
3177 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
3178 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
3179 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
3180 | 0 | } |
3181 | 0 | break; |
3182 | 0 | } |
3183 | 56.4k | for (x=0; x < (ssize_t) number_pixels; x++) |
3184 | 48.6k | { |
3185 | 48.6k | pixel=ScaleQuantumToShort(GetPixelRed(image,p)); |
3186 | 48.6k | q=PopShortPixel(quantum_info->endian,pixel,q); |
3187 | 48.6k | p+=(ptrdiff_t) GetPixelChannels(image); |
3188 | 48.6k | q+=(ptrdiff_t) quantum_info->pad; |
3189 | 48.6k | } |
3190 | 7.75k | break; |
3191 | 7.75k | } |
3192 | 1.79k | case 32: |
3193 | 1.79k | { |
3194 | 1.79k | unsigned int |
3195 | 1.79k | pixel; |
3196 | | |
3197 | 1.79k | if (quantum_info->format == FloatingPointQuantumFormat) |
3198 | 987 | { |
3199 | 5.47k | for (x=0; x < (ssize_t) number_pixels; x++) |
3200 | 4.48k | { |
3201 | 4.48k | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelRed(image,p),q); |
3202 | 4.48k | p+=(ptrdiff_t) GetPixelChannels(image); |
3203 | 4.48k | q+=(ptrdiff_t) quantum_info->pad; |
3204 | 4.48k | } |
3205 | 987 | break; |
3206 | 987 | } |
3207 | 8.01k | for (x=0; x < (ssize_t) number_pixels; x++) |
3208 | 7.20k | { |
3209 | 7.20k | pixel=ScaleQuantumToLong(GetPixelRed(image,p)); |
3210 | 7.20k | q=PopLongPixel(quantum_info->endian,pixel,q); |
3211 | 7.20k | p+=(ptrdiff_t) GetPixelChannels(image); |
3212 | 7.20k | q+=(ptrdiff_t) quantum_info->pad; |
3213 | 7.20k | } |
3214 | 808 | break; |
3215 | 1.79k | } |
3216 | 2.14k | case 64: |
3217 | 2.14k | { |
3218 | 2.14k | if (quantum_info->format == FloatingPointQuantumFormat) |
3219 | 464 | { |
3220 | 1.44k | for (x=0; x < (ssize_t) number_pixels; x++) |
3221 | 977 | { |
3222 | 977 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelRed(image,p),q); |
3223 | 977 | p+=(ptrdiff_t) GetPixelChannels(image); |
3224 | 977 | q+=(ptrdiff_t) quantum_info->pad; |
3225 | 977 | } |
3226 | 464 | break; |
3227 | 464 | } |
3228 | 1.67k | magick_fallthrough; |
3229 | 1.67k | } |
3230 | 1.67k | default: |
3231 | 1.67k | { |
3232 | 1.67k | range=GetQuantumRange(quantum_info->depth); |
3233 | 9.95k | for (x=0; x < (ssize_t) number_pixels; x++) |
3234 | 8.27k | { |
3235 | 8.27k | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p), |
3236 | 8.27k | range),q); |
3237 | 8.27k | p+=(ptrdiff_t) GetPixelChannels(image); |
3238 | 8.27k | q+=(ptrdiff_t) quantum_info->pad; |
3239 | 8.27k | } |
3240 | 1.67k | break; |
3241 | 1.67k | } |
3242 | 52.1k | } |
3243 | 52.1k | } |
3244 | | |
3245 | | static void ExportRGBQuantum(const Image *image,QuantumInfo *quantum_info, |
3246 | | const MagickSizeType number_pixels,const Quantum *magick_restrict p, |
3247 | | unsigned char *magick_restrict q) |
3248 | 275k | { |
3249 | 275k | QuantumAny |
3250 | 275k | range; |
3251 | | |
3252 | 275k | ssize_t |
3253 | 275k | x; |
3254 | | |
3255 | 275k | ssize_t |
3256 | 275k | bit; |
3257 | | |
3258 | 275k | switch (quantum_info->depth) |
3259 | 275k | { |
3260 | 71.2k | case 8: |
3261 | 71.2k | { |
3262 | 37.6M | for (x=0; x < (ssize_t) number_pixels; x++) |
3263 | 37.6M | { |
3264 | 37.6M | q=PopCharPixel(ScaleQuantumToChar(GetPixelRed(image,p)),q); |
3265 | 37.6M | q=PopCharPixel(ScaleQuantumToChar(GetPixelGreen(image,p)),q); |
3266 | 37.6M | q=PopCharPixel(ScaleQuantumToChar(GetPixelBlue(image,p)),q); |
3267 | 37.6M | p+=(ptrdiff_t) GetPixelChannels(image); |
3268 | 37.6M | q+=(ptrdiff_t) quantum_info->pad; |
3269 | 37.6M | } |
3270 | 71.2k | break; |
3271 | 0 | } |
3272 | 2.82k | case 10: |
3273 | 2.82k | { |
3274 | 2.82k | unsigned int |
3275 | 2.82k | pixel; |
3276 | | |
3277 | 2.82k | range=GetQuantumRange(quantum_info->depth); |
3278 | 2.82k | if (quantum_info->pack == MagickFalse) |
3279 | 1.23k | { |
3280 | 24.0k | for (x=0; x < (ssize_t) number_pixels; x++) |
3281 | 22.8k | { |
3282 | 22.8k | pixel=(unsigned int) ( |
3283 | 22.8k | ScaleQuantumToAny(GetPixelRed(image,p),range) << 22 | |
3284 | 22.8k | ScaleQuantumToAny(GetPixelGreen(image,p),range) << 12 | |
3285 | 22.8k | ScaleQuantumToAny(GetPixelBlue(image,p),range) << 2); |
3286 | 22.8k | q=PopLongPixel(quantum_info->endian,pixel,q); |
3287 | 22.8k | p+=(ptrdiff_t) GetPixelChannels(image); |
3288 | 22.8k | q+=(ptrdiff_t) quantum_info->pad; |
3289 | 22.8k | } |
3290 | 1.23k | break; |
3291 | 1.23k | } |
3292 | 1.58k | if (quantum_info->quantum == 32UL) |
3293 | 0 | { |
3294 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
3295 | 0 | { |
3296 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); |
3297 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
3298 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), |
3299 | 0 | range); |
3300 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
3301 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); |
3302 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
3303 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
3304 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
3305 | 0 | } |
3306 | 0 | break; |
3307 | 0 | } |
3308 | 19.5k | for (x=0; x < (ssize_t) number_pixels; x++) |
3309 | 17.9k | { |
3310 | 17.9k | pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); |
3311 | 17.9k | q=PopQuantumPixel(quantum_info,pixel,q); |
3312 | 17.9k | pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range); |
3313 | 17.9k | q=PopQuantumPixel(quantum_info,pixel,q); |
3314 | 17.9k | pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); |
3315 | 17.9k | q=PopQuantumPixel(quantum_info,pixel,q); |
3316 | 17.9k | p+=(ptrdiff_t) GetPixelChannels(image); |
3317 | 17.9k | q+=(ptrdiff_t) quantum_info->pad; |
3318 | 17.9k | } |
3319 | 1.58k | break; |
3320 | 1.58k | } |
3321 | 20.0k | case 12: |
3322 | 20.0k | { |
3323 | 20.0k | unsigned int |
3324 | 20.0k | pixel; |
3325 | | |
3326 | 20.0k | range=GetQuantumRange(quantum_info->depth); |
3327 | 20.0k | if (quantum_info->pack == MagickFalse) |
3328 | 16.6k | { |
3329 | 62.0k | for (x=0; x < (ssize_t) (3*number_pixels-1); x+=2) |
3330 | 45.3k | { |
3331 | 45.3k | switch (x % 3) |
3332 | 45.3k | { |
3333 | 0 | default: |
3334 | 25.7k | case 0: |
3335 | 25.7k | { |
3336 | 25.7k | pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p), |
3337 | 25.7k | range); |
3338 | 25.7k | break; |
3339 | 0 | } |
3340 | 9.79k | case 1: |
3341 | 9.79k | { |
3342 | 9.79k | pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), |
3343 | 9.79k | range); |
3344 | 9.79k | break; |
3345 | 0 | } |
3346 | 9.79k | case 2: |
3347 | 9.79k | { |
3348 | 9.79k | pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p), |
3349 | 9.79k | range); |
3350 | 9.79k | p+=(ptrdiff_t) GetPixelChannels(image); |
3351 | 9.79k | break; |
3352 | 0 | } |
3353 | 45.3k | } |
3354 | 45.3k | q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel << 4), |
3355 | 45.3k | q); |
3356 | 45.3k | switch ((x+1) % 3) |
3357 | 45.3k | { |
3358 | 0 | default: |
3359 | 9.79k | case 0: |
3360 | 9.79k | { |
3361 | 9.79k | pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p), |
3362 | 9.79k | range); |
3363 | 9.79k | break; |
3364 | 0 | } |
3365 | 25.7k | case 1: |
3366 | 25.7k | { |
3367 | 25.7k | pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), |
3368 | 25.7k | range); |
3369 | 25.7k | break; |
3370 | 0 | } |
3371 | 9.79k | case 2: |
3372 | 9.79k | { |
3373 | 9.79k | pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p), |
3374 | 9.79k | range); |
3375 | 9.79k | p+=(ptrdiff_t) GetPixelChannels(image); |
3376 | 9.79k | break; |
3377 | 0 | } |
3378 | 45.3k | } |
3379 | 45.3k | q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel << 4), |
3380 | 45.3k | q); |
3381 | 45.3k | q+=(ptrdiff_t) quantum_info->pad; |
3382 | 45.3k | } |
3383 | 32.6k | for (bit=0; bit < (ssize_t) (3*number_pixels % 2); bit++) |
3384 | 15.9k | { |
3385 | 15.9k | switch ((x+bit) % 3) |
3386 | 15.9k | { |
3387 | 0 | default: |
3388 | 0 | case 0: |
3389 | 0 | { |
3390 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p), |
3391 | 0 | range); |
3392 | 0 | break; |
3393 | 0 | } |
3394 | 0 | case 1: |
3395 | 0 | { |
3396 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), |
3397 | 0 | range); |
3398 | 0 | break; |
3399 | 0 | } |
3400 | 15.9k | case 2: |
3401 | 15.9k | { |
3402 | 15.9k | pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p), |
3403 | 15.9k | range); |
3404 | 15.9k | p+=(ptrdiff_t) GetPixelChannels(image); |
3405 | 15.9k | break; |
3406 | 0 | } |
3407 | 15.9k | } |
3408 | 15.9k | q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel << 4), |
3409 | 15.9k | q); |
3410 | 15.9k | q+=(ptrdiff_t) quantum_info->pad; |
3411 | 15.9k | } |
3412 | 16.6k | if (bit != 0) |
3413 | 15.9k | p+=(ptrdiff_t) GetPixelChannels(image); |
3414 | 16.6k | break; |
3415 | 16.6k | } |
3416 | 3.40k | if (quantum_info->quantum == 32UL) |
3417 | 0 | { |
3418 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
3419 | 0 | { |
3420 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); |
3421 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
3422 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), |
3423 | 0 | range); |
3424 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
3425 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); |
3426 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
3427 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
3428 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
3429 | 0 | } |
3430 | 0 | break; |
3431 | 0 | } |
3432 | 45.5k | for (x=0; x < (ssize_t) number_pixels; x++) |
3433 | 42.1k | { |
3434 | 42.1k | pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); |
3435 | 42.1k | q=PopQuantumPixel(quantum_info,pixel,q); |
3436 | 42.1k | pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range); |
3437 | 42.1k | q=PopQuantumPixel(quantum_info,pixel,q); |
3438 | 42.1k | pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); |
3439 | 42.1k | q=PopQuantumPixel(quantum_info,pixel,q); |
3440 | 42.1k | p+=(ptrdiff_t) GetPixelChannels(image); |
3441 | 42.1k | q+=(ptrdiff_t) quantum_info->pad; |
3442 | 42.1k | } |
3443 | 3.40k | break; |
3444 | 3.40k | } |
3445 | 149k | case 16: |
3446 | 149k | { |
3447 | 149k | unsigned short |
3448 | 149k | pixel; |
3449 | | |
3450 | 149k | if (quantum_info->format == FloatingPointQuantumFormat) |
3451 | 7.06k | { |
3452 | 301k | for (x=0; x < (ssize_t) number_pixels; x++) |
3453 | 294k | { |
3454 | 294k | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
3455 | 294k | GetPixelRed(image,p)); |
3456 | 294k | q=PopShortPixel(quantum_info->endian,pixel,q); |
3457 | 294k | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
3458 | 294k | GetPixelGreen(image,p)); |
3459 | 294k | q=PopShortPixel(quantum_info->endian,pixel,q); |
3460 | 294k | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
3461 | 294k | GetPixelBlue(image,p)); |
3462 | 294k | q=PopShortPixel(quantum_info->endian,pixel,q); |
3463 | 294k | p+=(ptrdiff_t) GetPixelChannels(image); |
3464 | 294k | q+=(ptrdiff_t) quantum_info->pad; |
3465 | 294k | } |
3466 | 7.06k | break; |
3467 | 7.06k | } |
3468 | 193M | for (x=0; x < (ssize_t) number_pixels; x++) |
3469 | 193M | { |
3470 | 193M | pixel=ScaleQuantumToShort(GetPixelRed(image,p)); |
3471 | 193M | q=PopShortPixel(quantum_info->endian,pixel,q); |
3472 | 193M | pixel=ScaleQuantumToShort(GetPixelGreen(image,p)); |
3473 | 193M | q=PopShortPixel(quantum_info->endian,pixel,q); |
3474 | 193M | pixel=ScaleQuantumToShort(GetPixelBlue(image,p)); |
3475 | 193M | q=PopShortPixel(quantum_info->endian,pixel,q); |
3476 | 193M | p+=(ptrdiff_t) GetPixelChannels(image); |
3477 | 193M | q+=(ptrdiff_t) quantum_info->pad; |
3478 | 193M | } |
3479 | 142k | break; |
3480 | 149k | } |
3481 | 22.0k | case 32: |
3482 | 22.0k | { |
3483 | 22.0k | unsigned int |
3484 | 22.0k | pixel; |
3485 | | |
3486 | 22.0k | if (quantum_info->format == FloatingPointQuantumFormat) |
3487 | 2.33k | { |
3488 | 41.3k | for (x=0; x < (ssize_t) number_pixels; x++) |
3489 | 39.0k | { |
3490 | 39.0k | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelRed(image,p), |
3491 | 39.0k | q); |
3492 | 39.0k | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelGreen(image,p), |
3493 | 39.0k | q); |
3494 | 39.0k | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelBlue(image,p), |
3495 | 39.0k | q); |
3496 | 39.0k | p+=(ptrdiff_t) GetPixelChannels(image); |
3497 | 39.0k | q+=(ptrdiff_t) quantum_info->pad; |
3498 | 39.0k | } |
3499 | 2.33k | break; |
3500 | 2.33k | } |
3501 | 21.6M | for (x=0; x < (ssize_t) number_pixels; x++) |
3502 | 21.6M | { |
3503 | 21.6M | pixel=ScaleQuantumToLong(GetPixelRed(image,p)); |
3504 | 21.6M | q=PopLongPixel(quantum_info->endian,pixel,q); |
3505 | 21.6M | pixel=ScaleQuantumToLong(GetPixelGreen(image,p)); |
3506 | 21.6M | q=PopLongPixel(quantum_info->endian,pixel,q); |
3507 | 21.6M | pixel=ScaleQuantumToLong(GetPixelBlue(image,p)); |
3508 | 21.6M | q=PopLongPixel(quantum_info->endian,pixel,q); |
3509 | 21.6M | p+=(ptrdiff_t) GetPixelChannels(image); |
3510 | 21.6M | q+=(ptrdiff_t) quantum_info->pad; |
3511 | 21.6M | } |
3512 | 19.7k | break; |
3513 | 22.0k | } |
3514 | 434 | case 64: |
3515 | 434 | { |
3516 | 434 | if (quantum_info->format == FloatingPointQuantumFormat) |
3517 | 110 | { |
3518 | 310 | for (x=0; x < (ssize_t) number_pixels; x++) |
3519 | 200 | { |
3520 | 200 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelRed(image,p),q); |
3521 | 200 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q); |
3522 | 200 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q); |
3523 | 200 | p+=(ptrdiff_t) GetPixelChannels(image); |
3524 | 200 | q+=(ptrdiff_t) quantum_info->pad; |
3525 | 200 | } |
3526 | 110 | break; |
3527 | 110 | } |
3528 | 324 | magick_fallthrough; |
3529 | 324 | } |
3530 | 9.67k | default: |
3531 | 9.67k | { |
3532 | 9.67k | range=GetQuantumRange(quantum_info->depth); |
3533 | 329k | for (x=0; x < (ssize_t) number_pixels; x++) |
3534 | 319k | { |
3535 | 319k | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p), |
3536 | 319k | range),q); |
3537 | 319k | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p), |
3538 | 319k | range),q); |
3539 | 319k | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p), |
3540 | 319k | range),q); |
3541 | 319k | p+=(ptrdiff_t) GetPixelChannels(image); |
3542 | 319k | q+=(ptrdiff_t) quantum_info->pad; |
3543 | 319k | } |
3544 | 9.67k | break; |
3545 | 324 | } |
3546 | 275k | } |
3547 | 275k | } |
3548 | | |
3549 | | static void ExportRGBAQuantum(const Image *image,QuantumInfo *quantum_info, |
3550 | | const MagickSizeType number_pixels,const Quantum *magick_restrict p, |
3551 | | unsigned char *magick_restrict q) |
3552 | 69.1k | { |
3553 | 69.1k | QuantumAny |
3554 | 69.1k | range; |
3555 | | |
3556 | 69.1k | ssize_t |
3557 | 69.1k | x; |
3558 | | |
3559 | 69.1k | switch (quantum_info->depth) |
3560 | 69.1k | { |
3561 | 20.9k | case 8: |
3562 | 20.9k | { |
3563 | 20.9k | unsigned char |
3564 | 20.9k | pixel; |
3565 | | |
3566 | 9.80M | for (x=0; x < (ssize_t) number_pixels; x++) |
3567 | 9.78M | { |
3568 | 9.78M | pixel=ScaleQuantumToChar(GetPixelRed(image,p)); |
3569 | 9.78M | q=PopCharPixel(pixel,q); |
3570 | 9.78M | pixel=ScaleQuantumToChar(GetPixelGreen(image,p)); |
3571 | 9.78M | q=PopCharPixel(pixel,q); |
3572 | 9.78M | pixel=ScaleQuantumToChar(GetPixelBlue(image,p)); |
3573 | 9.78M | q=PopCharPixel(pixel,q); |
3574 | 9.78M | pixel=ScaleQuantumToChar(GetPixelAlpha(image,p)); |
3575 | 9.78M | q=PopCharPixel(pixel,q); |
3576 | 9.78M | p+=(ptrdiff_t) GetPixelChannels(image); |
3577 | 9.78M | q+=(ptrdiff_t) quantum_info->pad; |
3578 | 9.78M | } |
3579 | 20.9k | break; |
3580 | 0 | } |
3581 | 1.38k | case 10: |
3582 | 1.38k | { |
3583 | 1.38k | unsigned int |
3584 | 1.38k | pixel; |
3585 | | |
3586 | 1.38k | range=GetQuantumRange(quantum_info->depth); |
3587 | 1.38k | if (quantum_info->pack == MagickFalse) |
3588 | 553 | { |
3589 | 553 | ssize_t |
3590 | 553 | i; |
3591 | | |
3592 | 553 | size_t |
3593 | 553 | quantum; |
3594 | | |
3595 | 553 | ssize_t |
3596 | 553 | n; |
3597 | | |
3598 | 553 | n=0; |
3599 | 553 | quantum=0; |
3600 | 553 | pixel=0; |
3601 | 11.0k | for (x=0; x < (ssize_t) number_pixels; x++) |
3602 | 10.4k | { |
3603 | 52.3k | for (i=0; i < 4; i++) |
3604 | 41.8k | { |
3605 | 41.8k | switch (i) |
3606 | 41.8k | { |
3607 | 10.4k | case 0: quantum=(size_t) GetPixelRed(image,p); break; |
3608 | 10.4k | case 1: quantum=(size_t) GetPixelGreen(image,p); break; |
3609 | 10.4k | case 2: quantum=(size_t) GetPixelBlue(image,p); break; |
3610 | 10.4k | case 3: quantum=(size_t) GetPixelAlpha(image,p); break; |
3611 | 41.8k | } |
3612 | 41.8k | switch (n % 3) |
3613 | 41.8k | { |
3614 | 14.1k | case 0: |
3615 | 14.1k | { |
3616 | 14.1k | pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum, |
3617 | 14.1k | range) << 22); |
3618 | 14.1k | break; |
3619 | 0 | } |
3620 | 13.9k | case 1: |
3621 | 13.9k | { |
3622 | 13.9k | pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum, |
3623 | 13.9k | range) << 12); |
3624 | 13.9k | break; |
3625 | 0 | } |
3626 | 13.6k | case 2: |
3627 | 13.6k | { |
3628 | 13.6k | pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum, |
3629 | 13.6k | range) << 2); |
3630 | 13.6k | q=PopLongPixel(quantum_info->endian,pixel,q); |
3631 | 13.6k | pixel=0; |
3632 | 13.6k | break; |
3633 | 0 | } |
3634 | 41.8k | } |
3635 | 41.8k | n++; |
3636 | 41.8k | } |
3637 | 10.4k | p+=(ptrdiff_t) GetPixelChannels(image); |
3638 | 10.4k | q+=(ptrdiff_t) quantum_info->pad; |
3639 | 10.4k | } |
3640 | 553 | break; |
3641 | 553 | } |
3642 | 828 | if (quantum_info->quantum == 32UL) |
3643 | 0 | { |
3644 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
3645 | 0 | { |
3646 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); |
3647 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
3648 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), |
3649 | 0 | range); |
3650 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
3651 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); |
3652 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
3653 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelAlpha(image,p), |
3654 | 0 | range); |
3655 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
3656 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
3657 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
3658 | 0 | } |
3659 | 0 | break; |
3660 | 0 | } |
3661 | 8.68k | for (x=0; x < (ssize_t) number_pixels; x++) |
3662 | 7.85k | { |
3663 | 7.85k | pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); |
3664 | 7.85k | q=PopQuantumPixel(quantum_info,pixel,q); |
3665 | 7.85k | pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range); |
3666 | 7.85k | q=PopQuantumPixel(quantum_info,pixel,q); |
3667 | 7.85k | pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); |
3668 | 7.85k | q=PopQuantumPixel(quantum_info,pixel,q); |
3669 | 7.85k | pixel=(unsigned int) ScaleQuantumToAny(GetPixelAlpha(image,p),range); |
3670 | 7.85k | q=PopQuantumPixel(quantum_info,pixel,q); |
3671 | 7.85k | p+=(ptrdiff_t) GetPixelChannels(image); |
3672 | 7.85k | q+=(ptrdiff_t) quantum_info->pad; |
3673 | 7.85k | } |
3674 | 828 | break; |
3675 | 828 | } |
3676 | 32.2k | case 16: |
3677 | 32.2k | { |
3678 | 32.2k | unsigned short |
3679 | 32.2k | pixel; |
3680 | | |
3681 | 32.2k | if (quantum_info->format == FloatingPointQuantumFormat) |
3682 | 6.19k | { |
3683 | 75.1k | for (x=0; x < (ssize_t) number_pixels; x++) |
3684 | 68.9k | { |
3685 | 68.9k | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
3686 | 68.9k | GetPixelRed(image,p)); |
3687 | 68.9k | q=PopShortPixel(quantum_info->endian,pixel,q); |
3688 | 68.9k | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
3689 | 68.9k | GetPixelGreen(image,p)); |
3690 | 68.9k | q=PopShortPixel(quantum_info->endian,pixel,q); |
3691 | 68.9k | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
3692 | 68.9k | GetPixelBlue(image,p)); |
3693 | 68.9k | q=PopShortPixel(quantum_info->endian,pixel,q); |
3694 | 68.9k | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
3695 | 68.9k | GetPixelAlpha(image,p)); |
3696 | 68.9k | q=PopShortPixel(quantum_info->endian,pixel,q); |
3697 | 68.9k | p+=(ptrdiff_t) GetPixelChannels(image); |
3698 | 68.9k | q+=(ptrdiff_t) quantum_info->pad; |
3699 | 68.9k | } |
3700 | 6.19k | break; |
3701 | 6.19k | } |
3702 | 6.24M | for (x=0; x < (ssize_t) number_pixels; x++) |
3703 | 6.21M | { |
3704 | 6.21M | pixel=ScaleQuantumToShort(GetPixelRed(image,p)); |
3705 | 6.21M | q=PopShortPixel(quantum_info->endian,pixel,q); |
3706 | 6.21M | pixel=ScaleQuantumToShort(GetPixelGreen(image,p)); |
3707 | 6.21M | q=PopShortPixel(quantum_info->endian,pixel,q); |
3708 | 6.21M | pixel=ScaleQuantumToShort(GetPixelBlue(image,p)); |
3709 | 6.21M | q=PopShortPixel(quantum_info->endian,pixel,q); |
3710 | 6.21M | pixel=ScaleQuantumToShort(GetPixelAlpha(image,p)); |
3711 | 6.21M | q=PopShortPixel(quantum_info->endian,pixel,q); |
3712 | 6.21M | p+=(ptrdiff_t) GetPixelChannels(image); |
3713 | 6.21M | q+=(ptrdiff_t) quantum_info->pad; |
3714 | 6.21M | } |
3715 | 26.0k | break; |
3716 | 32.2k | } |
3717 | 9.93k | case 32: |
3718 | 9.93k | { |
3719 | 9.93k | unsigned int |
3720 | 9.93k | pixel; |
3721 | | |
3722 | 9.93k | if (quantum_info->format == FloatingPointQuantumFormat) |
3723 | 2.06k | { |
3724 | 7.93k | for (x=0; x < (ssize_t) number_pixels; x++) |
3725 | 5.87k | { |
3726 | 5.87k | float |
3727 | 5.87k | float_pixel; |
3728 | | |
3729 | 5.87k | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelRed(image,p),q); |
3730 | 5.87k | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q); |
3731 | 5.87k | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q); |
3732 | 5.87k | float_pixel=(float) GetPixelAlpha(image,p); |
3733 | 5.87k | q=PopQuantumFloatPixel(quantum_info,float_pixel,q); |
3734 | 5.87k | p+=(ptrdiff_t) GetPixelChannels(image); |
3735 | 5.87k | q+=(ptrdiff_t) quantum_info->pad; |
3736 | 5.87k | } |
3737 | 2.06k | break; |
3738 | 2.06k | } |
3739 | 7.33M | for (x=0; x < (ssize_t) number_pixels; x++) |
3740 | 7.32M | { |
3741 | 7.32M | pixel=ScaleQuantumToLong(GetPixelRed(image,p)); |
3742 | 7.32M | q=PopLongPixel(quantum_info->endian,pixel,q); |
3743 | 7.32M | pixel=ScaleQuantumToLong(GetPixelGreen(image,p)); |
3744 | 7.32M | q=PopLongPixel(quantum_info->endian,pixel,q); |
3745 | 7.32M | pixel=ScaleQuantumToLong(GetPixelBlue(image,p)); |
3746 | 7.32M | q=PopLongPixel(quantum_info->endian,pixel,q); |
3747 | 7.32M | pixel=ScaleQuantumToLong(GetPixelAlpha(image,p)); |
3748 | 7.32M | q=PopLongPixel(quantum_info->endian,pixel,q); |
3749 | 7.32M | p+=(ptrdiff_t) GetPixelChannels(image); |
3750 | 7.32M | q+=(ptrdiff_t) quantum_info->pad; |
3751 | 7.32M | } |
3752 | 7.87k | break; |
3753 | 9.93k | } |
3754 | 56 | case 64: |
3755 | 56 | { |
3756 | 56 | if (quantum_info->format == FloatingPointQuantumFormat) |
3757 | 56 | { |
3758 | 56 | double |
3759 | 56 | pixel; |
3760 | | |
3761 | 168 | for (x=0; x < (ssize_t) number_pixels; x++) |
3762 | 112 | { |
3763 | 112 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelRed(image,p),q); |
3764 | 112 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q); |
3765 | 112 | q=PopQuantumDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q); |
3766 | 112 | pixel=(double) GetPixelAlpha(image,p); |
3767 | 112 | q=PopQuantumDoublePixel(quantum_info,pixel,q); |
3768 | 112 | p+=(ptrdiff_t) GetPixelChannels(image); |
3769 | 112 | q+=(ptrdiff_t) quantum_info->pad; |
3770 | 112 | } |
3771 | 56 | break; |
3772 | 56 | } |
3773 | 0 | magick_fallthrough; |
3774 | 0 | } |
3775 | 4.63k | default: |
3776 | 4.63k | { |
3777 | 4.63k | range=GetQuantumRange(quantum_info->depth); |
3778 | 38.2k | for (x=0; x < (ssize_t) number_pixels; x++) |
3779 | 33.5k | { |
3780 | 33.5k | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p), |
3781 | 33.5k | range),q); |
3782 | 33.5k | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p), |
3783 | 33.5k | range),q); |
3784 | 33.5k | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p), |
3785 | 33.5k | range),q); |
3786 | 33.5k | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p), |
3787 | 33.5k | range),q); |
3788 | 33.5k | p+=(ptrdiff_t) GetPixelChannels(image); |
3789 | 33.5k | q+=(ptrdiff_t) quantum_info->pad; |
3790 | 33.5k | } |
3791 | 4.63k | break; |
3792 | 0 | } |
3793 | 69.1k | } |
3794 | 69.1k | } |
3795 | | |
3796 | | static void ExportRGBOQuantum(const Image *image,QuantumInfo *quantum_info, |
3797 | | const MagickSizeType number_pixels,const Quantum *magick_restrict p, |
3798 | | unsigned char *magick_restrict q) |
3799 | 0 | { |
3800 | 0 | QuantumAny |
3801 | 0 | range; |
3802 | |
|
3803 | 0 | ssize_t |
3804 | 0 | x; |
3805 | |
|
3806 | 0 | switch (quantum_info->depth) |
3807 | 0 | { |
3808 | 0 | case 8: |
3809 | 0 | { |
3810 | 0 | unsigned char |
3811 | 0 | pixel; |
3812 | |
|
3813 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
3814 | 0 | { |
3815 | 0 | pixel=ScaleQuantumToChar(GetPixelRed(image,p)); |
3816 | 0 | q=PopCharPixel(pixel,q); |
3817 | 0 | pixel=ScaleQuantumToChar(GetPixelGreen(image,p)); |
3818 | 0 | q=PopCharPixel(pixel,q); |
3819 | 0 | pixel=ScaleQuantumToChar(GetPixelBlue(image,p)); |
3820 | 0 | q=PopCharPixel(pixel,q); |
3821 | 0 | pixel=ScaleQuantumToChar(GetPixelOpacity(image,p)); |
3822 | 0 | q=PopCharPixel(pixel,q); |
3823 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
3824 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
3825 | 0 | } |
3826 | 0 | break; |
3827 | 0 | } |
3828 | 0 | case 10: |
3829 | 0 | { |
3830 | 0 | unsigned int |
3831 | 0 | pixel; |
3832 | |
|
3833 | 0 | range=GetQuantumRange(quantum_info->depth); |
3834 | 0 | if (quantum_info->pack == MagickFalse) |
3835 | 0 | { |
3836 | 0 | ssize_t |
3837 | 0 | i; |
3838 | |
|
3839 | 0 | size_t |
3840 | 0 | quantum; |
3841 | |
|
3842 | 0 | ssize_t |
3843 | 0 | n; |
3844 | |
|
3845 | 0 | n=0; |
3846 | 0 | quantum=0; |
3847 | 0 | pixel=0; |
3848 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
3849 | 0 | { |
3850 | 0 | for (i=0; i < 4; i++) |
3851 | 0 | { |
3852 | 0 | switch (i) |
3853 | 0 | { |
3854 | 0 | case 0: quantum=(size_t) GetPixelRed(image,p); break; |
3855 | 0 | case 1: quantum=(size_t) GetPixelGreen(image,p); break; |
3856 | 0 | case 2: quantum=(size_t) GetPixelBlue(image,p); break; |
3857 | 0 | case 3: quantum=(size_t) GetPixelOpacity(image,p); break; |
3858 | 0 | } |
3859 | 0 | switch (n % 3) |
3860 | 0 | { |
3861 | 0 | case 0: |
3862 | 0 | { |
3863 | 0 | pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum, |
3864 | 0 | range) << 22); |
3865 | 0 | break; |
3866 | 0 | } |
3867 | 0 | case 1: |
3868 | 0 | { |
3869 | 0 | pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum, |
3870 | 0 | range) << 12); |
3871 | 0 | break; |
3872 | 0 | } |
3873 | 0 | case 2: |
3874 | 0 | { |
3875 | 0 | pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum, |
3876 | 0 | range) << 2); |
3877 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
3878 | 0 | pixel=0; |
3879 | 0 | break; |
3880 | 0 | } |
3881 | 0 | } |
3882 | 0 | n++; |
3883 | 0 | } |
3884 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
3885 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
3886 | 0 | } |
3887 | 0 | break; |
3888 | 0 | } |
3889 | 0 | if (quantum_info->quantum == 32UL) |
3890 | 0 | { |
3891 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
3892 | 0 | { |
3893 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); |
3894 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
3895 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), |
3896 | 0 | range); |
3897 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
3898 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); |
3899 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
3900 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelOpacity(image,p), |
3901 | 0 | range); |
3902 | 0 | q=PopQuantumLongPixel(quantum_info,pixel,q); |
3903 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
3904 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
3905 | 0 | } |
3906 | 0 | break; |
3907 | 0 | } |
3908 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
3909 | 0 | { |
3910 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); |
3911 | 0 | q=PopQuantumPixel(quantum_info,pixel,q); |
3912 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range); |
3913 | 0 | q=PopQuantumPixel(quantum_info,pixel,q); |
3914 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); |
3915 | 0 | q=PopQuantumPixel(quantum_info,pixel,q); |
3916 | 0 | pixel=(unsigned int) ScaleQuantumToAny(GetPixelOpacity(image,p),range); |
3917 | 0 | q=PopQuantumPixel(quantum_info,pixel,q); |
3918 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
3919 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
3920 | 0 | } |
3921 | 0 | break; |
3922 | 0 | } |
3923 | 0 | case 16: |
3924 | 0 | { |
3925 | 0 | unsigned short |
3926 | 0 | pixel; |
3927 | |
|
3928 | 0 | if (quantum_info->format == FloatingPointQuantumFormat) |
3929 | 0 | { |
3930 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
3931 | 0 | { |
3932 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
3933 | 0 | GetPixelRed(image,p)); |
3934 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
3935 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
3936 | 0 | GetPixelGreen(image,p)); |
3937 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
3938 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
3939 | 0 | GetPixelBlue(image,p)); |
3940 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
3941 | 0 | pixel=SinglePrecisionToHalf(QuantumScale*(double) |
3942 | 0 | GetPixelOpacity(image,p)); |
3943 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
3944 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
3945 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
3946 | 0 | } |
3947 | 0 | break; |
3948 | 0 | } |
3949 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
3950 | 0 | { |
3951 | 0 | pixel=ScaleQuantumToShort(GetPixelRed(image,p)); |
3952 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
3953 | 0 | pixel=ScaleQuantumToShort(GetPixelGreen(image,p)); |
3954 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
3955 | 0 | pixel=ScaleQuantumToShort(GetPixelBlue(image,p)); |
3956 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
3957 | 0 | pixel=ScaleQuantumToShort(GetPixelOpacity(image,p)); |
3958 | 0 | q=PopShortPixel(quantum_info->endian,pixel,q); |
3959 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
3960 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
3961 | 0 | } |
3962 | 0 | break; |
3963 | 0 | } |
3964 | 0 | case 32: |
3965 | 0 | { |
3966 | 0 | unsigned int |
3967 | 0 | pixel; |
3968 | |
|
3969 | 0 | if (quantum_info->format == FloatingPointQuantumFormat) |
3970 | 0 | { |
3971 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
3972 | 0 | { |
3973 | 0 | float |
3974 | 0 | float_pixel; |
3975 | |
|
3976 | 0 | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelRed(image,p), |
3977 | 0 | q); |
3978 | 0 | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelGreen(image,p), |
3979 | 0 | q); |
3980 | 0 | q=PopQuantumFloatPixel(quantum_info,(float) GetPixelBlue(image,p), |
3981 | 0 | q); |
3982 | 0 | float_pixel=(float) GetPixelOpacity(image,p); |
3983 | 0 | q=PopQuantumFloatPixel(quantum_info,float_pixel,q); |
3984 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
3985 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
3986 | 0 | } |
3987 | 0 | break; |
3988 | 0 | } |
3989 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
3990 | 0 | { |
3991 | 0 | pixel=ScaleQuantumToLong(GetPixelRed(image,p)); |
3992 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
3993 | 0 | pixel=ScaleQuantumToLong(GetPixelGreen(image,p)); |
3994 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
3995 | 0 | pixel=ScaleQuantumToLong(GetPixelBlue(image,p)); |
3996 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
3997 | 0 | pixel=ScaleQuantumToLong(GetPixelOpacity(image,p)); |
3998 | 0 | q=PopLongPixel(quantum_info->endian,pixel,q); |
3999 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
4000 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
4001 | 0 | } |
4002 | 0 | break; |
4003 | 0 | } |
4004 | 0 | case 64: |
4005 | 0 | { |
4006 | 0 | if (quantum_info->format == FloatingPointQuantumFormat) |
4007 | 0 | { |
4008 | 0 | double |
4009 | 0 | pixel; |
4010 | |
|
4011 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
4012 | 0 | { |
4013 | 0 | q=PopQuantumDoublePixel(quantum_info,(double) |
4014 | 0 | GetPixelRed(image,p),q); |
4015 | 0 | q=PopQuantumDoublePixel(quantum_info,(double) |
4016 | 0 | GetPixelGreen(image,p),q); |
4017 | 0 | q=PopQuantumDoublePixel(quantum_info,(double) |
4018 | 0 | GetPixelBlue(image,p),q); |
4019 | 0 | pixel=(double) GetPixelOpacity(image,p); |
4020 | 0 | q=PopQuantumDoublePixel(quantum_info,pixel,q); |
4021 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
4022 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
4023 | 0 | } |
4024 | 0 | break; |
4025 | 0 | } |
4026 | 0 | magick_fallthrough; |
4027 | 0 | } |
4028 | 0 | default: |
4029 | 0 | { |
4030 | 0 | range=GetQuantumRange(quantum_info->depth); |
4031 | 0 | for (x=0; x < (ssize_t) number_pixels; x++) |
4032 | 0 | { |
4033 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p), |
4034 | 0 | range),q); |
4035 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p), |
4036 | 0 | range),q); |
4037 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p), |
4038 | 0 | range),q); |
4039 | 0 | q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelOpacity(image,p), |
4040 | 0 | range),q); |
4041 | 0 | p+=(ptrdiff_t) GetPixelChannels(image); |
4042 | 0 | q+=(ptrdiff_t) quantum_info->pad; |
4043 | 0 | } |
4044 | 0 | break; |
4045 | 0 | } |
4046 | 0 | } |
4047 | 0 | } |
4048 | | |
4049 | | MagickExport size_t ExportQuantumPixels(const Image *image, |
4050 | | CacheView *image_view,QuantumInfo *quantum_info, |
4051 | | const QuantumType quantum_type,unsigned char *magick_restrict pixels, |
4052 | | ExceptionInfo *exception) |
4053 | 1.59M | { |
4054 | 1.59M | MagickSizeType |
4055 | 1.59M | number_pixels; |
4056 | | |
4057 | 1.59M | const Quantum |
4058 | 1.59M | *magick_restrict p; |
4059 | | |
4060 | 1.59M | size_t |
4061 | 1.59M | extent; |
4062 | | |
4063 | 1.59M | ssize_t |
4064 | 1.59M | x; |
4065 | | |
4066 | 1.59M | unsigned char |
4067 | 1.59M | *magick_restrict q; |
4068 | | |
4069 | 1.59M | assert(image != (Image *) NULL); |
4070 | 1.59M | assert(image->signature == MagickCoreSignature); |
4071 | 1.59M | assert(quantum_info != (QuantumInfo *) NULL); |
4072 | 1.59M | assert(quantum_info->signature == MagickCoreSignature); |
4073 | 1.59M | if (IsEventLogging() != MagickFalse) |
4074 | 0 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
4075 | 1.59M | if (pixels == (unsigned char *) NULL) |
4076 | 0 | pixels=(unsigned char *) GetQuantumPixels(quantum_info); |
4077 | 1.59M | if (image_view == (CacheView *) NULL) |
4078 | 1.59M | { |
4079 | 1.59M | number_pixels=GetImageExtent(image); |
4080 | 1.59M | p=GetVirtualPixelQueue(image); |
4081 | 1.59M | } |
4082 | 0 | else |
4083 | 0 | { |
4084 | 0 | number_pixels=GetCacheViewExtent(image_view); |
4085 | 0 | p=GetCacheViewVirtualPixelQueue(image_view); |
4086 | 0 | } |
4087 | 1.59M | if (quantum_info->alpha_type == AssociatedQuantumAlpha) |
4088 | 0 | { |
4089 | 0 | double |
4090 | 0 | Sa; |
4091 | |
|
4092 | 0 | Quantum |
4093 | 0 | *magick_restrict r; |
4094 | | |
4095 | | /* |
4096 | | Associate alpha. |
4097 | | */ |
4098 | 0 | if (image_view == (CacheView *) NULL) |
4099 | 0 | r=GetAuthenticPixelQueue(image); |
4100 | 0 | else |
4101 | 0 | r=GetCacheViewAuthenticPixelQueue(image_view); |
4102 | 0 | for (x=0; x < (ssize_t) image->columns; x++) |
4103 | 0 | { |
4104 | 0 | ssize_t |
4105 | 0 | i; |
4106 | |
|
4107 | 0 | Sa=QuantumScale*(double) GetPixelAlpha(image,r); |
4108 | 0 | for (i=0; i < (ssize_t) GetPixelChannels(image); i++) |
4109 | 0 | { |
4110 | 0 | PixelChannel channel = GetPixelChannelChannel(image,i); |
4111 | 0 | PixelTrait traits = GetPixelChannelTraits(image,channel); |
4112 | 0 | if ((traits & UpdatePixelTrait) == 0) |
4113 | 0 | continue; |
4114 | 0 | r[i]=ClampToQuantum(Sa*(double) r[i]); |
4115 | 0 | } |
4116 | 0 | r+=(ptrdiff_t) GetPixelChannels(image); |
4117 | 0 | } |
4118 | 0 | } |
4119 | 1.59M | if ((quantum_type == CbYCrQuantum) || (quantum_type == CbYCrAQuantum)) |
4120 | 2.24k | { |
4121 | 2.24k | Quantum |
4122 | 2.24k | quantum; |
4123 | | |
4124 | 2.24k | Quantum |
4125 | 2.24k | *magick_restrict r; |
4126 | | |
4127 | 2.24k | if (image_view == (CacheView *) NULL) |
4128 | 2.24k | r=GetAuthenticPixelQueue(image); |
4129 | 0 | else |
4130 | 0 | r=GetCacheViewAuthenticPixelQueue(image_view); |
4131 | 21.8k | for (x=0; x < (ssize_t) number_pixels; x++) |
4132 | 19.6k | { |
4133 | 19.6k | quantum=GetPixelRed(image,r); |
4134 | 19.6k | SetPixelRed(image,GetPixelGreen(image,r),r); |
4135 | 19.6k | SetPixelGreen(image,quantum,r); |
4136 | 19.6k | r+=(ptrdiff_t) GetPixelChannels(image); |
4137 | 19.6k | } |
4138 | 2.24k | } |
4139 | 1.59M | q=pixels; |
4140 | 1.59M | ResetQuantumState(quantum_info); |
4141 | 1.59M | extent=GetQuantumExtent(image,quantum_info,quantum_type); |
4142 | 1.59M | switch (quantum_type) |
4143 | 1.59M | { |
4144 | 0 | case AlphaQuantum: |
4145 | 0 | { |
4146 | 0 | ExportAlphaQuantum(image,quantum_info,number_pixels,p,q); |
4147 | 0 | break; |
4148 | 0 | } |
4149 | 0 | case BGRQuantum: |
4150 | 0 | { |
4151 | 0 | ExportBGRQuantum(image,quantum_info,number_pixels,p,q); |
4152 | 0 | break; |
4153 | 0 | } |
4154 | 0 | case BGRAQuantum: |
4155 | 0 | { |
4156 | 0 | ExportBGRAQuantum(image,quantum_info,number_pixels,p,q); |
4157 | 0 | break; |
4158 | 0 | } |
4159 | 0 | case BGROQuantum: |
4160 | 0 | { |
4161 | 0 | ExportBGROQuantum(image,quantum_info,number_pixels,p,q); |
4162 | 0 | break; |
4163 | 0 | } |
4164 | 0 | case BlackQuantum: |
4165 | 0 | { |
4166 | 0 | ExportBlackQuantum(image,quantum_info,number_pixels,p,q,exception); |
4167 | 0 | break; |
4168 | 0 | } |
4169 | 51.6k | case BlueQuantum: |
4170 | 51.6k | case YellowQuantum: |
4171 | 51.6k | { |
4172 | 51.6k | ExportBlueQuantum(image,quantum_info,number_pixels,p,q); |
4173 | 51.6k | break; |
4174 | 51.6k | } |
4175 | 27.1k | case CMYKQuantum: |
4176 | 27.1k | { |
4177 | 27.1k | ExportCMYKQuantum(image,quantum_info,number_pixels,p,q,exception); |
4178 | 27.1k | break; |
4179 | 51.6k | } |
4180 | 34.3k | case CMYKAQuantum: |
4181 | 34.3k | { |
4182 | 34.3k | ExportCMYKAQuantum(image,quantum_info,number_pixels,p,q,exception); |
4183 | 34.3k | break; |
4184 | 51.6k | } |
4185 | 23.9k | case MultispectralQuantum: |
4186 | 23.9k | { |
4187 | 23.9k | ExportMultispectralQuantum(image,quantum_info,number_pixels,p,q,exception); |
4188 | 23.9k | break; |
4189 | 51.6k | } |
4190 | 0 | case CMYKOQuantum: |
4191 | 0 | { |
4192 | 0 | ExportCMYKOQuantum(image,quantum_info,number_pixels,p,q,exception); |
4193 | 0 | break; |
4194 | 51.6k | } |
4195 | 0 | case CbYCrYQuantum: |
4196 | 0 | { |
4197 | 0 | ExportCbYCrYQuantum(image,quantum_info,number_pixels,p,q); |
4198 | 0 | break; |
4199 | 51.6k | } |
4200 | 786k | case GrayQuantum: |
4201 | 786k | { |
4202 | 786k | ExportGrayQuantum(image,quantum_info,number_pixels,p,q); |
4203 | 786k | break; |
4204 | 51.6k | } |
4205 | 30.1k | case GrayAlphaQuantum: |
4206 | 30.1k | { |
4207 | 30.1k | ExportGrayAlphaQuantum(image,quantum_info,number_pixels,p,q); |
4208 | 30.1k | break; |
4209 | 51.6k | } |
4210 | 51.6k | case GreenQuantum: |
4211 | 51.6k | case MagentaQuantum: |
4212 | 51.6k | { |
4213 | 51.6k | ExportGreenQuantum(image,quantum_info,number_pixels,p,q); |
4214 | 51.6k | break; |
4215 | 51.6k | } |
4216 | 186k | case IndexQuantum: |
4217 | 186k | { |
4218 | 186k | ExportIndexQuantum(image,quantum_info,number_pixels,p,q,exception); |
4219 | 186k | break; |
4220 | 51.6k | } |
4221 | 9.87k | case IndexAlphaQuantum: |
4222 | 9.87k | { |
4223 | 9.87k | ExportIndexAlphaQuantum(image,quantum_info,number_pixels,p,q,exception); |
4224 | 9.87k | break; |
4225 | 51.6k | } |
4226 | 52.1k | case RedQuantum: |
4227 | 52.1k | case CyanQuantum: |
4228 | 52.1k | { |
4229 | 52.1k | ExportRedQuantum(image,quantum_info,number_pixels,p,q); |
4230 | 52.1k | break; |
4231 | 52.1k | } |
4232 | 0 | case OpacityQuantum: |
4233 | 0 | { |
4234 | 0 | ExportOpacityQuantum(image,quantum_info,number_pixels,p,q); |
4235 | 0 | break; |
4236 | 52.1k | } |
4237 | 274k | case RGBQuantum: |
4238 | 275k | case CbYCrQuantum: |
4239 | 275k | { |
4240 | 275k | ExportRGBQuantum(image,quantum_info,number_pixels,p,q); |
4241 | 275k | break; |
4242 | 274k | } |
4243 | 68.3k | case RGBAQuantum: |
4244 | 69.1k | case CbYCrAQuantum: |
4245 | 69.1k | { |
4246 | 69.1k | ExportRGBAQuantum(image,quantum_info,number_pixels,p,q); |
4247 | 69.1k | break; |
4248 | 68.3k | } |
4249 | 0 | case RGBOQuantum: |
4250 | 0 | { |
4251 | 0 | ExportRGBOQuantum(image,quantum_info,number_pixels,p,q); |
4252 | 0 | break; |
4253 | 68.3k | } |
4254 | 0 | default: |
4255 | 0 | break; |
4256 | 1.59M | } |
4257 | 1.59M | if ((quantum_type == CbYCrQuantum) || (quantum_type == CbYCrAQuantum)) |
4258 | 2.24k | { |
4259 | 2.24k | Quantum |
4260 | 2.24k | quantum; |
4261 | | |
4262 | 2.24k | Quantum |
4263 | 2.24k | *magick_restrict r; |
4264 | | |
4265 | 2.24k | if (image_view == (CacheView *) NULL) |
4266 | 2.24k | r=GetAuthenticPixelQueue(image); |
4267 | 0 | else |
4268 | 0 | r=GetCacheViewAuthenticPixelQueue(image_view); |
4269 | 21.8k | for (x=0; x < (ssize_t) number_pixels; x++) |
4270 | 19.6k | { |
4271 | 19.6k | quantum=GetPixelRed(image,r); |
4272 | 19.6k | SetPixelRed(image,GetPixelGreen(image,r),r); |
4273 | 19.6k | SetPixelGreen(image,quantum,r); |
4274 | 19.6k | r+=(ptrdiff_t) GetPixelChannels(image); |
4275 | 19.6k | } |
4276 | 2.24k | } |
4277 | 1.59M | return(extent); |
4278 | 1.59M | } |