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