cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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 | % John Cristy % |
| 22 | % October 1998 % |
| 23 | % % |
| 24 | % % |
| 25 | % Copyright 1999-2008 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 | % http://www.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 "magick/studio.h" |
| 48 | #include "magick/property.h" |
| 49 | #include "magick/blob.h" |
| 50 | #include "magick/blob-private.h" |
| 51 | #include "magick/color-private.h" |
| 52 | #include "magick/exception.h" |
| 53 | #include "magick/exception-private.h" |
| 54 | #include "magick/cache.h" |
| 55 | #include "magick/constitute.h" |
| 56 | #include "magick/delegate.h" |
| 57 | #include "magick/geometry.h" |
| 58 | #include "magick/list.h" |
| 59 | #include "magick/magick.h" |
| 60 | #include "magick/memory_.h" |
| 61 | #include "magick/monitor.h" |
| 62 | #include "magick/option.h" |
| 63 | #include "magick/pixel.h" |
| 64 | #include "magick/pixel-private.h" |
| 65 | #include "magick/quantum.h" |
| 66 | #include "magick/quantum-private.h" |
| 67 | #include "magick/resource_.h" |
| 68 | #include "magick/semaphore.h" |
| 69 | #include "magick/statistic.h" |
| 70 | #include "magick/stream.h" |
| 71 | #include "magick/string_.h" |
| 72 | #include "magick/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 MagickTrue if the pixels are |
| 88 | % successfully transferred, otherwise MagickFalse. |
| 89 | % |
| 90 | % The format of the ImportQuantumPixels method is: |
| 91 | % |
| 92 | % size_t ImportQuantumPixels(Image *image,CacheView *image_view, |
| 93 | % const QuantumInfo *quantum_info,const QuantumType quantum_type, |
| 94 | % const unsigned char *pixels,ExceptionInfo *exception) |
| 95 | % |
| 96 | % A description of each parameter follows: |
| 97 | % |
| 98 | % o image: the image. |
| 99 | % |
| 100 | % o image_view: the image cache view. |
| 101 | % |
| 102 | % o quantum_info: the quantum info. |
| 103 | % |
| 104 | % o quantum_type: Declare which pixel components to transfer (red, green, |
| 105 | % blue, opacity, RGB, or RGBA). |
| 106 | % |
| 107 | % o pixels: The pixel components are transferred from this buffer. |
| 108 | % |
| 109 | % o exception: return any errors or warnings in this structure. |
| 110 | % |
| 111 | */ |
| 112 | |
| 113 | static inline IndexPacket PushColormapIndex(Image *image, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 114 | const size_t index,MagickBooleanType *range_exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 115 | { |
| 116 | if (index < image->colors) |
| 117 | return((IndexPacket) index); |
| 118 | *range_exception=MagickTrue; |
| 119 | return((IndexPacket) 0); |
| 120 | } |
| 121 | |
| 122 | static inline const unsigned char *PushDoublePixel( |
| 123 | const QuantumState *quantum_state,const unsigned char *pixels,double *pixel) |
| 124 | { |
| 125 | double |
| 126 | *p; |
| 127 | |
| 128 | unsigned char |
| 129 | quantum[8]; |
| 130 | |
| 131 | if (quantum_state->endian != LSBEndian) |
| 132 | { |
| 133 | quantum[7]=(*pixels++); |
| 134 | quantum[6]=(*pixels++); |
| 135 | quantum[5]=(*pixels++); |
| 136 | quantum[5]=(*pixels++); |
| 137 | quantum[3]=(*pixels++); |
| 138 | quantum[2]=(*pixels++); |
| 139 | quantum[1]=(*pixels++); |
| 140 | quantum[0]=(*pixels++); |
| 141 | p=(double *) quantum; |
| 142 | *pixel=(*p); |
| 143 | *pixel-=quantum_state->minimum; |
| 144 | *pixel*=quantum_state->scale; |
| 145 | return(pixels); |
| 146 | } |
| 147 | quantum[0]=(*pixels++); |
| 148 | quantum[1]=(*pixels++); |
| 149 | quantum[2]=(*pixels++); |
| 150 | quantum[3]=(*pixels++); |
| 151 | quantum[4]=(*pixels++); |
| 152 | quantum[5]=(*pixels++); |
| 153 | quantum[6]=(*pixels++); |
| 154 | quantum[7]=(*pixels++); |
| 155 | p=(double *) quantum; |
| 156 | *pixel=(*p); |
| 157 | *pixel-=quantum_state->minimum; |
| 158 | *pixel*=quantum_state->scale; |
| 159 | return(pixels); |
| 160 | } |
| 161 | |
| 162 | static inline const unsigned char *PushFloatPixel( |
| 163 | const QuantumState *quantum_state,const unsigned char *pixels,float *pixel) |
| 164 | { |
| 165 | float |
| 166 | *p; |
| 167 | |
| 168 | unsigned char |
| 169 | quantum[4]; |
| 170 | |
| 171 | if (quantum_state->endian != LSBEndian) |
| 172 | { |
| 173 | quantum[3]=(*pixels++); |
| 174 | quantum[2]=(*pixels++); |
| 175 | quantum[1]=(*pixels++); |
| 176 | quantum[0]=(*pixels++); |
| 177 | p=(float *) quantum; |
| 178 | *pixel=(*p); |
| 179 | *pixel-=quantum_state->minimum; |
| 180 | *pixel*=quantum_state->scale; |
| 181 | return(pixels); |
| 182 | } |
| 183 | quantum[0]=(*pixels++); |
| 184 | quantum[1]=(*pixels++); |
| 185 | quantum[2]=(*pixels++); |
| 186 | quantum[3]=(*pixels++); |
| 187 | p=(float *) quantum; |
| 188 | *pixel=(*p); |
| 189 | *pixel-=quantum_state->minimum; |
| 190 | *pixel*=quantum_state->scale; |
| 191 | return(pixels); |
| 192 | } |
| 193 | |
| 194 | static inline const unsigned char *PushQuantumPixel( |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 195 | QuantumState *quantum_state,const size_t depth, |
cristy | 4cb162a | 2010-05-30 03:04:47 +0000 | [diff] [blame] | 196 | const unsigned char *pixels,unsigned int *quantum) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 197 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 198 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 199 | i; |
| 200 | |
cristy | 6b825f9 | 2010-06-04 02:01:10 +0000 | [diff] [blame] | 201 | register size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 202 | quantum_bits; |
| 203 | |
| 204 | *quantum=(QuantumAny) 0; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 205 | for (i=(ssize_t) depth; i > 0L; ) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 206 | { |
| 207 | if (quantum_state->bits == 0UL) |
| 208 | { |
| 209 | quantum_state->pixel=(*pixels++); |
cristy | 6b825f9 | 2010-06-04 02:01:10 +0000 | [diff] [blame] | 210 | quantum_state->bits=8UL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 211 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 212 | quantum_bits=(size_t) i; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 213 | if (quantum_bits > quantum_state->bits) |
| 214 | quantum_bits=quantum_state->bits; |
cristy | ebdf07a | 2010-06-04 14:48:53 +0000 | [diff] [blame^] | 215 | i-=(ssize_t) quantum_bits; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 216 | quantum_state->bits-=quantum_bits; |
cristy | 6b825f9 | 2010-06-04 02:01:10 +0000 | [diff] [blame] | 217 | *quantum=(unsigned int) ((*quantum << quantum_bits) | |
| 218 | ((quantum_state->pixel >> quantum_state->bits) &~ ((~0UL) << |
| 219 | quantum_bits))); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 220 | } |
| 221 | return(pixels); |
| 222 | } |
| 223 | |
| 224 | static inline const unsigned char *PushQuantumLongPixel( |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 225 | QuantumState *quantum_state,const size_t depth, |
cristy | 4cb162a | 2010-05-30 03:04:47 +0000 | [diff] [blame] | 226 | const unsigned char *pixels,unsigned int *quantum) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 227 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 228 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 229 | i; |
| 230 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 231 | register size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 232 | quantum_bits; |
| 233 | |
| 234 | *quantum=0UL; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 235 | for (i=(ssize_t) depth; i > 0; ) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 236 | { |
| 237 | if (quantum_state->bits == 0) |
| 238 | { |
| 239 | pixels=PushLongPixel(quantum_state->endian,pixels, |
| 240 | &quantum_state->pixel); |
cristy | 4cb162a | 2010-05-30 03:04:47 +0000 | [diff] [blame] | 241 | quantum_state->bits=32U; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 242 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 243 | quantum_bits=(size_t) i; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 244 | if (quantum_bits > quantum_state->bits) |
| 245 | quantum_bits=quantum_state->bits; |
cristy | 4cb162a | 2010-05-30 03:04:47 +0000 | [diff] [blame] | 246 | *quantum|=(((quantum_state->pixel >> (32U-quantum_state->bits)) & |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 247 | quantum_state->mask[quantum_bits]) << (depth-i)); |
cristy | eaedf06 | 2010-05-29 22:36:02 +0000 | [diff] [blame] | 248 | i-=(ssize_t) quantum_bits; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 249 | quantum_state->bits-=quantum_bits; |
| 250 | } |
| 251 | return(pixels); |
| 252 | } |
| 253 | |
| 254 | MagickExport size_t ImportQuantumPixels(Image *image,CacheView *image_view, |
| 255 | const QuantumInfo *quantum_info,const QuantumType quantum_type, |
| 256 | const unsigned char *pixels,ExceptionInfo *exception) |
| 257 | { |
| 258 | EndianType |
| 259 | endian; |
| 260 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 261 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 262 | bit; |
| 263 | |
| 264 | MagickSizeType |
| 265 | number_pixels; |
| 266 | |
| 267 | QuantumAny |
| 268 | range; |
| 269 | |
| 270 | QuantumState |
| 271 | quantum_state; |
| 272 | |
| 273 | register const unsigned char |
cristy | aebafa2 | 2009-11-26 01:48:56 +0000 | [diff] [blame] | 274 | *restrict p; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 275 | |
| 276 | register IndexPacket |
cristy | c47d1f8 | 2009-11-26 01:44:43 +0000 | [diff] [blame] | 277 | *restrict indexes; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 278 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 279 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 280 | x; |
| 281 | |
| 282 | register PixelPacket |
cristy | c47d1f8 | 2009-11-26 01:44:43 +0000 | [diff] [blame] | 283 | *restrict q; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 284 | |
| 285 | size_t |
| 286 | extent; |
| 287 | |
cristy | 4cb162a | 2010-05-30 03:04:47 +0000 | [diff] [blame] | 288 | unsigned int |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 289 | pixel; |
| 290 | |
| 291 | assert(image != (Image *) NULL); |
| 292 | assert(image->signature == MagickSignature); |
| 293 | if (image->debug != MagickFalse) |
| 294 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 295 | assert(quantum_info != (QuantumInfo *) NULL); |
| 296 | assert(quantum_info->signature == MagickSignature); |
| 297 | if (pixels == (const unsigned char *) NULL) |
| 298 | pixels=GetQuantumPixels(quantum_info); |
| 299 | x=0; |
| 300 | p=pixels; |
cristy | 8a7ea36 | 2010-03-10 20:31:43 +0000 | [diff] [blame] | 301 | if (image_view == (CacheView *) NULL) |
| 302 | { |
| 303 | number_pixels=GetImageExtent(image); |
| 304 | q=GetAuthenticPixelQueue(image); |
| 305 | indexes=GetAuthenticIndexQueue(image); |
| 306 | } |
| 307 | else |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 308 | { |
| 309 | number_pixels=GetCacheViewExtent(image_view); |
| 310 | q=GetCacheViewAuthenticPixelQueue(image_view); |
| 311 | indexes=GetCacheViewAuthenticIndexQueue(image_view); |
| 312 | } |
| 313 | InitializeQuantumState(quantum_info,image->endian,&quantum_state); |
| 314 | extent=GetQuantumExtent(image,quantum_info,quantum_type); |
| 315 | endian=quantum_state.endian; |
| 316 | switch (quantum_type) |
| 317 | { |
| 318 | case IndexQuantum: |
| 319 | { |
| 320 | MagickBooleanType |
| 321 | range_exception; |
| 322 | |
| 323 | if (image->storage_class != PseudoClass) |
| 324 | { |
| 325 | (void) ThrowMagickException(exception,GetMagickModule(),ImageError, |
| 326 | "ColormappedImageRequired","`%s'",image->filename); |
| 327 | return(extent); |
| 328 | } |
| 329 | range_exception=MagickFalse; |
| 330 | switch (quantum_info->depth) |
| 331 | { |
| 332 | case 1: |
| 333 | { |
| 334 | register unsigned char |
| 335 | pixel; |
| 336 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 337 | for (x=0; x < ((ssize_t) number_pixels-7); x+=8) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 338 | { |
| 339 | for (bit=0; bit < 8; bit++) |
| 340 | { |
| 341 | if (quantum_info->min_is_white == MagickFalse) |
| 342 | pixel=(unsigned char) (((*p) & (1 << (7-bit))) == 0 ? |
| 343 | 0x00 : 0x01); |
| 344 | else |
| 345 | pixel=(unsigned char) (((*p) & (1 << (7-bit))) != 0 ? |
| 346 | 0x00 : 0x01); |
| 347 | indexes[x+bit]=PushColormapIndex(image,pixel,&range_exception); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 348 | *q=image->colormap[(ssize_t) indexes[x+bit]]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 349 | q++; |
| 350 | } |
| 351 | p++; |
| 352 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 353 | for (bit=0; bit < (ssize_t) (number_pixels % 8); bit++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 354 | { |
| 355 | if (quantum_info->min_is_white == MagickFalse) |
| 356 | pixel=(unsigned char) (((*p) & (1 << (7-bit))) == 0 ? |
| 357 | 0x00 : 0x01); |
| 358 | else |
| 359 | pixel=(unsigned char) (((*p) & (1 << (7-bit))) != 0 ? |
| 360 | 0x00 : 0x01); |
| 361 | indexes[x+bit]=PushColormapIndex(image,pixel,&range_exception); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 362 | *q=image->colormap[(ssize_t) indexes[x+bit]]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 363 | q++; |
| 364 | } |
| 365 | break; |
| 366 | } |
| 367 | case 4: |
| 368 | { |
| 369 | register unsigned char |
| 370 | pixel; |
| 371 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 372 | for (x=0; x < ((ssize_t) number_pixels-1); x+=2) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 373 | { |
| 374 | pixel=(unsigned char) ((*p >> 4) & 0xf); |
| 375 | indexes[x]=PushColormapIndex(image,pixel,&range_exception); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 376 | *q=image->colormap[(ssize_t) indexes[x]]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 377 | q++; |
| 378 | pixel=(unsigned char) ((*p) & 0xf); |
| 379 | indexes[x+1]=PushColormapIndex(image,pixel,&range_exception); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 380 | *q=image->colormap[(ssize_t) indexes[x+1]]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 381 | p++; |
| 382 | q++; |
| 383 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 384 | for (bit=0; bit < (ssize_t) (number_pixels % 2); bit++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 385 | { |
| 386 | pixel=(unsigned char) ((*p++ >> 4) & 0xf); |
| 387 | indexes[x+bit]=PushColormapIndex(image,pixel,&range_exception); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 388 | *q=image->colormap[(ssize_t) indexes[x+bit]]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 389 | q++; |
| 390 | } |
| 391 | break; |
| 392 | } |
| 393 | case 8: |
| 394 | { |
| 395 | unsigned char |
| 396 | pixel; |
| 397 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 398 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 399 | { |
| 400 | p=PushCharPixel(p,&pixel); |
| 401 | indexes[x]=PushColormapIndex(image,pixel,&range_exception); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 402 | *q=image->colormap[(ssize_t) indexes[x]]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 403 | p+=quantum_info->pad; |
| 404 | q++; |
| 405 | } |
| 406 | break; |
| 407 | } |
| 408 | case 16: |
| 409 | { |
| 410 | unsigned short |
| 411 | pixel; |
| 412 | |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 413 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 414 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 415 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 416 | { |
| 417 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 418 | indexes[x]=PushColormapIndex(image,ClampToQuantum( |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 419 | (MagickRealType) QuantumRange*HalfToSinglePrecision(pixel)), |
| 420 | &range_exception); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 421 | *q=image->colormap[(ssize_t) indexes[x]]; |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 422 | p+=quantum_info->pad; |
| 423 | q++; |
| 424 | } |
| 425 | break; |
| 426 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 427 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 428 | { |
| 429 | p=PushShortPixel(endian,p,&pixel); |
| 430 | indexes[x]=PushColormapIndex(image,pixel,&range_exception); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 431 | *q=image->colormap[(ssize_t) indexes[x]]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 432 | p+=quantum_info->pad; |
| 433 | q++; |
| 434 | } |
| 435 | break; |
| 436 | } |
| 437 | case 32: |
| 438 | { |
cristy | 4cb162a | 2010-05-30 03:04:47 +0000 | [diff] [blame] | 439 | unsigned int |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 440 | pixel; |
| 441 | |
| 442 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 443 | { |
| 444 | float |
| 445 | pixel; |
| 446 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 447 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 448 | { |
| 449 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 450 | indexes[x]=PushColormapIndex(image,ClampToQuantum(pixel), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 451 | &range_exception); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 452 | *q=image->colormap[(ssize_t) indexes[x]]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 453 | p+=quantum_info->pad; |
| 454 | q++; |
| 455 | } |
| 456 | break; |
| 457 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 458 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 459 | { |
| 460 | p=PushLongPixel(endian,p,&pixel); |
| 461 | indexes[x]=PushColormapIndex(image,pixel,&range_exception); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 462 | *q=image->colormap[(ssize_t) indexes[x]]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 463 | p+=quantum_info->pad; |
| 464 | q++; |
| 465 | } |
| 466 | break; |
| 467 | } |
| 468 | case 64: |
| 469 | { |
| 470 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 471 | { |
| 472 | double |
| 473 | pixel; |
| 474 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 475 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 476 | { |
| 477 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 478 | indexes[x]=PushColormapIndex(image,ClampToQuantum(pixel), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 479 | &range_exception); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 480 | *q=image->colormap[(ssize_t) indexes[x]]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 481 | p+=quantum_info->pad; |
| 482 | q++; |
| 483 | } |
| 484 | break; |
| 485 | } |
| 486 | } |
| 487 | default: |
| 488 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 489 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 490 | { |
| 491 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
| 492 | indexes[x]=PushColormapIndex(image,pixel,&range_exception); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 493 | *q=image->colormap[(ssize_t) indexes[x]]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 494 | p+=quantum_info->pad; |
| 495 | q++; |
| 496 | } |
| 497 | break; |
| 498 | } |
| 499 | } |
| 500 | if (range_exception != MagickFalse) |
| 501 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 502 | CorruptImageError,"InvalidColormapIndex","`%s'",image->filename); |
| 503 | break; |
| 504 | } |
| 505 | case IndexAlphaQuantum: |
| 506 | { |
| 507 | MagickBooleanType |
| 508 | range_exception; |
| 509 | |
| 510 | if (image->storage_class != PseudoClass) |
| 511 | { |
| 512 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 513 | ImageError,"ColormappedImageRequired","`%s'",image->filename); |
| 514 | return(extent); |
| 515 | } |
| 516 | range_exception=MagickFalse; |
| 517 | switch (quantum_info->depth) |
| 518 | { |
| 519 | case 1: |
| 520 | { |
| 521 | register unsigned char |
| 522 | pixel; |
| 523 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 524 | for (x=0; x < ((ssize_t) number_pixels-3); x+=4) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 525 | { |
| 526 | for (bit=0; bit < 8; bit+=2) |
| 527 | { |
| 528 | if (quantum_info->min_is_white == MagickFalse) |
| 529 | pixel=(unsigned char) (((*p) & (1 << (7-bit))) == 0 ? |
| 530 | 0x00 : 0x01); |
| 531 | else |
| 532 | pixel=(unsigned char) (((*p) & (1 << (7-bit))) != 0 ? |
| 533 | 0x00 : 0x01); |
| 534 | indexes[x+bit/2]=(IndexPacket) (pixel == 0 ? 0 : 1); |
| 535 | q->red=(Quantum) (pixel == 0 ? 0 : QuantumRange); |
| 536 | q->green=q->red; |
| 537 | q->blue=q->red; |
| 538 | q->opacity=(Quantum) (((*p) & (1UL << (unsigned char) (6-bit))) |
| 539 | == 0 ? TransparentOpacity : OpaqueOpacity); |
| 540 | q++; |
| 541 | } |
| 542 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 543 | for (bit=0; bit < (ssize_t) (number_pixels % 4); bit+=2) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 544 | { |
| 545 | if (quantum_info->min_is_white == MagickFalse) |
| 546 | pixel=(unsigned char) (((*p) & (1 << (7-bit))) == 0 ? |
| 547 | 0x00 : 0x01); |
| 548 | else |
| 549 | pixel=(unsigned char) (((*p) & (1 << (7-bit))) != 0 ? |
| 550 | 0x00 : 0x01); |
| 551 | indexes[x+bit/2]=(IndexPacket) (pixel == 0 ? 0 : 1); |
| 552 | q->red=(Quantum) (pixel == 0 ? 0 : QuantumRange); |
| 553 | q->green=q->red; |
| 554 | q->blue=q->red; |
| 555 | q->opacity=(Quantum) (((*p) & (1UL << (unsigned char) (6-bit))) == |
| 556 | 0 ? TransparentOpacity : OpaqueOpacity); |
| 557 | q++; |
| 558 | } |
| 559 | break; |
| 560 | } |
| 561 | case 4: |
| 562 | { |
| 563 | register unsigned char |
| 564 | pixel; |
| 565 | |
| 566 | range=GetQuantumRange(image->depth); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 567 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 568 | { |
| 569 | pixel=(unsigned char) ((*p >> 4) & 0xf); |
| 570 | indexes[x]=PushColormapIndex(image,pixel,&range_exception); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 571 | *q=image->colormap[(ssize_t) indexes[x]]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 572 | pixel=(unsigned char) ((*p) & 0xf); |
| 573 | q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range)); |
| 574 | p++; |
| 575 | q++; |
| 576 | } |
| 577 | break; |
| 578 | } |
| 579 | case 8: |
| 580 | { |
| 581 | unsigned char |
| 582 | pixel; |
| 583 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 584 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 585 | { |
| 586 | p=PushCharPixel(p,&pixel); |
| 587 | indexes[x]=PushColormapIndex(image,pixel,&range_exception); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 588 | *q=image->colormap[(ssize_t) indexes[x]]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 589 | p=PushCharPixel(p,&pixel); |
| 590 | q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel)); |
| 591 | p+=quantum_info->pad; |
| 592 | q++; |
| 593 | } |
| 594 | break; |
| 595 | } |
| 596 | case 16: |
| 597 | { |
| 598 | unsigned short |
| 599 | pixel; |
| 600 | |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 601 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 602 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 603 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 604 | { |
| 605 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 606 | indexes[x]=PushColormapIndex(image,ClampToQuantum( |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 607 | (MagickRealType) QuantumRange*HalfToSinglePrecision(pixel)), |
| 608 | &range_exception); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 609 | *q=image->colormap[(ssize_t) indexes[x]]; |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 610 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 611 | q->opacity=(Quantum) (QuantumRange-ClampToQuantum( |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 612 | (MagickRealType) QuantumRange*HalfToSinglePrecision(pixel))); |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 613 | p+=quantum_info->pad; |
| 614 | q++; |
| 615 | } |
| 616 | break; |
| 617 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 618 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 619 | { |
| 620 | p=PushShortPixel(endian,p,&pixel); |
| 621 | indexes[x]=PushColormapIndex(image,pixel,&range_exception); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 622 | *q=image->colormap[(ssize_t) indexes[x]]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 623 | p=PushShortPixel(endian,p,&pixel); |
| 624 | q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel)); |
| 625 | p+=quantum_info->pad; |
| 626 | q++; |
| 627 | } |
| 628 | break; |
| 629 | } |
| 630 | case 32: |
| 631 | { |
cristy | 4cb162a | 2010-05-30 03:04:47 +0000 | [diff] [blame] | 632 | unsigned int |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 633 | pixel; |
| 634 | |
| 635 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 636 | { |
| 637 | float |
| 638 | pixel; |
| 639 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 640 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 641 | { |
| 642 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 643 | indexes[x]=PushColormapIndex(image,ClampToQuantum(pixel), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 644 | &range_exception); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 645 | *q=image->colormap[(ssize_t) indexes[x]]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 646 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 647 | q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 648 | p+=quantum_info->pad; |
| 649 | q++; |
| 650 | } |
| 651 | break; |
| 652 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 653 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 654 | { |
| 655 | p=PushLongPixel(endian,p,&pixel); |
| 656 | indexes[x]=PushColormapIndex(image,pixel,&range_exception); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 657 | *q=image->colormap[(ssize_t) indexes[x]]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 658 | p=PushLongPixel(endian,p,&pixel); |
| 659 | q->opacity=(Quantum) (QuantumRange-ScaleLongToQuantum(pixel)); |
| 660 | p+=quantum_info->pad; |
| 661 | q++; |
| 662 | } |
| 663 | break; |
| 664 | } |
| 665 | case 64: |
| 666 | { |
| 667 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 668 | { |
| 669 | double |
| 670 | pixel; |
| 671 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 672 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 673 | { |
| 674 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 675 | indexes[x]=PushColormapIndex(image,ClampToQuantum(pixel), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 676 | &range_exception); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 677 | *q=image->colormap[(ssize_t) indexes[x]]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 678 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 679 | q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 680 | p+=quantum_info->pad; |
| 681 | q++; |
| 682 | } |
| 683 | break; |
| 684 | } |
| 685 | } |
| 686 | default: |
| 687 | { |
| 688 | range=GetQuantumRange(image->depth); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 689 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 690 | { |
| 691 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
| 692 | indexes[x]=PushColormapIndex(image,pixel,&range_exception); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 693 | *q=image->colormap[(ssize_t) indexes[x]]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 694 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
| 695 | q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range)); |
| 696 | p+=quantum_info->pad; |
| 697 | q++; |
| 698 | } |
| 699 | break; |
| 700 | } |
| 701 | } |
| 702 | if (range_exception != MagickFalse) |
| 703 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 704 | CorruptImageError,"InvalidColormapIndex","`%s'",image->filename); |
| 705 | break; |
| 706 | } |
| 707 | case GrayQuantum: |
| 708 | { |
| 709 | switch (quantum_info->depth) |
| 710 | { |
| 711 | case 1: |
| 712 | { |
| 713 | register Quantum |
| 714 | black, |
| 715 | white; |
| 716 | |
| 717 | black=0; |
| 718 | white=(Quantum) QuantumRange; |
| 719 | if (quantum_info->min_is_white != MagickFalse) |
| 720 | { |
| 721 | black=(Quantum) QuantumRange; |
| 722 | white=0; |
| 723 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 724 | for (x=0; x < ((ssize_t) number_pixels-7); x+=8) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 725 | { |
| 726 | for (bit=0; bit < 8; bit++) |
| 727 | { |
| 728 | q->red=(((*p) & (1 << (7-bit))) == 0 ? black : white); |
| 729 | q->green=q->red; |
| 730 | q->blue=q->red; |
| 731 | q++; |
| 732 | } |
| 733 | p++; |
| 734 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 735 | for (bit=0; bit < (ssize_t) (number_pixels % 8); bit++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 736 | { |
| 737 | q->red=(((*p) & (1 << (7-bit))) == 0 ? black : white); |
| 738 | q->green=q->red; |
| 739 | q->blue=q->red; |
| 740 | q++; |
| 741 | } |
| 742 | if (bit != 0) |
| 743 | p++; |
| 744 | break; |
| 745 | } |
| 746 | case 4: |
| 747 | { |
| 748 | register unsigned char |
| 749 | pixel; |
| 750 | |
| 751 | range=GetQuantumRange(image->depth); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 752 | for (x=0; x < ((ssize_t) number_pixels-1); x+=2) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 753 | { |
| 754 | pixel=(unsigned char) ((*p >> 4) & 0xf); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 755 | SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 756 | q->green=q->red; |
| 757 | q->blue=q->red; |
| 758 | q++; |
| 759 | pixel=(unsigned char) ((*p) & 0xf); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 760 | SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 761 | q->green=q->red; |
| 762 | q->blue=q->red; |
| 763 | p++; |
| 764 | q++; |
| 765 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 766 | for (bit=0; bit < (ssize_t) (number_pixels % 2); bit++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 767 | { |
| 768 | pixel=(unsigned char) (*p++ >> 4); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 769 | SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 770 | q->green=q->red; |
| 771 | q->blue=q->red; |
| 772 | q++; |
| 773 | } |
| 774 | break; |
| 775 | } |
| 776 | case 8: |
| 777 | { |
| 778 | unsigned char |
| 779 | pixel; |
| 780 | |
| 781 | if (quantum_info->min_is_white != MagickFalse) |
| 782 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 783 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 784 | { |
| 785 | p=PushCharPixel(p,&pixel); |
| 786 | q->red=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel)); |
| 787 | q->green=q->red; |
| 788 | q->blue=q->red; |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 789 | SetOpacityPixelComponent(q,OpaqueOpacity); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 790 | p+=quantum_info->pad; |
| 791 | q++; |
| 792 | } |
| 793 | break; |
| 794 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 795 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 796 | { |
| 797 | p=PushCharPixel(p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 798 | SetRedPixelComponent(q,ScaleCharToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 799 | q->green=q->red; |
| 800 | q->blue=q->red; |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 801 | SetOpacityPixelComponent(q,OpaqueOpacity); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 802 | p+=quantum_info->pad; |
| 803 | q++; |
| 804 | } |
| 805 | break; |
| 806 | } |
| 807 | case 10: |
| 808 | { |
| 809 | range=GetQuantumRange(image->depth); |
| 810 | if (quantum_info->pack == MagickFalse) |
| 811 | { |
| 812 | if (image->endian != LSBEndian) |
| 813 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 814 | for (x=0; x < (ssize_t) (number_pixels-2); x+=3) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 815 | { |
| 816 | p=PushLongPixel(endian,p,&pixel); |
cristy | ff024b4 | 2010-02-21 22:55:09 +0000 | [diff] [blame] | 817 | q->red=ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 818 | q->green=q->red; |
| 819 | q->blue=q->red; |
| 820 | q++; |
cristy | ff024b4 | 2010-02-21 22:55:09 +0000 | [diff] [blame] | 821 | q->red=ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 822 | q->green=q->red; |
| 823 | q->blue=q->red; |
| 824 | q++; |
cristy | ff024b4 | 2010-02-21 22:55:09 +0000 | [diff] [blame] | 825 | q->red=ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 826 | q->green=q->red; |
| 827 | q->blue=q->red; |
| 828 | p+=quantum_info->pad; |
| 829 | q++; |
| 830 | } |
cristy | 69702dd | 2010-02-22 15:26:39 +0000 | [diff] [blame] | 831 | p=PushLongPixel(endian,p,&pixel); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 832 | if (x++ < (ssize_t) (number_pixels-1)) |
cristy | 69702dd | 2010-02-22 15:26:39 +0000 | [diff] [blame] | 833 | { |
| 834 | q->red=ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range); |
| 835 | q->green=q->red; |
| 836 | q->blue=q->red; |
| 837 | q++; |
| 838 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 839 | if (x++ < (ssize_t) number_pixels) |
cristy | 69702dd | 2010-02-22 15:26:39 +0000 | [diff] [blame] | 840 | { |
| 841 | q->red=ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range); |
| 842 | q->green=q->red; |
| 843 | q->blue=q->red; |
| 844 | q++; |
| 845 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 846 | break; |
| 847 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 848 | for (x=0; x < (ssize_t) (number_pixels-2); x+=3) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 849 | { |
| 850 | p=PushLongPixel(endian,p,&pixel); |
| 851 | q->red=ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range); |
| 852 | q->green=q->red; |
| 853 | q->blue=q->red; |
| 854 | q++; |
| 855 | q->red=ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range); |
| 856 | q->green=q->red; |
| 857 | q->blue=q->red; |
| 858 | q++; |
| 859 | q->red=ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range); |
| 860 | q->green=q->red; |
| 861 | q->blue=q->red; |
| 862 | p+=quantum_info->pad; |
| 863 | q++; |
| 864 | } |
cristy | 69702dd | 2010-02-22 15:26:39 +0000 | [diff] [blame] | 865 | p=PushLongPixel(endian,p,&pixel); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 866 | if (x++ < (ssize_t) (number_pixels-1)) |
cristy | 69702dd | 2010-02-22 15:26:39 +0000 | [diff] [blame] | 867 | { |
| 868 | q->red=ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range); |
| 869 | q->green=q->red; |
| 870 | q->blue=q->red; |
| 871 | q++; |
| 872 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 873 | if (x++ < (ssize_t) number_pixels) |
cristy | 69702dd | 2010-02-22 15:26:39 +0000 | [diff] [blame] | 874 | { |
| 875 | q->red=ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range); |
| 876 | q->green=q->red; |
| 877 | q->blue=q->red; |
| 878 | q++; |
| 879 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 880 | break; |
| 881 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 882 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 883 | { |
| 884 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 885 | SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 886 | q->green=q->red; |
| 887 | q->blue=q->red; |
| 888 | p+=quantum_info->pad; |
| 889 | q++; |
| 890 | } |
| 891 | break; |
| 892 | } |
| 893 | case 12: |
| 894 | { |
| 895 | range=GetQuantumRange(image->depth); |
| 896 | if (quantum_info->pack == MagickFalse) |
| 897 | { |
| 898 | unsigned short |
| 899 | pixel; |
| 900 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 901 | for (x=0; x < (ssize_t) (number_pixels-1); x+=2) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 902 | { |
| 903 | p=PushShortPixel(endian,p,&pixel); |
| 904 | q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range); |
| 905 | q->green=q->red; |
| 906 | q->blue=q->red; |
| 907 | q++; |
| 908 | p=PushShortPixel(endian,p,&pixel); |
| 909 | q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range); |
| 910 | q->green=q->red; |
| 911 | q->blue=q->red; |
| 912 | p+=quantum_info->pad; |
| 913 | q++; |
| 914 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 915 | for (bit=0; bit < (ssize_t) (number_pixels % 2); bit++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 916 | { |
| 917 | p=PushShortPixel(endian,p,&pixel); |
| 918 | q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range); |
| 919 | q->green=q->red; |
| 920 | q->blue=q->red; |
| 921 | p+=quantum_info->pad; |
| 922 | q++; |
| 923 | } |
| 924 | if (bit != 0) |
| 925 | p++; |
| 926 | break; |
| 927 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 928 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 929 | { |
| 930 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 931 | SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 932 | q->green=q->red; |
| 933 | q->blue=q->red; |
| 934 | p+=quantum_info->pad; |
| 935 | q++; |
| 936 | } |
| 937 | break; |
| 938 | } |
| 939 | case 16: |
| 940 | { |
| 941 | unsigned short |
| 942 | pixel; |
| 943 | |
| 944 | if (quantum_info->min_is_white != MagickFalse) |
| 945 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 946 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 947 | { |
| 948 | p=PushShortPixel(endian,p,&pixel); |
| 949 | q->red=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel)); |
| 950 | q->green=q->red; |
| 951 | q->blue=q->red; |
| 952 | p+=quantum_info->pad; |
| 953 | q++; |
| 954 | } |
| 955 | break; |
| 956 | } |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 957 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 958 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 959 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 960 | { |
| 961 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 962 | q->red=ClampToQuantum((MagickRealType) QuantumRange* |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 963 | HalfToSinglePrecision(pixel)); |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 964 | q->green=q->red; |
| 965 | q->blue=q->red; |
| 966 | p+=quantum_info->pad; |
| 967 | q++; |
| 968 | } |
| 969 | break; |
| 970 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 971 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 972 | { |
| 973 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 974 | SetRedPixelComponent(q,ScaleShortToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 975 | q->green=q->red; |
| 976 | q->blue=q->red; |
| 977 | p+=quantum_info->pad; |
| 978 | q++; |
| 979 | } |
| 980 | break; |
| 981 | } |
| 982 | case 32: |
| 983 | { |
cristy | 4cb162a | 2010-05-30 03:04:47 +0000 | [diff] [blame] | 984 | unsigned int |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 985 | pixel; |
| 986 | |
| 987 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 988 | { |
| 989 | float |
| 990 | pixel; |
| 991 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 992 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 993 | { |
| 994 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 995 | q->red=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 996 | q->green=q->red; |
| 997 | q->blue=q->red; |
| 998 | p+=quantum_info->pad; |
| 999 | q++; |
| 1000 | } |
| 1001 | break; |
| 1002 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1003 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1004 | { |
| 1005 | p=PushLongPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1006 | SetRedPixelComponent(q,ScaleLongToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1007 | q->green=q->red; |
| 1008 | q->blue=q->red; |
| 1009 | p+=quantum_info->pad; |
| 1010 | q++; |
| 1011 | } |
| 1012 | break; |
| 1013 | } |
| 1014 | case 64: |
| 1015 | { |
| 1016 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 1017 | { |
| 1018 | double |
| 1019 | pixel; |
| 1020 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1021 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1022 | { |
| 1023 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1024 | q->red=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1025 | q->green=q->red; |
| 1026 | q->blue=q->red; |
| 1027 | p+=quantum_info->pad; |
| 1028 | q++; |
| 1029 | } |
| 1030 | break; |
| 1031 | } |
| 1032 | } |
| 1033 | default: |
| 1034 | { |
| 1035 | range=GetQuantumRange(image->depth); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1036 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1037 | { |
| 1038 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1039 | SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1040 | q->green=q->red; |
| 1041 | q->blue=q->red; |
| 1042 | p+=quantum_info->pad; |
| 1043 | q++; |
| 1044 | } |
| 1045 | break; |
| 1046 | } |
| 1047 | } |
| 1048 | break; |
| 1049 | } |
| 1050 | case GrayAlphaQuantum: |
| 1051 | { |
| 1052 | switch (quantum_info->depth) |
| 1053 | { |
| 1054 | case 1: |
| 1055 | { |
| 1056 | register unsigned char |
| 1057 | pixel; |
| 1058 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1059 | for (x=0; x < ((ssize_t) number_pixels-3); x+=4) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1060 | { |
| 1061 | for (bit=0; bit < 8; bit+=2) |
| 1062 | { |
| 1063 | pixel=(unsigned char) |
| 1064 | (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01); |
| 1065 | q->red=(Quantum) (pixel == 0 ? 0 : QuantumRange); |
| 1066 | q->green=q->red; |
| 1067 | q->blue=q->red; |
| 1068 | q->opacity=(Quantum) (((*p) & (1UL << (unsigned char) (6-bit))) |
| 1069 | == 0 ? TransparentOpacity : OpaqueOpacity); |
| 1070 | q++; |
| 1071 | } |
| 1072 | p++; |
| 1073 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1074 | for (bit=0; bit < (ssize_t) (number_pixels % 4); bit+=2) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1075 | { |
| 1076 | pixel=(unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01); |
| 1077 | q->red=(Quantum) (pixel == 0 ? 0 : QuantumRange); |
| 1078 | q->green=q->red; |
| 1079 | q->blue=q->red; |
| 1080 | q->opacity=(Quantum) (((*p) & (1UL << (unsigned char) (6-bit))) == 0 |
| 1081 | ? TransparentOpacity : OpaqueOpacity); |
| 1082 | q++; |
| 1083 | } |
| 1084 | if (bit != 0) |
| 1085 | p++; |
| 1086 | break; |
| 1087 | } |
| 1088 | case 4: |
| 1089 | { |
| 1090 | register unsigned char |
| 1091 | pixel; |
| 1092 | |
| 1093 | range=GetQuantumRange(image->depth); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1094 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1095 | { |
| 1096 | pixel=(unsigned char) ((*p >> 4) & 0xf); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1097 | SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1098 | q->green=q->red; |
| 1099 | q->blue=q->red; |
| 1100 | pixel=(unsigned char) ((*p) & 0xf); |
| 1101 | q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range)); |
| 1102 | p++; |
| 1103 | q++; |
| 1104 | } |
| 1105 | break; |
| 1106 | } |
| 1107 | case 8: |
| 1108 | { |
| 1109 | unsigned char |
| 1110 | pixel; |
| 1111 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1112 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1113 | { |
| 1114 | p=PushCharPixel(p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1115 | SetRedPixelComponent(q,ScaleCharToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1116 | q->green=q->red; |
| 1117 | q->blue=q->red; |
| 1118 | p=PushCharPixel(p,&pixel); |
| 1119 | q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel)); |
| 1120 | p+=quantum_info->pad; |
| 1121 | q++; |
| 1122 | } |
| 1123 | break; |
| 1124 | } |
| 1125 | case 10: |
| 1126 | { |
| 1127 | range=GetQuantumRange(image->depth); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1128 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1129 | { |
| 1130 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1131 | SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1132 | q->green=q->red; |
| 1133 | q->blue=q->red; |
| 1134 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1135 | SetOpacityPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1136 | p+=quantum_info->pad; |
| 1137 | q++; |
| 1138 | } |
| 1139 | break; |
| 1140 | } |
| 1141 | case 12: |
| 1142 | { |
| 1143 | range=GetQuantumRange(image->depth); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1144 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1145 | { |
| 1146 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1147 | SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1148 | q->green=q->red; |
| 1149 | q->blue=q->red; |
| 1150 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1151 | SetOpacityPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1152 | p+=quantum_info->pad; |
| 1153 | q++; |
| 1154 | } |
| 1155 | break; |
| 1156 | } |
| 1157 | case 16: |
| 1158 | { |
| 1159 | unsigned short |
| 1160 | pixel; |
| 1161 | |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 1162 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 1163 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1164 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 1165 | { |
| 1166 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1167 | q->red=ClampToQuantum((MagickRealType) QuantumRange* |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 1168 | HalfToSinglePrecision(pixel)); |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 1169 | q->green=q->red; |
| 1170 | q->blue=q->red; |
| 1171 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1172 | q->opacity=(Quantum) (QuantumRange-ClampToQuantum( |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 1173 | (MagickRealType) QuantumRange*HalfToSinglePrecision(pixel))); |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 1174 | p+=quantum_info->pad; |
| 1175 | q++; |
| 1176 | } |
| 1177 | break; |
| 1178 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1179 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1180 | { |
| 1181 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1182 | SetRedPixelComponent(q,ScaleShortToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1183 | q->green=q->red; |
| 1184 | q->blue=q->red; |
| 1185 | p=PushShortPixel(endian,p,&pixel); |
| 1186 | q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel)); |
| 1187 | p+=quantum_info->pad; |
| 1188 | q++; |
| 1189 | } |
| 1190 | break; |
| 1191 | } |
| 1192 | case 32: |
| 1193 | { |
cristy | 4cb162a | 2010-05-30 03:04:47 +0000 | [diff] [blame] | 1194 | unsigned int |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1195 | pixel; |
| 1196 | |
| 1197 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 1198 | { |
| 1199 | float |
| 1200 | pixel; |
| 1201 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1202 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1203 | { |
| 1204 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1205 | q->red=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1206 | q->green=q->red; |
| 1207 | q->blue=q->red; |
| 1208 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1209 | q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1210 | p+=quantum_info->pad; |
| 1211 | q++; |
| 1212 | } |
| 1213 | break; |
| 1214 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1215 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1216 | { |
| 1217 | p=PushLongPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1218 | SetRedPixelComponent(q,ScaleLongToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1219 | q->green=q->red; |
| 1220 | q->blue=q->red; |
| 1221 | p=PushLongPixel(endian,p,&pixel); |
| 1222 | q->opacity=(Quantum) (QuantumRange-ScaleLongToQuantum(pixel)); |
| 1223 | p+=quantum_info->pad; |
| 1224 | q++; |
| 1225 | } |
| 1226 | break; |
| 1227 | } |
| 1228 | case 64: |
| 1229 | { |
| 1230 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 1231 | { |
| 1232 | double |
| 1233 | pixel; |
| 1234 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1235 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1236 | { |
| 1237 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1238 | q->red=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1239 | q->green=q->red; |
| 1240 | q->blue=q->red; |
| 1241 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1242 | q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1243 | p+=quantum_info->pad; |
| 1244 | q++; |
| 1245 | } |
| 1246 | break; |
| 1247 | } |
| 1248 | } |
| 1249 | default: |
| 1250 | { |
| 1251 | range=GetQuantumRange(image->depth); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1252 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1253 | { |
| 1254 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1255 | SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1256 | q->green=q->red; |
| 1257 | q->blue=q->red; |
| 1258 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
| 1259 | q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range)); |
| 1260 | p+=quantum_info->pad; |
| 1261 | q++; |
| 1262 | } |
| 1263 | break; |
| 1264 | } |
| 1265 | } |
| 1266 | break; |
| 1267 | } |
| 1268 | case RedQuantum: |
| 1269 | case CyanQuantum: |
| 1270 | { |
| 1271 | switch (quantum_info->depth) |
| 1272 | { |
| 1273 | case 8: |
| 1274 | { |
| 1275 | unsigned char |
| 1276 | pixel; |
| 1277 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1278 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1279 | { |
| 1280 | p=PushCharPixel(p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1281 | SetRedPixelComponent(q,ScaleCharToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1282 | p+=quantum_info->pad; |
| 1283 | q++; |
| 1284 | } |
| 1285 | break; |
| 1286 | } |
| 1287 | case 16: |
| 1288 | { |
| 1289 | unsigned short |
| 1290 | pixel; |
| 1291 | |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 1292 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 1293 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1294 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 1295 | { |
| 1296 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1297 | q->red=ClampToQuantum((MagickRealType) QuantumRange* |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 1298 | HalfToSinglePrecision(pixel)); |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 1299 | p+=quantum_info->pad; |
| 1300 | q++; |
| 1301 | } |
| 1302 | break; |
| 1303 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1304 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1305 | { |
| 1306 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1307 | SetRedPixelComponent(q,ScaleShortToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1308 | p+=quantum_info->pad; |
| 1309 | q++; |
| 1310 | } |
| 1311 | break; |
| 1312 | } |
| 1313 | case 32: |
| 1314 | { |
cristy | 4cb162a | 2010-05-30 03:04:47 +0000 | [diff] [blame] | 1315 | unsigned int |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1316 | pixel; |
| 1317 | |
| 1318 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 1319 | { |
| 1320 | float |
| 1321 | pixel; |
| 1322 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1323 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1324 | { |
| 1325 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1326 | q->red=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1327 | p+=quantum_info->pad; |
| 1328 | q++; |
| 1329 | } |
| 1330 | break; |
| 1331 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1332 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1333 | { |
| 1334 | p=PushLongPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1335 | SetRedPixelComponent(q,ScaleLongToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1336 | p+=quantum_info->pad; |
| 1337 | q++; |
| 1338 | } |
| 1339 | break; |
| 1340 | } |
| 1341 | case 64: |
| 1342 | { |
| 1343 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 1344 | { |
| 1345 | double |
| 1346 | pixel; |
| 1347 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1348 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1349 | { |
| 1350 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1351 | q->red=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1352 | p+=quantum_info->pad; |
| 1353 | q++; |
| 1354 | } |
| 1355 | break; |
| 1356 | } |
| 1357 | } |
| 1358 | default: |
| 1359 | { |
| 1360 | range=GetQuantumRange(image->depth); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1361 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1362 | { |
| 1363 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1364 | SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1365 | p+=quantum_info->pad; |
| 1366 | q++; |
| 1367 | } |
| 1368 | break; |
| 1369 | } |
| 1370 | } |
| 1371 | break; |
| 1372 | } |
| 1373 | case GreenQuantum: |
| 1374 | case MagentaQuantum: |
| 1375 | { |
| 1376 | switch (quantum_info->depth) |
| 1377 | { |
| 1378 | case 8: |
| 1379 | { |
| 1380 | unsigned char |
| 1381 | pixel; |
| 1382 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1383 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1384 | { |
| 1385 | p=PushCharPixel(p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1386 | SetGreenPixelComponent(q,ScaleCharToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1387 | p+=quantum_info->pad; |
| 1388 | q++; |
| 1389 | } |
| 1390 | break; |
| 1391 | } |
| 1392 | case 16: |
| 1393 | { |
| 1394 | unsigned short |
| 1395 | pixel; |
| 1396 | |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 1397 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 1398 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1399 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 1400 | { |
| 1401 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1402 | q->green=ClampToQuantum((MagickRealType) QuantumRange* |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 1403 | HalfToSinglePrecision(pixel)); |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 1404 | p+=quantum_info->pad; |
| 1405 | q++; |
| 1406 | } |
| 1407 | break; |
| 1408 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1409 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1410 | { |
| 1411 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1412 | SetGreenPixelComponent(q,ScaleShortToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1413 | p+=quantum_info->pad; |
| 1414 | q++; |
| 1415 | } |
| 1416 | break; |
| 1417 | } |
| 1418 | case 32: |
| 1419 | { |
cristy | 4cb162a | 2010-05-30 03:04:47 +0000 | [diff] [blame] | 1420 | unsigned int |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1421 | pixel; |
| 1422 | |
| 1423 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 1424 | { |
| 1425 | float |
| 1426 | pixel; |
| 1427 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1428 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1429 | { |
| 1430 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1431 | q->green=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1432 | p+=quantum_info->pad; |
| 1433 | q++; |
| 1434 | } |
| 1435 | break; |
| 1436 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1437 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1438 | { |
| 1439 | p=PushLongPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1440 | SetGreenPixelComponent(q,ScaleLongToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1441 | p+=quantum_info->pad; |
| 1442 | q++; |
| 1443 | } |
| 1444 | break; |
| 1445 | } |
| 1446 | case 64: |
| 1447 | { |
| 1448 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 1449 | { |
| 1450 | double |
| 1451 | pixel; |
| 1452 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1453 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1454 | { |
| 1455 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1456 | q->green=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1457 | p+=quantum_info->pad; |
| 1458 | q++; |
| 1459 | } |
| 1460 | break; |
| 1461 | } |
| 1462 | } |
| 1463 | default: |
| 1464 | { |
| 1465 | range=GetQuantumRange(image->depth); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1466 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1467 | { |
| 1468 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1469 | SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1470 | p+=quantum_info->pad; |
| 1471 | q++; |
| 1472 | } |
| 1473 | break; |
| 1474 | } |
| 1475 | } |
| 1476 | break; |
| 1477 | } |
| 1478 | case BlueQuantum: |
| 1479 | case YellowQuantum: |
| 1480 | { |
| 1481 | switch (quantum_info->depth) |
| 1482 | { |
| 1483 | case 8: |
| 1484 | { |
| 1485 | unsigned char |
| 1486 | pixel; |
| 1487 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1488 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1489 | { |
| 1490 | p=PushCharPixel(p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1491 | SetBluePixelComponent(q,ScaleCharToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1492 | p+=quantum_info->pad; |
| 1493 | q++; |
| 1494 | } |
| 1495 | break; |
| 1496 | } |
| 1497 | case 16: |
| 1498 | { |
| 1499 | unsigned short |
| 1500 | pixel; |
| 1501 | |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 1502 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 1503 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1504 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 1505 | { |
| 1506 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1507 | q->blue=ClampToQuantum((MagickRealType) QuantumRange* |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 1508 | HalfToSinglePrecision(pixel)); |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 1509 | p+=quantum_info->pad; |
| 1510 | q++; |
| 1511 | } |
| 1512 | break; |
| 1513 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1514 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1515 | { |
| 1516 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1517 | SetBluePixelComponent(q,ScaleShortToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1518 | p+=quantum_info->pad; |
| 1519 | q++; |
| 1520 | } |
| 1521 | break; |
| 1522 | } |
| 1523 | case 32: |
| 1524 | { |
cristy | 4cb162a | 2010-05-30 03:04:47 +0000 | [diff] [blame] | 1525 | unsigned int |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1526 | pixel; |
| 1527 | |
| 1528 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 1529 | { |
| 1530 | float |
| 1531 | pixel; |
| 1532 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1533 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1534 | { |
| 1535 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1536 | q->blue=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1537 | p+=quantum_info->pad; |
| 1538 | q++; |
| 1539 | } |
| 1540 | break; |
| 1541 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1542 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1543 | { |
| 1544 | p=PushLongPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1545 | SetBluePixelComponent(q,ScaleLongToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1546 | p+=quantum_info->pad; |
| 1547 | q++; |
| 1548 | } |
| 1549 | break; |
| 1550 | } |
| 1551 | case 64: |
| 1552 | { |
| 1553 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 1554 | { |
| 1555 | double |
| 1556 | pixel; |
| 1557 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1558 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1559 | { |
| 1560 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1561 | q->blue=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1562 | p+=quantum_info->pad; |
| 1563 | q++; |
| 1564 | } |
| 1565 | break; |
| 1566 | } |
| 1567 | } |
| 1568 | default: |
| 1569 | { |
| 1570 | range=GetQuantumRange(image->depth); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1571 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1572 | { |
| 1573 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1574 | SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1575 | p+=quantum_info->pad; |
| 1576 | q++; |
| 1577 | } |
| 1578 | break; |
| 1579 | } |
| 1580 | } |
| 1581 | break; |
| 1582 | } |
| 1583 | case AlphaQuantum: |
| 1584 | { |
| 1585 | switch (quantum_info->depth) |
| 1586 | { |
| 1587 | case 8: |
| 1588 | { |
| 1589 | unsigned char |
| 1590 | pixel; |
| 1591 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1592 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1593 | { |
| 1594 | p=PushCharPixel(p,&pixel); |
| 1595 | q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel)); |
| 1596 | p+=quantum_info->pad; |
| 1597 | q++; |
| 1598 | } |
| 1599 | break; |
| 1600 | } |
| 1601 | case 16: |
| 1602 | { |
| 1603 | unsigned short |
| 1604 | pixel; |
| 1605 | |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 1606 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 1607 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1608 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 1609 | { |
| 1610 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1611 | q->opacity=(Quantum) (QuantumRange-ClampToQuantum( |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 1612 | (MagickRealType) QuantumRange*HalfToSinglePrecision(pixel))); |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 1613 | p+=quantum_info->pad; |
| 1614 | q++; |
| 1615 | } |
| 1616 | break; |
| 1617 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1618 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1619 | { |
| 1620 | p=PushShortPixel(endian,p,&pixel); |
| 1621 | q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel)); |
| 1622 | p+=quantum_info->pad; |
| 1623 | q++; |
| 1624 | } |
| 1625 | break; |
| 1626 | } |
| 1627 | case 32: |
| 1628 | { |
cristy | 4cb162a | 2010-05-30 03:04:47 +0000 | [diff] [blame] | 1629 | unsigned int |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1630 | pixel; |
| 1631 | |
| 1632 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 1633 | { |
| 1634 | float |
| 1635 | pixel; |
| 1636 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1637 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1638 | { |
| 1639 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1640 | q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1641 | p+=quantum_info->pad; |
| 1642 | q++; |
| 1643 | } |
| 1644 | break; |
| 1645 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1646 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1647 | { |
| 1648 | p=PushLongPixel(endian,p,&pixel); |
| 1649 | q->opacity=(Quantum) (QuantumRange-ScaleLongToQuantum(pixel)); |
| 1650 | p+=quantum_info->pad; |
| 1651 | q++; |
| 1652 | } |
| 1653 | break; |
| 1654 | } |
| 1655 | case 64: |
| 1656 | { |
| 1657 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 1658 | { |
| 1659 | double |
| 1660 | pixel; |
| 1661 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1662 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1663 | { |
| 1664 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1665 | q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1666 | p+=quantum_info->pad; |
| 1667 | q++; |
| 1668 | } |
| 1669 | break; |
| 1670 | } |
| 1671 | } |
| 1672 | default: |
| 1673 | { |
| 1674 | range=GetQuantumRange(image->depth); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1675 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1676 | { |
| 1677 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
| 1678 | q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range)); |
| 1679 | p+=quantum_info->pad; |
| 1680 | q++; |
| 1681 | } |
| 1682 | break; |
| 1683 | } |
| 1684 | } |
| 1685 | break; |
| 1686 | } |
| 1687 | case BlackQuantum: |
| 1688 | { |
| 1689 | if (image->colorspace != CMYKColorspace) |
| 1690 | { |
| 1691 | (void) ThrowMagickException(exception,GetMagickModule(),ImageError, |
| 1692 | "ColorSeparatedImageRequired","`%s'",image->filename); |
| 1693 | return(extent); |
| 1694 | } |
| 1695 | switch (quantum_info->depth) |
| 1696 | { |
| 1697 | case 8: |
| 1698 | { |
| 1699 | unsigned char |
| 1700 | pixel; |
| 1701 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1702 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1703 | { |
| 1704 | p=PushCharPixel(p,&pixel); |
| 1705 | indexes[x]=ScaleCharToQuantum(pixel); |
| 1706 | p+=quantum_info->pad; |
| 1707 | } |
| 1708 | break; |
| 1709 | } |
| 1710 | case 16: |
| 1711 | { |
| 1712 | unsigned short |
| 1713 | pixel; |
| 1714 | |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 1715 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 1716 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1717 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 1718 | { |
| 1719 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1720 | indexes[x]=ClampToQuantum((MagickRealType) QuantumRange* |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 1721 | HalfToSinglePrecision(pixel)); |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 1722 | p+=quantum_info->pad; |
| 1723 | } |
| 1724 | break; |
| 1725 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1726 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1727 | { |
| 1728 | p=PushShortPixel(endian,p,&pixel); |
| 1729 | indexes[x]=ScaleShortToQuantum(pixel); |
| 1730 | p+=quantum_info->pad; |
| 1731 | } |
| 1732 | break; |
| 1733 | } |
| 1734 | case 32: |
| 1735 | { |
cristy | 4cb162a | 2010-05-30 03:04:47 +0000 | [diff] [blame] | 1736 | unsigned int |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1737 | pixel; |
| 1738 | |
| 1739 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 1740 | { |
| 1741 | float |
| 1742 | pixel; |
| 1743 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1744 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1745 | { |
| 1746 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1747 | indexes[x]=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1748 | p+=quantum_info->pad; |
| 1749 | q++; |
| 1750 | } |
| 1751 | break; |
| 1752 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1753 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1754 | { |
| 1755 | p=PushLongPixel(endian,p,&pixel); |
| 1756 | indexes[x]=ScaleLongToQuantum(pixel); |
| 1757 | p+=quantum_info->pad; |
| 1758 | q++; |
| 1759 | } |
| 1760 | break; |
| 1761 | } |
| 1762 | case 64: |
| 1763 | { |
| 1764 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 1765 | { |
| 1766 | double |
| 1767 | pixel; |
| 1768 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1769 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1770 | { |
| 1771 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1772 | indexes[x]=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1773 | p+=quantum_info->pad; |
| 1774 | q++; |
| 1775 | } |
| 1776 | break; |
| 1777 | } |
| 1778 | } |
| 1779 | default: |
| 1780 | { |
| 1781 | range=GetQuantumRange(image->depth); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1782 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1783 | { |
| 1784 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
| 1785 | indexes[x]=ScaleAnyToQuantum(pixel,range); |
| 1786 | p+=quantum_info->pad; |
| 1787 | q++; |
| 1788 | } |
| 1789 | break; |
| 1790 | } |
| 1791 | } |
| 1792 | break; |
| 1793 | } |
| 1794 | case RGBQuantum: |
| 1795 | case CbYCrQuantum: |
| 1796 | { |
| 1797 | switch (quantum_info->depth) |
| 1798 | { |
| 1799 | case 8: |
| 1800 | { |
| 1801 | unsigned char |
| 1802 | pixel; |
| 1803 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1804 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1805 | { |
| 1806 | p=PushCharPixel(p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1807 | SetRedPixelComponent(q,ScaleCharToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1808 | p=PushCharPixel(p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1809 | SetGreenPixelComponent(q,ScaleCharToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1810 | p=PushCharPixel(p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1811 | SetBluePixelComponent(q,ScaleCharToQuantum(pixel)); |
| 1812 | SetOpacityPixelComponent(q,OpaqueOpacity); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1813 | p+=quantum_info->pad; |
| 1814 | q++; |
| 1815 | } |
| 1816 | break; |
| 1817 | } |
| 1818 | case 10: |
| 1819 | { |
| 1820 | range=GetQuantumRange(image->depth); |
| 1821 | if (quantum_info->pack == MagickFalse) |
| 1822 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1823 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1824 | { |
| 1825 | p=PushLongPixel(endian,p,&pixel); |
| 1826 | q->red=ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range); |
| 1827 | q->green=ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range); |
| 1828 | q->blue=ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range); |
| 1829 | p+=quantum_info->pad; |
| 1830 | q++; |
| 1831 | } |
| 1832 | break; |
| 1833 | } |
cristy | 4cb162a | 2010-05-30 03:04:47 +0000 | [diff] [blame] | 1834 | if (quantum_info->quantum == 32U) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1835 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1836 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1837 | { |
| 1838 | p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1839 | SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1840 | p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1841 | SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1842 | p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1843 | SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1844 | q++; |
| 1845 | } |
| 1846 | break; |
| 1847 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1848 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1849 | { |
| 1850 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1851 | SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1852 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1853 | SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1854 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1855 | SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1856 | q++; |
| 1857 | } |
| 1858 | break; |
| 1859 | } |
| 1860 | case 12: |
| 1861 | { |
| 1862 | range=GetQuantumRange(image->depth); |
| 1863 | if (quantum_info->pack == MagickFalse) |
| 1864 | { |
| 1865 | unsigned short |
| 1866 | pixel; |
| 1867 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1868 | for (x=0; x < (ssize_t) (3*number_pixels-1); x+=2) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1869 | { |
| 1870 | p=PushShortPixel(endian,p,&pixel); |
| 1871 | switch (x % 3) |
| 1872 | { |
| 1873 | default: |
| 1874 | case 0: |
| 1875 | { |
| 1876 | q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range); |
| 1877 | break; |
| 1878 | } |
| 1879 | case 1: |
| 1880 | { |
| 1881 | q->green=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range); |
| 1882 | break; |
| 1883 | } |
| 1884 | case 2: |
| 1885 | { |
| 1886 | q->blue=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range); |
| 1887 | q++; |
| 1888 | break; |
| 1889 | } |
| 1890 | } |
| 1891 | p=PushShortPixel(endian,p,&pixel); |
| 1892 | switch ((x+1) % 3) |
| 1893 | { |
| 1894 | default: |
| 1895 | case 0: |
| 1896 | { |
| 1897 | q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range); |
| 1898 | break; |
| 1899 | } |
| 1900 | case 1: |
| 1901 | { |
| 1902 | q->green=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range); |
| 1903 | break; |
| 1904 | } |
| 1905 | case 2: |
| 1906 | { |
| 1907 | q->blue=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range); |
| 1908 | q++; |
| 1909 | break; |
| 1910 | } |
| 1911 | } |
| 1912 | p+=quantum_info->pad; |
| 1913 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1914 | for (bit=0; bit < (ssize_t) (3*number_pixels % 2); bit++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1915 | { |
| 1916 | p=PushShortPixel(endian,p,&pixel); |
| 1917 | switch ((x+bit) % 3) |
| 1918 | { |
| 1919 | default: |
| 1920 | case 0: |
| 1921 | { |
| 1922 | q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range); |
| 1923 | break; |
| 1924 | } |
| 1925 | case 1: |
| 1926 | { |
| 1927 | q->green=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range); |
| 1928 | break; |
| 1929 | } |
| 1930 | case 2: |
| 1931 | { |
| 1932 | q->blue=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range); |
| 1933 | q++; |
| 1934 | break; |
| 1935 | } |
| 1936 | } |
| 1937 | p+=quantum_info->pad; |
| 1938 | } |
| 1939 | if (bit != 0) |
| 1940 | p++; |
| 1941 | break; |
| 1942 | } |
cristy | 4cb162a | 2010-05-30 03:04:47 +0000 | [diff] [blame] | 1943 | if (quantum_info->quantum == 32U) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1944 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1945 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1946 | { |
| 1947 | p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1948 | SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1949 | p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1950 | SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1951 | p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1952 | SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1953 | q++; |
| 1954 | } |
| 1955 | break; |
| 1956 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1957 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1958 | { |
| 1959 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1960 | SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1961 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1962 | SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1963 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1964 | SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1965 | q++; |
| 1966 | } |
| 1967 | break; |
| 1968 | } |
| 1969 | case 16: |
| 1970 | { |
| 1971 | unsigned short |
| 1972 | pixel; |
| 1973 | |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 1974 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 1975 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1976 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 1977 | { |
| 1978 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1979 | q->red=ClampToQuantum((MagickRealType) QuantumRange* |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 1980 | HalfToSinglePrecision(pixel)); |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 1981 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1982 | q->green=ClampToQuantum((MagickRealType) QuantumRange* |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 1983 | HalfToSinglePrecision(pixel)); |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 1984 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1985 | q->blue=ClampToQuantum((MagickRealType) QuantumRange* |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 1986 | HalfToSinglePrecision(pixel)); |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 1987 | p+=quantum_info->pad; |
| 1988 | q++; |
| 1989 | } |
| 1990 | break; |
| 1991 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1992 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1993 | { |
| 1994 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1995 | SetRedPixelComponent(q,ScaleShortToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1996 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1997 | SetGreenPixelComponent(q,ScaleShortToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1998 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 1999 | SetBluePixelComponent(q,ScaleShortToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2000 | p+=quantum_info->pad; |
| 2001 | q++; |
| 2002 | } |
| 2003 | break; |
| 2004 | } |
| 2005 | case 32: |
| 2006 | { |
cristy | 4cb162a | 2010-05-30 03:04:47 +0000 | [diff] [blame] | 2007 | unsigned int |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2008 | pixel; |
| 2009 | |
| 2010 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 2011 | { |
| 2012 | float |
| 2013 | pixel; |
| 2014 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2015 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2016 | { |
| 2017 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2018 | q->red=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2019 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2020 | q->green=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2021 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2022 | q->blue=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2023 | p+=quantum_info->pad; |
| 2024 | q++; |
| 2025 | } |
| 2026 | break; |
| 2027 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2028 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2029 | { |
| 2030 | p=PushLongPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2031 | SetRedPixelComponent(q,ScaleLongToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2032 | p=PushLongPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2033 | SetGreenPixelComponent(q,ScaleLongToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2034 | p=PushLongPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2035 | SetBluePixelComponent(q,ScaleLongToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2036 | p+=quantum_info->pad; |
| 2037 | q++; |
| 2038 | } |
| 2039 | break; |
| 2040 | } |
| 2041 | case 64: |
| 2042 | { |
| 2043 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 2044 | { |
| 2045 | double |
| 2046 | pixel; |
| 2047 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2048 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2049 | { |
| 2050 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2051 | q->red=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2052 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2053 | q->green=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2054 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2055 | q->blue=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2056 | p+=quantum_info->pad; |
| 2057 | q++; |
| 2058 | } |
| 2059 | break; |
| 2060 | } |
| 2061 | } |
| 2062 | default: |
| 2063 | { |
| 2064 | range=GetQuantumRange(image->depth); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2065 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2066 | { |
| 2067 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2068 | SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2069 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2070 | SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2071 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2072 | SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2073 | q++; |
| 2074 | } |
| 2075 | break; |
| 2076 | } |
| 2077 | } |
| 2078 | break; |
| 2079 | } |
| 2080 | case RGBAQuantum: |
| 2081 | case RGBOQuantum: |
| 2082 | case CbYCrAQuantum: |
| 2083 | { |
| 2084 | switch (quantum_info->depth) |
| 2085 | { |
| 2086 | case 8: |
| 2087 | { |
| 2088 | unsigned char |
| 2089 | pixel; |
| 2090 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2091 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2092 | { |
| 2093 | p=PushCharPixel(p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2094 | SetRedPixelComponent(q,ScaleCharToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2095 | p=PushCharPixel(p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2096 | SetGreenPixelComponent(q,ScaleCharToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2097 | p=PushCharPixel(p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2098 | SetBluePixelComponent(q,ScaleCharToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2099 | p=PushCharPixel(p,&pixel); |
| 2100 | q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel)); |
| 2101 | p+=quantum_info->pad; |
| 2102 | q++; |
| 2103 | } |
| 2104 | break; |
| 2105 | } |
| 2106 | case 10: |
| 2107 | { |
| 2108 | pixel=0; |
| 2109 | if (quantum_info->pack == MagickFalse) |
| 2110 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2111 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2112 | n; |
| 2113 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2114 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2115 | i; |
| 2116 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2117 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2118 | quantum; |
| 2119 | |
| 2120 | n=0; |
| 2121 | quantum=0; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2122 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2123 | { |
| 2124 | for (i=0; i < 4; i++) |
| 2125 | { |
| 2126 | switch (n % 3) |
| 2127 | { |
| 2128 | case 0: |
| 2129 | { |
| 2130 | p=PushLongPixel(endian,p,&pixel); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2131 | quantum=(size_t) (ScaleShortToQuantum( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2132 | (unsigned short) (((pixel >> 22) & 0x3ff) << 6))); |
| 2133 | break; |
| 2134 | } |
| 2135 | case 1: |
| 2136 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2137 | quantum=(size_t) (ScaleShortToQuantum( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2138 | (unsigned short) (((pixel >> 12) & 0x3ff) << 6))); |
| 2139 | break; |
| 2140 | } |
| 2141 | case 2: |
| 2142 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2143 | quantum=(size_t) (ScaleShortToQuantum( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2144 | (unsigned short) (((pixel >> 2) & 0x3ff) << 6))); |
| 2145 | break; |
| 2146 | } |
| 2147 | } |
| 2148 | switch (i) |
| 2149 | { |
| 2150 | case 0: q->red=(Quantum) (quantum); break; |
| 2151 | case 1: q->green=(Quantum) (quantum); break; |
| 2152 | case 2: q->blue=(Quantum) (quantum); break; |
| 2153 | case 3: q->opacity=(Quantum) (QuantumRange-quantum); break; |
| 2154 | } |
| 2155 | n++; |
| 2156 | } |
| 2157 | p+=quantum_info->pad; |
| 2158 | q++; |
| 2159 | } |
| 2160 | break; |
| 2161 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2162 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2163 | { |
| 2164 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
| 2165 | q->red=ScaleShortToQuantum((unsigned short) (pixel << 6)); |
| 2166 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
| 2167 | q->green=ScaleShortToQuantum((unsigned short) (pixel << 6)); |
| 2168 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
| 2169 | q->blue=ScaleShortToQuantum((unsigned short) (pixel << 6)); |
| 2170 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
| 2171 | q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum( |
| 2172 | (unsigned short) (pixel << 6))); |
| 2173 | q++; |
| 2174 | } |
| 2175 | break; |
| 2176 | } |
| 2177 | case 16: |
| 2178 | { |
| 2179 | unsigned short |
| 2180 | pixel; |
| 2181 | |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 2182 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 2183 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2184 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 2185 | { |
| 2186 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2187 | q->red=ClampToQuantum((MagickRealType) QuantumRange* |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 2188 | HalfToSinglePrecision(pixel)); |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 2189 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2190 | q->green=ClampToQuantum((MagickRealType) QuantumRange* |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 2191 | HalfToSinglePrecision(pixel)); |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 2192 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2193 | q->blue=ClampToQuantum((MagickRealType) QuantumRange* |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 2194 | HalfToSinglePrecision(pixel)); |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 2195 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2196 | q->opacity=(Quantum) (QuantumRange-ClampToQuantum( |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 2197 | (MagickRealType) QuantumRange*HalfToSinglePrecision(pixel))); |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 2198 | p+=quantum_info->pad; |
| 2199 | q++; |
| 2200 | } |
| 2201 | break; |
| 2202 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2203 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2204 | { |
| 2205 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2206 | SetRedPixelComponent(q,ScaleShortToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2207 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2208 | SetGreenPixelComponent(q,ScaleShortToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2209 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2210 | SetBluePixelComponent(q,ScaleShortToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2211 | p=PushShortPixel(endian,p,&pixel); |
| 2212 | q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel)); |
| 2213 | p+=quantum_info->pad; |
| 2214 | q++; |
| 2215 | } |
| 2216 | break; |
| 2217 | } |
| 2218 | case 32: |
| 2219 | { |
cristy | 4cb162a | 2010-05-30 03:04:47 +0000 | [diff] [blame] | 2220 | unsigned int |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2221 | pixel; |
| 2222 | |
| 2223 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 2224 | { |
| 2225 | float |
| 2226 | pixel; |
| 2227 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2228 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2229 | { |
| 2230 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2231 | q->red=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2232 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2233 | q->green=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2234 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2235 | q->blue=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2236 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2237 | q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2238 | p+=quantum_info->pad; |
| 2239 | q++; |
| 2240 | } |
| 2241 | break; |
| 2242 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2243 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2244 | { |
| 2245 | p=PushLongPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2246 | SetRedPixelComponent(q,ScaleLongToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2247 | p=PushLongPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2248 | SetGreenPixelComponent(q,ScaleLongToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2249 | p=PushLongPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2250 | SetBluePixelComponent(q,ScaleLongToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2251 | p=PushLongPixel(endian,p,&pixel); |
| 2252 | q->opacity=(Quantum) (QuantumRange-ScaleLongToQuantum(pixel)); |
| 2253 | p+=quantum_info->pad; |
| 2254 | q++; |
| 2255 | } |
| 2256 | break; |
| 2257 | } |
| 2258 | case 64: |
| 2259 | { |
| 2260 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 2261 | { |
| 2262 | double |
| 2263 | pixel; |
| 2264 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2265 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2266 | { |
| 2267 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2268 | q->red=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2269 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2270 | q->green=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2271 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2272 | q->blue=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2273 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2274 | q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2275 | p+=quantum_info->pad; |
| 2276 | q++; |
| 2277 | } |
| 2278 | break; |
| 2279 | } |
| 2280 | } |
| 2281 | default: |
| 2282 | { |
| 2283 | range=GetQuantumRange(image->depth); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2284 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2285 | { |
| 2286 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2287 | SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2288 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2289 | SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2290 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2291 | SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2292 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
| 2293 | q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range)); |
| 2294 | q++; |
| 2295 | } |
| 2296 | break; |
| 2297 | } |
| 2298 | } |
| 2299 | break; |
| 2300 | } |
| 2301 | case CMYKQuantum: |
| 2302 | { |
| 2303 | if (image->colorspace != CMYKColorspace) |
| 2304 | { |
| 2305 | (void) ThrowMagickException(exception,GetMagickModule(),ImageError, |
| 2306 | "ColorSeparatedImageRequired","`%s'",image->filename); |
| 2307 | return(extent); |
| 2308 | } |
| 2309 | switch (quantum_info->depth) |
| 2310 | { |
| 2311 | case 8: |
| 2312 | { |
| 2313 | unsigned char |
| 2314 | pixel; |
| 2315 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2316 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2317 | { |
| 2318 | p=PushCharPixel(p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2319 | SetRedPixelComponent(q,ScaleCharToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2320 | p=PushCharPixel(p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2321 | SetGreenPixelComponent(q,ScaleCharToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2322 | p=PushCharPixel(p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2323 | SetBluePixelComponent(q,ScaleCharToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2324 | p=PushCharPixel(p,&pixel); |
| 2325 | indexes[x]=ScaleCharToQuantum(pixel); |
| 2326 | p+=quantum_info->pad; |
| 2327 | q++; |
| 2328 | } |
| 2329 | break; |
| 2330 | } |
| 2331 | case 16: |
| 2332 | { |
| 2333 | unsigned short |
| 2334 | pixel; |
| 2335 | |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 2336 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 2337 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2338 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 2339 | { |
| 2340 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2341 | q->red=ClampToQuantum((MagickRealType) QuantumRange* |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 2342 | HalfToSinglePrecision(pixel)); |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 2343 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2344 | q->green=ClampToQuantum((MagickRealType) QuantumRange* |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 2345 | HalfToSinglePrecision(pixel)); |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 2346 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2347 | q->blue=ClampToQuantum((MagickRealType) QuantumRange* |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 2348 | HalfToSinglePrecision(pixel)); |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 2349 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2350 | indexes[x]=ClampToQuantum((MagickRealType) QuantumRange* |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 2351 | HalfToSinglePrecision(pixel)); |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 2352 | p+=quantum_info->pad; |
| 2353 | q++; |
| 2354 | } |
| 2355 | break; |
| 2356 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2357 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2358 | { |
| 2359 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2360 | SetRedPixelComponent(q,ScaleShortToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2361 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2362 | SetGreenPixelComponent(q,ScaleShortToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2363 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2364 | SetBluePixelComponent(q,ScaleShortToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2365 | p=PushShortPixel(endian,p,&pixel); |
| 2366 | indexes[x]=ScaleShortToQuantum(pixel); |
| 2367 | p+=quantum_info->pad; |
| 2368 | q++; |
| 2369 | } |
| 2370 | break; |
| 2371 | } |
| 2372 | case 32: |
| 2373 | { |
cristy | 4cb162a | 2010-05-30 03:04:47 +0000 | [diff] [blame] | 2374 | unsigned int |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2375 | pixel; |
| 2376 | |
| 2377 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 2378 | { |
| 2379 | float |
| 2380 | pixel; |
| 2381 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2382 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2383 | { |
| 2384 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2385 | q->red=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2386 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2387 | q->green=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2388 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2389 | q->blue=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2390 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2391 | indexes[x]=(IndexPacket) ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2392 | p+=quantum_info->pad; |
| 2393 | q++; |
| 2394 | } |
| 2395 | break; |
| 2396 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2397 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2398 | { |
| 2399 | p=PushLongPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2400 | SetRedPixelComponent(q,ScaleLongToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2401 | p=PushLongPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2402 | SetGreenPixelComponent(q,ScaleLongToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2403 | p=PushLongPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2404 | SetBluePixelComponent(q,ScaleLongToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2405 | p=PushLongPixel(endian,p,&pixel); |
| 2406 | indexes[x]=ScaleLongToQuantum(pixel); |
| 2407 | p+=quantum_info->pad; |
| 2408 | q++; |
| 2409 | } |
| 2410 | break; |
| 2411 | } |
| 2412 | case 64: |
| 2413 | { |
| 2414 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 2415 | { |
| 2416 | double |
| 2417 | pixel; |
| 2418 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2419 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2420 | { |
| 2421 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2422 | q->red=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2423 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2424 | q->green=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2425 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2426 | q->blue=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2427 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2428 | indexes[x]=(IndexPacket) ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2429 | p+=quantum_info->pad; |
| 2430 | q++; |
| 2431 | } |
| 2432 | break; |
| 2433 | } |
| 2434 | } |
| 2435 | default: |
| 2436 | { |
| 2437 | range=GetQuantumRange(image->depth); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2438 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2439 | { |
| 2440 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2441 | SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2442 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2443 | SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2444 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2445 | SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2446 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
| 2447 | indexes[x]=ScaleAnyToQuantum(pixel,range); |
| 2448 | q++; |
| 2449 | } |
| 2450 | break; |
| 2451 | } |
| 2452 | } |
| 2453 | break; |
| 2454 | } |
| 2455 | case CMYKAQuantum: |
| 2456 | case CMYKOQuantum: |
| 2457 | { |
| 2458 | if (image->colorspace != CMYKColorspace) |
| 2459 | { |
| 2460 | (void) ThrowMagickException(exception,GetMagickModule(),ImageError, |
| 2461 | "ColorSeparatedImageRequired","`%s'",image->filename); |
| 2462 | return(extent); |
| 2463 | } |
| 2464 | switch (quantum_info->depth) |
| 2465 | { |
| 2466 | case 8: |
| 2467 | { |
| 2468 | unsigned char |
| 2469 | pixel; |
| 2470 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2471 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2472 | { |
| 2473 | p=PushCharPixel(p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2474 | SetRedPixelComponent(q,ScaleCharToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2475 | p=PushCharPixel(p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2476 | SetGreenPixelComponent(q,ScaleCharToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2477 | p=PushCharPixel(p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2478 | SetBluePixelComponent(q,ScaleCharToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2479 | p=PushCharPixel(p,&pixel); |
| 2480 | indexes[x]=ScaleCharToQuantum(pixel); |
| 2481 | p=PushCharPixel(p,&pixel); |
| 2482 | q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel)); |
| 2483 | p+=quantum_info->pad; |
| 2484 | q++; |
| 2485 | } |
| 2486 | break; |
| 2487 | } |
| 2488 | case 16: |
| 2489 | { |
| 2490 | unsigned short |
| 2491 | pixel; |
| 2492 | |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 2493 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 2494 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2495 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 2496 | { |
| 2497 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2498 | q->red=ClampToQuantum((MagickRealType) QuantumRange* |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 2499 | HalfToSinglePrecision(pixel)); |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 2500 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2501 | q->green=ClampToQuantum((MagickRealType) QuantumRange* |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 2502 | HalfToSinglePrecision(pixel)); |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 2503 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2504 | q->blue=ClampToQuantum((MagickRealType) QuantumRange* |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 2505 | HalfToSinglePrecision(pixel)); |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 2506 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2507 | indexes[x]=ClampToQuantum((MagickRealType) QuantumRange* |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 2508 | HalfToSinglePrecision(pixel)); |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 2509 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2510 | q->opacity=(Quantum) (QuantumRange-ClampToQuantum( |
cristy | 2a4d01c | 2010-01-10 21:14:51 +0000 | [diff] [blame] | 2511 | (MagickRealType) QuantumRange*HalfToSinglePrecision(pixel))); |
cristy | c9672a9 | 2010-01-06 00:57:45 +0000 | [diff] [blame] | 2512 | p+=quantum_info->pad; |
| 2513 | q++; |
| 2514 | } |
| 2515 | break; |
| 2516 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2517 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2518 | { |
| 2519 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2520 | SetRedPixelComponent(q,ScaleShortToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2521 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2522 | SetGreenPixelComponent(q,ScaleShortToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2523 | p=PushShortPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2524 | SetBluePixelComponent(q,ScaleShortToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2525 | p=PushShortPixel(endian,p,&pixel); |
| 2526 | indexes[x]=ScaleShortToQuantum(pixel); |
| 2527 | p=PushShortPixel(endian,p,&pixel); |
| 2528 | q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel)); |
| 2529 | p+=quantum_info->pad; |
| 2530 | q++; |
| 2531 | } |
| 2532 | break; |
| 2533 | } |
| 2534 | case 32: |
| 2535 | { |
cristy | 4cb162a | 2010-05-30 03:04:47 +0000 | [diff] [blame] | 2536 | unsigned int |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2537 | pixel; |
| 2538 | |
| 2539 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 2540 | { |
| 2541 | float |
| 2542 | pixel; |
| 2543 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2544 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2545 | { |
| 2546 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2547 | q->red=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2548 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2549 | q->green=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2550 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2551 | q->blue=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2552 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2553 | indexes[x]=(IndexPacket) ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2554 | p=PushFloatPixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2555 | q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2556 | p+=quantum_info->pad; |
| 2557 | q++; |
| 2558 | } |
| 2559 | break; |
| 2560 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2561 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2562 | { |
| 2563 | p=PushLongPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2564 | SetRedPixelComponent(q,ScaleLongToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2565 | p=PushLongPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2566 | SetGreenPixelComponent(q,ScaleLongToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2567 | p=PushLongPixel(endian,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2568 | SetBluePixelComponent(q,ScaleLongToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2569 | p=PushLongPixel(endian,p,&pixel); |
| 2570 | indexes[x]=ScaleLongToQuantum(pixel); |
| 2571 | p=PushLongPixel(endian,p,&pixel); |
| 2572 | q->opacity=(Quantum) (QuantumRange-ScaleLongToQuantum(pixel)); |
| 2573 | p+=quantum_info->pad; |
| 2574 | q++; |
| 2575 | } |
| 2576 | break; |
| 2577 | } |
| 2578 | case 64: |
| 2579 | { |
| 2580 | if (quantum_info->format == FloatingPointQuantumFormat) |
| 2581 | { |
| 2582 | double |
| 2583 | pixel; |
| 2584 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2585 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2586 | { |
| 2587 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2588 | q->red=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2589 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2590 | q->green=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2591 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2592 | q->blue=ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2593 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2594 | indexes[x]=(IndexPacket) ClampToQuantum(pixel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2595 | p=PushDoublePixel(&quantum_state,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2596 | q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2597 | p=PushDoublePixel(&quantum_state,p,&pixel); |
| 2598 | p+=quantum_info->pad; |
| 2599 | q++; |
| 2600 | } |
| 2601 | break; |
| 2602 | } |
| 2603 | } |
| 2604 | default: |
| 2605 | { |
| 2606 | range=GetQuantumRange(image->depth); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2607 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2608 | { |
| 2609 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2610 | SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2611 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2612 | SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2613 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2614 | SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2615 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
| 2616 | indexes[x]=ScaleAnyToQuantum(pixel,range); |
| 2617 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
| 2618 | q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range)); |
| 2619 | q++; |
| 2620 | } |
| 2621 | break; |
| 2622 | } |
| 2623 | } |
| 2624 | break; |
| 2625 | } |
| 2626 | case CbYCrYQuantum: |
| 2627 | { |
| 2628 | switch (quantum_info->depth) |
| 2629 | { |
| 2630 | case 10: |
| 2631 | { |
| 2632 | Quantum |
| 2633 | cbcr[4]; |
| 2634 | |
| 2635 | pixel=0; |
| 2636 | if (quantum_info->pack == MagickFalse) |
| 2637 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2638 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2639 | n; |
| 2640 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2641 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2642 | i; |
| 2643 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2644 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2645 | quantum; |
| 2646 | |
| 2647 | n=0; |
| 2648 | quantum=0; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2649 | for (x=0; x < (ssize_t) number_pixels; x+=2) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2650 | { |
| 2651 | for (i=0; i < 4; i++) |
| 2652 | { |
| 2653 | switch (n % 3) |
| 2654 | { |
| 2655 | case 0: |
| 2656 | { |
| 2657 | p=PushLongPixel(endian,p,&pixel); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2658 | quantum=(size_t) (ScaleShortToQuantum( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2659 | (unsigned short) (((pixel >> 22) & 0x3ff) << 6))); |
| 2660 | break; |
| 2661 | } |
| 2662 | case 1: |
| 2663 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2664 | quantum=(size_t) (ScaleShortToQuantum( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2665 | (unsigned short) (((pixel >> 12) & 0x3ff) << 6))); |
| 2666 | break; |
| 2667 | } |
| 2668 | case 2: |
| 2669 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2670 | quantum=(size_t) (ScaleShortToQuantum( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2671 | (unsigned short) (((pixel >> 2) & 0x3ff) << 6))); |
| 2672 | break; |
| 2673 | } |
| 2674 | } |
| 2675 | cbcr[i]=(Quantum) (quantum); |
| 2676 | n++; |
| 2677 | } |
| 2678 | p+=quantum_info->pad; |
| 2679 | q->red=cbcr[1]; |
| 2680 | q->green=cbcr[0]; |
| 2681 | q->blue=cbcr[2]; |
| 2682 | q++; |
| 2683 | q->red=cbcr[3]; |
| 2684 | q->green=cbcr[0]; |
| 2685 | q->blue=cbcr[2]; |
| 2686 | q++; |
| 2687 | } |
| 2688 | break; |
| 2689 | } |
| 2690 | } |
| 2691 | default: |
| 2692 | { |
| 2693 | range=GetQuantumRange(image->depth); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2694 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2695 | { |
| 2696 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2697 | SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2698 | p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2699 | SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2700 | q++; |
| 2701 | } |
| 2702 | break; |
| 2703 | } |
| 2704 | } |
| 2705 | break; |
| 2706 | } |
| 2707 | default: |
| 2708 | break; |
| 2709 | } |
| 2710 | if ((quantum_type == CbYCrQuantum) || (quantum_type == CbYCrAQuantum)) |
| 2711 | { |
| 2712 | Quantum |
| 2713 | quantum; |
| 2714 | |
| 2715 | register PixelPacket |
cristy | c47d1f8 | 2009-11-26 01:44:43 +0000 | [diff] [blame] | 2716 | *restrict q; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2717 | |
| 2718 | q=GetAuthenticPixelQueue(image); |
| 2719 | if (image_view != (CacheView *) NULL) |
| 2720 | q=GetCacheViewAuthenticPixelQueue(image_view); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2721 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2722 | { |
| 2723 | quantum=q->red; |
| 2724 | q->red=q->green; |
| 2725 | q->green=quantum; |
| 2726 | q++; |
| 2727 | } |
| 2728 | } |
| 2729 | if ((quantum_type == RGBOQuantum) || (quantum_type == CMYKOQuantum)) |
| 2730 | { |
| 2731 | register PixelPacket |
cristy | c47d1f8 | 2009-11-26 01:44:43 +0000 | [diff] [blame] | 2732 | *restrict q; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2733 | |
| 2734 | q=GetAuthenticPixelQueue(image); |
| 2735 | if (image_view != (CacheView *) NULL) |
| 2736 | q=GetCacheViewAuthenticPixelQueue(image_view); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2737 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2738 | { |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 2739 | q->opacity=(Quantum) GetAlphaPixelComponent(q); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2740 | q++; |
| 2741 | } |
| 2742 | } |
| 2743 | if (quantum_info->alpha_type == DisassociatedQuantumAlpha) |
| 2744 | { |
| 2745 | MagickRealType |
| 2746 | alpha; |
| 2747 | |
| 2748 | register PixelPacket |
cristy | c47d1f8 | 2009-11-26 01:44:43 +0000 | [diff] [blame] | 2749 | *restrict q; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2750 | |
| 2751 | /* |
| 2752 | Disassociate alpha. |
| 2753 | */ |
| 2754 | q=GetAuthenticPixelQueue(image); |
| 2755 | if (image_view != (CacheView *) NULL) |
| 2756 | q=GetCacheViewAuthenticPixelQueue(image_view); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2757 | for (x=0; x < (ssize_t) number_pixels; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2758 | { |
| 2759 | alpha=QuantumScale*((MagickRealType) QuantumRange-q->opacity); |
| 2760 | alpha=1.0/(fabs(alpha) <= MagickEpsilon ? 1.0 : alpha); |
cristy | ce70c17 | 2010-01-07 17:15:30 +0000 | [diff] [blame] | 2761 | q->red=ClampToQuantum(alpha*q->red); |
| 2762 | q->green=ClampToQuantum(alpha*q->green); |
| 2763 | q->blue=ClampToQuantum(alpha*q->blue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2764 | q++; |
| 2765 | } |
| 2766 | } |
| 2767 | return(extent); |
| 2768 | } |