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