|
MagickCore
6.7.5
|
00001 /* 00002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00003 % % 00004 % % 00005 % % 00006 % QQQ U U AAA N N TTTTT U U M M % 00007 % Q Q U U A A NN N T U U MM MM % 00008 % Q Q U U AAAAA N N N T U U M M M % 00009 % Q QQ U U A A N NN T U U M M % 00010 % QQQQ UUU A A N N T UUU M M % 00011 % % 00012 % EEEEE X X PPPP OOO RRRR TTTTT % 00013 % E X X P P O O R R T % 00014 % EEE X PPPP O O RRRR T % 00015 % E X X P O O R R T % 00016 % EEEEE X X P OOO R R T % 00017 % % 00018 % MagickCore Methods to Export Quantum Pixels % 00019 % % 00020 % Software Design % 00021 % John Cristy % 00022 % October 1998 % 00023 % % 00024 % % 00025 % Copyright 1999-2008 ImageMagick Studio LLC, a non-profit organization % 00026 % dedicated to making software imaging solutions freely available. % 00027 % % 00028 % You may not use this file except in compliance with the License. You may % 00029 % obtain a copy of the License at % 00030 % % 00031 % http://www.imagemagick.org/script/license.php % 00032 % % 00033 % Unless required by applicable law or agreed to in writing, software % 00034 % distributed under the License is distributed on an "AS IS" BASIS, % 00035 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % 00036 % See the License for the specific language governing permissions and % 00037 % limitations under the License. % 00038 % % 00039 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00040 % 00041 % 00042 */ 00043 00044 /* 00045 Include declarations. 00046 */ 00047 #include "MagickCore/studio.h" 00048 #include "MagickCore/property.h" 00049 #include "MagickCore/blob.h" 00050 #include "MagickCore/blob-private.h" 00051 #include "MagickCore/color-private.h" 00052 #include "MagickCore/exception.h" 00053 #include "MagickCore/exception-private.h" 00054 #include "MagickCore/cache.h" 00055 #include "MagickCore/constitute.h" 00056 #include "MagickCore/delegate.h" 00057 #include "MagickCore/geometry.h" 00058 #include "MagickCore/list.h" 00059 #include "MagickCore/magick.h" 00060 #include "MagickCore/memory_.h" 00061 #include "MagickCore/monitor.h" 00062 #include "MagickCore/option.h" 00063 #include "MagickCore/pixel.h" 00064 #include "MagickCore/pixel-accessor.h" 00065 #include "MagickCore/quantum.h" 00066 #include "MagickCore/quantum-private.h" 00067 #include "MagickCore/resource_.h" 00068 #include "MagickCore/semaphore.h" 00069 #include "MagickCore/statistic.h" 00070 #include "MagickCore/stream.h" 00071 #include "MagickCore/string_.h" 00072 #include "MagickCore/utility.h" 00073 00074 /* 00075 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00076 % % 00077 % % 00078 % % 00079 + E x p o r t Q u a n t u m P i x e l s % 00080 % % 00081 % % 00082 % % 00083 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00084 % 00085 % ExportQuantumPixels() transfers one or more pixel components from the image 00086 % pixel cache to a user supplied buffer. The pixels are returned in network 00087 % byte order. MagickTrue is returned if the pixels are successfully 00088 % transferred, otherwise MagickFalse. 00089 % 00090 % The format of the ExportQuantumPixels method is: 00091 % 00092 % size_t ExportQuantumPixels(const Image *image,CacheView *image_view, 00093 % QuantumInfo *quantum_info,const QuantumType quantum_type, 00094 % unsigned char *pixels,ExceptionInfo *exception) 00095 % 00096 % A description of each parameter follows: 00097 % 00098 % o image: the image. 00099 % 00100 % o image_view: the image cache view. 00101 % 00102 % o quantum_info: the quantum info. 00103 % 00104 % o quantum_type: Declare which pixel components to transfer (RGB, RGBA, 00105 % etc). 00106 % 00107 % o pixels: The components are transferred to this buffer. 00108 % 00109 % o exception: return any errors or warnings in this structure. 00110 % 00111 */ 00112 00113 static inline unsigned char *PopDoublePixel(QuantumInfo *quantum_info, 00114 const double pixel,unsigned char *pixels) 00115 { 00116 double 00117 *p; 00118 00119 unsigned char 00120 quantum[8]; 00121 00122 p=(double *) quantum; 00123 *p=(double) (pixel*quantum_info->state.inverse_scale+quantum_info->minimum); 00124 if (quantum_info->endian != LSBEndian) 00125 { 00126 *pixels++=quantum[7]; 00127 *pixels++=quantum[6]; 00128 *pixels++=quantum[5]; 00129 *pixels++=quantum[4]; 00130 *pixels++=quantum[3]; 00131 *pixels++=quantum[2]; 00132 *pixels++=quantum[1]; 00133 *pixels++=quantum[0]; 00134 return(pixels); 00135 } 00136 *pixels++=quantum[0]; 00137 *pixels++=quantum[1]; 00138 *pixels++=quantum[2]; 00139 *pixels++=quantum[3]; 00140 *pixels++=quantum[4]; 00141 *pixels++=quantum[5]; 00142 *pixels++=quantum[6]; 00143 *pixels++=quantum[7]; 00144 return(pixels); 00145 } 00146 00147 static inline unsigned char *PopFloatPixel(QuantumInfo *quantum_info, 00148 const float pixel,unsigned char *pixels) 00149 { 00150 float 00151 *p; 00152 00153 unsigned char 00154 quantum[4]; 00155 00156 p=(float *) quantum; 00157 *p=(float) ((double) pixel*quantum_info->state.inverse_scale+ 00158 quantum_info->minimum); 00159 if (quantum_info->endian != LSBEndian) 00160 { 00161 *pixels++=quantum[3]; 00162 *pixels++=quantum[2]; 00163 *pixels++=quantum[1]; 00164 *pixels++=quantum[0]; 00165 return(pixels); 00166 } 00167 *pixels++=quantum[0]; 00168 *pixels++=quantum[1]; 00169 *pixels++=quantum[2]; 00170 *pixels++=quantum[3]; 00171 return(pixels); 00172 } 00173 00174 static inline unsigned char *PopQuantumPixel(QuantumInfo *quantum_info, 00175 const QuantumAny pixel,unsigned char *pixels) 00176 { 00177 register ssize_t 00178 i; 00179 00180 size_t 00181 quantum_bits; 00182 00183 if (quantum_info->state.bits == 0UL) 00184 quantum_info->state.bits=8U; 00185 for (i=(ssize_t) quantum_info->depth; i > 0L; ) 00186 { 00187 quantum_bits=(size_t) i; 00188 if (quantum_bits > quantum_info->state.bits) 00189 quantum_bits=quantum_info->state.bits; 00190 i-=(ssize_t) quantum_bits; 00191 if (quantum_info->state.bits == 8UL) 00192 *pixels='\0'; 00193 quantum_info->state.bits-=quantum_bits; 00194 *pixels|=(((pixel >> i) &~ ((~0UL) << quantum_bits)) << 00195 quantum_info->state.bits); 00196 if (quantum_info->state.bits == 0UL) 00197 { 00198 pixels++; 00199 quantum_info->state.bits=8UL; 00200 } 00201 } 00202 return(pixels); 00203 } 00204 00205 static inline unsigned char *PopQuantumLongPixel(QuantumInfo *quantum_info, 00206 const size_t pixel,unsigned char *pixels) 00207 { 00208 register ssize_t 00209 i; 00210 00211 size_t 00212 quantum_bits; 00213 00214 if (quantum_info->state.bits == 0U) 00215 quantum_info->state.bits=32UL; 00216 for (i=(ssize_t) quantum_info->depth; i > 0; ) 00217 { 00218 quantum_bits=(size_t) i; 00219 if (quantum_bits > quantum_info->state.bits) 00220 quantum_bits=quantum_info->state.bits; 00221 quantum_info->state.pixel|=(((pixel >> (quantum_info->depth-i)) & 00222 quantum_info->state.mask[quantum_bits]) << (32U- 00223 quantum_info->state.bits)); 00224 i-=(ssize_t) quantum_bits; 00225 quantum_info->state.bits-=quantum_bits; 00226 if (quantum_info->state.bits == 0U) 00227 { 00228 pixels=PopLongPixel(quantum_info->endian,quantum_info->state.pixel, 00229 pixels); 00230 quantum_info->state.pixel=0U; 00231 quantum_info->state.bits=32U; 00232 } 00233 } 00234 return(pixels); 00235 } 00236 00237 static void ExportAlphaQuantum(const Image *image,QuantumInfo *quantum_info, 00238 const MagickSizeType number_pixels,const Quantum *restrict p, 00239 unsigned char *restrict q,ExceptionInfo *exception) 00240 { 00241 QuantumAny 00242 range; 00243 00244 register ssize_t 00245 x; 00246 00247 switch (quantum_info->depth) 00248 { 00249 case 8: 00250 { 00251 register unsigned char 00252 pixel; 00253 00254 for (x=0; x < (ssize_t) number_pixels; x++) 00255 { 00256 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p)); 00257 q=PopCharPixel(pixel,q); 00258 p+=GetPixelChannels(image); 00259 q+=quantum_info->pad; 00260 } 00261 break; 00262 } 00263 case 16: 00264 { 00265 register unsigned short 00266 pixel; 00267 00268 if (quantum_info->format == FloatingPointQuantumFormat) 00269 { 00270 for (x=0; x < (ssize_t) number_pixels; x++) 00271 { 00272 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelAlpha(image,p)); 00273 q=PopShortPixel(quantum_info->endian,pixel,q); 00274 p+=GetPixelChannels(image); 00275 q+=quantum_info->pad; 00276 } 00277 break; 00278 } 00279 for (x=0; x < (ssize_t) number_pixels; x++) 00280 { 00281 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p)); 00282 q=PopShortPixel(quantum_info->endian,pixel,q); 00283 p+=GetPixelChannels(image); 00284 q+=quantum_info->pad; 00285 } 00286 break; 00287 } 00288 case 32: 00289 { 00290 register unsigned int 00291 pixel; 00292 00293 if (quantum_info->format == FloatingPointQuantumFormat) 00294 { 00295 for (x=0; x < (ssize_t) number_pixels; x++) 00296 { 00297 q=PopFloatPixel(quantum_info,(float) GetPixelAlpha(image,p),q); 00298 p+=GetPixelChannels(image); 00299 q+=quantum_info->pad; 00300 } 00301 break; 00302 } 00303 for (x=0; x < (ssize_t) number_pixels; x++) 00304 { 00305 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p)); 00306 q=PopLongPixel(quantum_info->endian,pixel,q); 00307 p+=GetPixelChannels(image); 00308 q+=quantum_info->pad; 00309 } 00310 break; 00311 } 00312 case 64: 00313 { 00314 if (quantum_info->format == FloatingPointQuantumFormat) 00315 { 00316 for (x=0; x < (ssize_t) number_pixels; x++) 00317 { 00318 q=PopDoublePixel(quantum_info,(double) GetPixelAlpha(image,p),q); 00319 p+=GetPixelChannels(image); 00320 q+=quantum_info->pad; 00321 } 00322 break; 00323 } 00324 } 00325 default: 00326 { 00327 range=GetQuantumRange(quantum_info->depth); 00328 for (x=0; x < (ssize_t) number_pixels; x++) 00329 { 00330 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p), 00331 range),q); 00332 p+=GetPixelChannels(image); 00333 q+=quantum_info->pad; 00334 } 00335 break; 00336 } 00337 } 00338 } 00339 00340 static void ExportBGRQuantum(const Image *image,QuantumInfo *quantum_info, 00341 const MagickSizeType number_pixels,const Quantum *restrict p, 00342 unsigned char *restrict q,ExceptionInfo *exception) 00343 { 00344 QuantumAny 00345 range; 00346 00347 register ssize_t 00348 x; 00349 00350 ssize_t 00351 bit; 00352 00353 switch (quantum_info->depth) 00354 { 00355 case 8: 00356 { 00357 for (x=0; x < (ssize_t) number_pixels; x++) 00358 { 00359 q=PopCharPixel(ScaleQuantumToChar(GetPixelBlue(image,p)),q); 00360 q=PopCharPixel(ScaleQuantumToChar(GetPixelGreen(image,p)),q); 00361 q=PopCharPixel(ScaleQuantumToChar(GetPixelRed(image,p)),q); 00362 p+=GetPixelChannels(image); 00363 q+=quantum_info->pad; 00364 } 00365 break; 00366 } 00367 case 10: 00368 { 00369 register unsigned int 00370 pixel; 00371 00372 range=GetQuantumRange(quantum_info->depth); 00373 if (quantum_info->pack == MagickFalse) 00374 { 00375 for (x=0; x < (ssize_t) number_pixels; x++) 00376 { 00377 pixel=(unsigned int) ( 00378 ScaleQuantumToAny(GetPixelRed(image,p),range) << 22 | 00379 ScaleQuantumToAny(GetPixelGreen(image,p),range) << 12 | 00380 ScaleQuantumToAny(GetPixelBlue(image,p),range) << 2); 00381 q=PopLongPixel(quantum_info->endian,pixel,q); 00382 p+=GetPixelChannels(image); 00383 q+=quantum_info->pad; 00384 } 00385 break; 00386 } 00387 if (quantum_info->quantum == 32UL) 00388 { 00389 for (x=0; x < (ssize_t) number_pixels; x++) 00390 { 00391 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); 00392 q=PopQuantumLongPixel(quantum_info,pixel,q); 00393 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), 00394 range); 00395 q=PopQuantumLongPixel(quantum_info,pixel,q); 00396 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); 00397 q=PopQuantumLongPixel(quantum_info,pixel,q); 00398 p+=GetPixelChannels(image); 00399 q+=quantum_info->pad; 00400 } 00401 break; 00402 } 00403 for (x=0; x < (ssize_t) number_pixels; x++) 00404 { 00405 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); 00406 q=PopQuantumPixel(quantum_info,pixel,q); 00407 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range); 00408 q=PopQuantumPixel(quantum_info,pixel,q); 00409 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); 00410 q=PopQuantumPixel(quantum_info,pixel,q); 00411 p+=GetPixelChannels(image); 00412 q+=quantum_info->pad; 00413 } 00414 break; 00415 } 00416 case 12: 00417 { 00418 register unsigned int 00419 pixel; 00420 00421 range=GetQuantumRange(quantum_info->depth); 00422 if (quantum_info->pack == MagickFalse) 00423 { 00424 for (x=0; x < (ssize_t) (3*number_pixels-1); x+=2) 00425 { 00426 switch (x % 3) 00427 { 00428 default: 00429 case 0: 00430 { 00431 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p), 00432 range); 00433 break; 00434 } 00435 case 1: 00436 { 00437 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), 00438 range); 00439 break; 00440 } 00441 case 2: 00442 { 00443 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p), 00444 range); 00445 p+=GetPixelChannels(image); 00446 break; 00447 } 00448 } 00449 q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel << 4), 00450 q); 00451 switch ((x+1) % 3) 00452 { 00453 default: 00454 case 0: 00455 { 00456 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p), 00457 range); 00458 break; 00459 } 00460 case 1: 00461 { 00462 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), 00463 range); 00464 break; 00465 } 00466 case 2: 00467 { 00468 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p), 00469 range); 00470 p+=GetPixelChannels(image); 00471 break; 00472 } 00473 } 00474 q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel << 4), 00475 q); 00476 q+=quantum_info->pad; 00477 } 00478 for (bit=0; bit < (ssize_t) (3*number_pixels % 2); bit++) 00479 { 00480 switch ((x+bit) % 3) 00481 { 00482 default: 00483 case 0: 00484 { 00485 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p), 00486 range); 00487 break; 00488 } 00489 case 1: 00490 { 00491 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), 00492 range); 00493 break; 00494 } 00495 case 2: 00496 { 00497 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p), 00498 range); 00499 p+=GetPixelChannels(image); 00500 break; 00501 } 00502 } 00503 q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel << 4), 00504 q); 00505 q+=quantum_info->pad; 00506 } 00507 if (bit != 0) 00508 p+=GetPixelChannels(image); 00509 break; 00510 } 00511 if (quantum_info->quantum == 32UL) 00512 { 00513 for (x=0; x < (ssize_t) number_pixels; x++) 00514 { 00515 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); 00516 q=PopQuantumLongPixel(quantum_info,pixel,q); 00517 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), 00518 range); 00519 q=PopQuantumLongPixel(quantum_info,pixel,q); 00520 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); 00521 q=PopQuantumLongPixel(quantum_info,pixel,q); 00522 p+=GetPixelChannels(image); 00523 q+=quantum_info->pad; 00524 } 00525 break; 00526 } 00527 for (x=0; x < (ssize_t) number_pixels; x++) 00528 { 00529 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); 00530 q=PopQuantumPixel(quantum_info,pixel,q); 00531 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range); 00532 q=PopQuantumPixel(quantum_info,pixel,q); 00533 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); 00534 q=PopQuantumPixel(quantum_info,pixel,q); 00535 p+=GetPixelChannels(image); 00536 q+=quantum_info->pad; 00537 } 00538 break; 00539 } 00540 case 16: 00541 { 00542 register unsigned short 00543 pixel; 00544 00545 if (quantum_info->format == FloatingPointQuantumFormat) 00546 { 00547 for (x=0; x < (ssize_t) number_pixels; x++) 00548 { 00549 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlue(image,p)); 00550 q=PopShortPixel(quantum_info->endian,pixel,q); 00551 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelGreen(image,p)); 00552 q=PopShortPixel(quantum_info->endian,pixel,q); 00553 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelRed(image,p)); 00554 q=PopShortPixel(quantum_info->endian,pixel,q); 00555 p+=GetPixelChannels(image); 00556 q+=quantum_info->pad; 00557 } 00558 break; 00559 } 00560 for (x=0; x < (ssize_t) number_pixels; x++) 00561 { 00562 pixel=ScaleQuantumToShort(GetPixelBlue(image,p)); 00563 q=PopShortPixel(quantum_info->endian,pixel,q); 00564 pixel=ScaleQuantumToShort(GetPixelGreen(image,p)); 00565 q=PopShortPixel(quantum_info->endian,pixel,q); 00566 pixel=ScaleQuantumToShort(GetPixelRed(image,p)); 00567 q=PopShortPixel(quantum_info->endian,pixel,q); 00568 p+=GetPixelChannels(image); 00569 q+=quantum_info->pad; 00570 } 00571 break; 00572 } 00573 case 32: 00574 { 00575 register unsigned int 00576 pixel; 00577 00578 if (quantum_info->format == FloatingPointQuantumFormat) 00579 { 00580 for (x=0; x < (ssize_t) number_pixels; x++) 00581 { 00582 q=PopFloatPixel(quantum_info,(float) GetPixelRed(image,p),q); 00583 q=PopFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q); 00584 q=PopFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q); 00585 p+=GetPixelChannels(image); 00586 q+=quantum_info->pad; 00587 } 00588 break; 00589 } 00590 for (x=0; x < (ssize_t) number_pixels; x++) 00591 { 00592 pixel=ScaleQuantumToLong(GetPixelBlue(image,p)); 00593 q=PopLongPixel(quantum_info->endian,pixel,q); 00594 pixel=ScaleQuantumToLong(GetPixelGreen(image,p)); 00595 q=PopLongPixel(quantum_info->endian,pixel,q); 00596 pixel=ScaleQuantumToLong(GetPixelRed(image,p)); 00597 q=PopLongPixel(quantum_info->endian,pixel,q); 00598 p+=GetPixelChannels(image); 00599 q+=quantum_info->pad; 00600 } 00601 break; 00602 } 00603 case 64: 00604 { 00605 if (quantum_info->format == FloatingPointQuantumFormat) 00606 { 00607 for (x=0; x < (ssize_t) number_pixels; x++) 00608 { 00609 q=PopDoublePixel(quantum_info,(double) GetPixelRed(image,p),q); 00610 q=PopDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q); 00611 q=PopDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q); 00612 p+=GetPixelChannels(image); 00613 q+=quantum_info->pad; 00614 } 00615 break; 00616 } 00617 } 00618 default: 00619 { 00620 range=GetQuantumRange(quantum_info->depth); 00621 for (x=0; x < (ssize_t) number_pixels; x++) 00622 { 00623 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p), 00624 range),q); 00625 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p), 00626 range),q); 00627 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p), 00628 range),q); 00629 p+=GetPixelChannels(image); 00630 q+=quantum_info->pad; 00631 } 00632 break; 00633 } 00634 } 00635 } 00636 00637 static void ExportBGRAQuantum(const Image *image,QuantumInfo *quantum_info, 00638 const MagickSizeType number_pixels,const Quantum *restrict p, 00639 unsigned char *restrict q,ExceptionInfo *exception) 00640 { 00641 QuantumAny 00642 range; 00643 00644 register ssize_t 00645 x; 00646 00647 switch (quantum_info->depth) 00648 { 00649 case 8: 00650 { 00651 register unsigned char 00652 pixel; 00653 00654 for (x=0; x < (ssize_t) number_pixels; x++) 00655 { 00656 pixel=ScaleQuantumToChar(GetPixelBlue(image,p)); 00657 q=PopCharPixel(pixel,q); 00658 pixel=ScaleQuantumToChar(GetPixelGreen(image,p)); 00659 q=PopCharPixel(pixel,q); 00660 pixel=ScaleQuantumToChar(GetPixelRed(image,p)); 00661 q=PopCharPixel(pixel,q); 00662 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p)); 00663 q=PopCharPixel(pixel,q); 00664 p+=GetPixelChannels(image); 00665 q+=quantum_info->pad; 00666 } 00667 break; 00668 } 00669 case 10: 00670 { 00671 register unsigned int 00672 pixel; 00673 00674 range=GetQuantumRange(quantum_info->depth); 00675 if (quantum_info->pack == MagickFalse) 00676 { 00677 register ssize_t 00678 i; 00679 00680 size_t 00681 quantum; 00682 00683 ssize_t 00684 n; 00685 00686 n=0; 00687 quantum=0; 00688 pixel=0; 00689 for (x=0; x < (ssize_t) number_pixels; x++) 00690 { 00691 for (i=0; i < 4; i++) 00692 { 00693 switch (i) 00694 { 00695 case 0: quantum=GetPixelRed(image,p); break; 00696 case 1: quantum=GetPixelGreen(image,p); break; 00697 case 2: quantum=GetPixelBlue(image,p); break; 00698 case 3: quantum=GetPixelAlpha(image,p); break; 00699 } 00700 switch (n % 3) 00701 { 00702 case 0: 00703 { 00704 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum, 00705 range) << 22); 00706 break; 00707 } 00708 case 1: 00709 { 00710 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum, 00711 range) << 12); 00712 break; 00713 } 00714 case 2: 00715 { 00716 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum, 00717 range) << 2); 00718 q=PopLongPixel(quantum_info->endian,pixel,q); 00719 pixel=0; 00720 break; 00721 } 00722 } 00723 n++; 00724 } 00725 p+=GetPixelChannels(image); 00726 q+=quantum_info->pad; 00727 } 00728 break; 00729 } 00730 if (quantum_info->quantum == 32UL) 00731 { 00732 for (x=0; x < (ssize_t) number_pixels; x++) 00733 { 00734 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); 00735 q=PopQuantumLongPixel(quantum_info,pixel,q); 00736 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), 00737 range); 00738 q=PopQuantumLongPixel(quantum_info,pixel,q); 00739 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); 00740 q=PopQuantumLongPixel(quantum_info,pixel,q); 00741 pixel=(unsigned int) ScaleQuantumToAny(GetPixelAlpha(image,p), 00742 range); 00743 q=PopQuantumLongPixel(quantum_info,pixel,q); 00744 p+=GetPixelChannels(image); 00745 q+=quantum_info->pad; 00746 } 00747 break; 00748 } 00749 for (x=0; x < (ssize_t) number_pixels; x++) 00750 { 00751 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); 00752 q=PopQuantumPixel(quantum_info,pixel,q); 00753 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range); 00754 q=PopQuantumPixel(quantum_info,pixel,q); 00755 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); 00756 q=PopQuantumPixel(quantum_info,pixel,q); 00757 pixel=(unsigned int) ScaleQuantumToAny(GetPixelAlpha(image,p),range); 00758 q=PopQuantumPixel(quantum_info,pixel,q); 00759 p+=GetPixelChannels(image); 00760 q+=quantum_info->pad; 00761 } 00762 break; 00763 } 00764 case 16: 00765 { 00766 register unsigned short 00767 pixel; 00768 00769 if (quantum_info->format == FloatingPointQuantumFormat) 00770 { 00771 for (x=0; x < (ssize_t) number_pixels; x++) 00772 { 00773 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlue(image,p)); 00774 q=PopShortPixel(quantum_info->endian,pixel,q); 00775 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelGreen(image,p)); 00776 q=PopShortPixel(quantum_info->endian,pixel,q); 00777 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelRed(image,p)); 00778 q=PopShortPixel(quantum_info->endian,pixel,q); 00779 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelAlpha(image,p)); 00780 q=PopShortPixel(quantum_info->endian,pixel,q); 00781 p+=GetPixelChannels(image); 00782 q+=quantum_info->pad; 00783 } 00784 break; 00785 } 00786 for (x=0; x < (ssize_t) number_pixels; x++) 00787 { 00788 pixel=ScaleQuantumToShort(GetPixelBlue(image,p)); 00789 q=PopShortPixel(quantum_info->endian,pixel,q); 00790 pixel=ScaleQuantumToShort(GetPixelGreen(image,p)); 00791 q=PopShortPixel(quantum_info->endian,pixel,q); 00792 pixel=ScaleQuantumToShort(GetPixelRed(image,p)); 00793 q=PopShortPixel(quantum_info->endian,pixel,q); 00794 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p)); 00795 q=PopShortPixel(quantum_info->endian,pixel,q); 00796 p+=GetPixelChannels(image); 00797 q+=quantum_info->pad; 00798 } 00799 break; 00800 } 00801 case 32: 00802 { 00803 register unsigned int 00804 pixel; 00805 00806 if (quantum_info->format == FloatingPointQuantumFormat) 00807 { 00808 for (x=0; x < (ssize_t) number_pixels; x++) 00809 { 00810 float 00811 pixel; 00812 00813 q=PopFloatPixel(quantum_info,(float) GetPixelRed(image,p),q); 00814 q=PopFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q); 00815 q=PopFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q); 00816 pixel=(float) GetPixelAlpha(image,p); 00817 q=PopFloatPixel(quantum_info,pixel,q); 00818 p+=GetPixelChannels(image); 00819 q+=quantum_info->pad; 00820 } 00821 break; 00822 } 00823 for (x=0; x < (ssize_t) number_pixels; x++) 00824 { 00825 pixel=ScaleQuantumToLong(GetPixelBlue(image,p)); 00826 q=PopLongPixel(quantum_info->endian,pixel,q); 00827 pixel=ScaleQuantumToLong(GetPixelGreen(image,p)); 00828 q=PopLongPixel(quantum_info->endian,pixel,q); 00829 pixel=ScaleQuantumToLong(GetPixelRed(image,p)); 00830 q=PopLongPixel(quantum_info->endian,pixel,q); 00831 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p)); 00832 q=PopLongPixel(quantum_info->endian,pixel,q); 00833 p+=GetPixelChannels(image); 00834 q+=quantum_info->pad; 00835 } 00836 break; 00837 } 00838 case 64: 00839 { 00840 if (quantum_info->format == FloatingPointQuantumFormat) 00841 { 00842 double 00843 pixel; 00844 00845 for (x=0; x < (ssize_t) number_pixels; x++) 00846 { 00847 q=PopDoublePixel(quantum_info,(double) GetPixelRed(image,p),q); 00848 q=PopDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q); 00849 q=PopDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q); 00850 pixel=(double) GetPixelAlpha(image,p); 00851 q=PopDoublePixel(quantum_info,pixel,q); 00852 p+=GetPixelChannels(image); 00853 q+=quantum_info->pad; 00854 } 00855 break; 00856 } 00857 } 00858 default: 00859 { 00860 range=GetQuantumRange(quantum_info->depth); 00861 for (x=0; x < (ssize_t) number_pixels; x++) 00862 { 00863 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p), 00864 range),q); 00865 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p), 00866 range),q); 00867 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p), 00868 range),q); 00869 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p), 00870 range),q); 00871 p+=GetPixelChannels(image); 00872 q+=quantum_info->pad; 00873 } 00874 break; 00875 } 00876 } 00877 } 00878 00879 static void ExportBlackQuantum(const Image *image,QuantumInfo *quantum_info, 00880 const MagickSizeType number_pixels,const Quantum *restrict p, 00881 unsigned char *restrict q,ExceptionInfo *exception) 00882 { 00883 QuantumAny 00884 range; 00885 00886 register ssize_t 00887 x; 00888 00889 if (image->colorspace != CMYKColorspace) 00890 { 00891 (void) ThrowMagickException(exception,GetMagickModule(),ImageError, 00892 "ColorSeparatedImageRequired","`%s'",image->filename); 00893 return; 00894 } 00895 switch (quantum_info->depth) 00896 { 00897 case 8: 00898 { 00899 register unsigned char 00900 pixel; 00901 00902 for (x=0; x < (ssize_t) number_pixels; x++) 00903 { 00904 pixel=ScaleQuantumToChar(GetPixelBlack(image,p)); 00905 q=PopCharPixel(pixel,q); 00906 p+=GetPixelChannels(image); 00907 q+=quantum_info->pad; 00908 } 00909 break; 00910 } 00911 case 16: 00912 { 00913 register unsigned short 00914 pixel; 00915 00916 if (quantum_info->format == FloatingPointQuantumFormat) 00917 { 00918 for (x=0; x < (ssize_t) number_pixels; x++) 00919 { 00920 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlack(image,p)); 00921 q=PopShortPixel(quantum_info->endian,pixel,q); 00922 p+=GetPixelChannels(image); 00923 q+=quantum_info->pad; 00924 } 00925 break; 00926 } 00927 for (x=0; x < (ssize_t) number_pixels; x++) 00928 { 00929 pixel=ScaleQuantumToShort(GetPixelBlack(image,p)); 00930 q=PopShortPixel(quantum_info->endian,pixel,q); 00931 p+=GetPixelChannels(image); 00932 q+=quantum_info->pad; 00933 } 00934 break; 00935 } 00936 case 32: 00937 { 00938 register unsigned int 00939 pixel; 00940 00941 if (quantum_info->format == FloatingPointQuantumFormat) 00942 { 00943 for (x=0; x < (ssize_t) number_pixels; x++) 00944 { 00945 q=PopFloatPixel(quantum_info,(float) GetPixelBlack(image,p),q); 00946 p+=GetPixelChannels(image); 00947 q+=quantum_info->pad; 00948 } 00949 break; 00950 } 00951 for (x=0; x < (ssize_t) number_pixels; x++) 00952 { 00953 pixel=ScaleQuantumToLong(GetPixelBlack(image,p)); 00954 q=PopLongPixel(quantum_info->endian,pixel,q); 00955 p+=GetPixelChannels(image); 00956 q+=quantum_info->pad; 00957 } 00958 break; 00959 } 00960 case 64: 00961 { 00962 if (quantum_info->format == FloatingPointQuantumFormat) 00963 { 00964 for (x=0; x < (ssize_t) number_pixels; x++) 00965 { 00966 q=PopDoublePixel(quantum_info,(double) GetPixelBlack(image,p),q); 00967 p+=GetPixelChannels(image); 00968 q+=quantum_info->pad; 00969 } 00970 break; 00971 } 00972 } 00973 default: 00974 { 00975 range=GetQuantumRange(quantum_info->depth); 00976 for (x=0; x < (ssize_t) number_pixels; x++) 00977 { 00978 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlack(image,p), 00979 range),q); 00980 p+=GetPixelChannels(image); 00981 q+=quantum_info->pad; 00982 } 00983 break; 00984 } 00985 } 00986 } 00987 00988 static void ExportBlueQuantum(const Image *image,QuantumInfo *quantum_info, 00989 const MagickSizeType number_pixels,const Quantum *restrict p, 00990 unsigned char *restrict q,ExceptionInfo *exception) 00991 { 00992 QuantumAny 00993 range; 00994 00995 register ssize_t 00996 x; 00997 00998 switch (quantum_info->depth) 00999 { 01000 case 8: 01001 { 01002 register unsigned char 01003 pixel; 01004 01005 for (x=0; x < (ssize_t) number_pixels; x++) 01006 { 01007 pixel=ScaleQuantumToChar(GetPixelBlue(image,p)); 01008 q=PopCharPixel(pixel,q); 01009 p+=GetPixelChannels(image); 01010 q+=quantum_info->pad; 01011 } 01012 break; 01013 } 01014 case 16: 01015 { 01016 register unsigned short 01017 pixel; 01018 01019 if (quantum_info->format == FloatingPointQuantumFormat) 01020 { 01021 for (x=0; x < (ssize_t) number_pixels; x++) 01022 { 01023 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlue(image,p)); 01024 q=PopShortPixel(quantum_info->endian,pixel,q); 01025 p+=GetPixelChannels(image); 01026 q+=quantum_info->pad; 01027 } 01028 break; 01029 } 01030 for (x=0; x < (ssize_t) number_pixels; x++) 01031 { 01032 pixel=ScaleQuantumToShort(GetPixelBlue(image,p)); 01033 q=PopShortPixel(quantum_info->endian,pixel,q); 01034 p+=GetPixelChannels(image); 01035 q+=quantum_info->pad; 01036 } 01037 break; 01038 } 01039 case 32: 01040 { 01041 register unsigned int 01042 pixel; 01043 01044 if (quantum_info->format == FloatingPointQuantumFormat) 01045 { 01046 for (x=0; x < (ssize_t) number_pixels; x++) 01047 { 01048 q=PopFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q); 01049 p+=GetPixelChannels(image); 01050 q+=quantum_info->pad; 01051 } 01052 break; 01053 } 01054 for (x=0; x < (ssize_t) number_pixels; x++) 01055 { 01056 pixel=ScaleQuantumToLong(GetPixelBlue(image,p)); 01057 q=PopLongPixel(quantum_info->endian,pixel,q); 01058 p+=GetPixelChannels(image); 01059 q+=quantum_info->pad; 01060 } 01061 break; 01062 } 01063 case 64: 01064 { 01065 if (quantum_info->format == FloatingPointQuantumFormat) 01066 { 01067 for (x=0; x < (ssize_t) number_pixels; x++) 01068 { 01069 q=PopDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q); 01070 p+=GetPixelChannels(image); 01071 q+=quantum_info->pad; 01072 } 01073 break; 01074 } 01075 } 01076 default: 01077 { 01078 range=GetQuantumRange(quantum_info->depth); 01079 for (x=0; x < (ssize_t) number_pixels; x++) 01080 { 01081 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p), 01082 range),q); 01083 p+=GetPixelChannels(image); 01084 q+=quantum_info->pad; 01085 } 01086 break; 01087 } 01088 } 01089 } 01090 01091 static void ExportCbYCrYQuantum(const Image *image,QuantumInfo *quantum_info, 01092 const MagickSizeType number_pixels,const Quantum *restrict p, 01093 unsigned char *restrict q,ExceptionInfo *exception) 01094 { 01095 Quantum 01096 cbcr[4]; 01097 01098 register ssize_t 01099 i, 01100 x; 01101 01102 register unsigned int 01103 pixel; 01104 01105 size_t 01106 quantum; 01107 01108 ssize_t 01109 n; 01110 01111 n=0; 01112 quantum=0; 01113 switch (quantum_info->depth) 01114 { 01115 case 10: 01116 { 01117 if (quantum_info->pack == MagickFalse) 01118 { 01119 for (x=0; x < (ssize_t) number_pixels; x+=2) 01120 { 01121 for (i=0; i < 4; i++) 01122 { 01123 switch (n % 3) 01124 { 01125 case 0: 01126 { 01127 quantum=GetPixelRed(image,p); 01128 break; 01129 } 01130 case 1: 01131 { 01132 quantum=GetPixelGreen(image,p); 01133 break; 01134 } 01135 case 2: 01136 { 01137 quantum=GetPixelBlue(image,p); 01138 break; 01139 } 01140 } 01141 cbcr[i]=(Quantum) quantum; 01142 n++; 01143 } 01144 pixel=(unsigned int) ((size_t) (cbcr[1]) << 22 | (size_t) 01145 (cbcr[0]) << 12 | (size_t) (cbcr[2]) << 2); 01146 q=PopLongPixel(quantum_info->endian,pixel,q); 01147 p+=GetPixelChannels(image); 01148 pixel=(unsigned int) ((size_t) (cbcr[3]) << 22 | (size_t) 01149 (cbcr[0]) << 12 | (size_t) (cbcr[2]) << 2); 01150 q=PopLongPixel(quantum_info->endian,pixel,q); 01151 p+=GetPixelChannels(image); 01152 q+=quantum_info->pad; 01153 } 01154 break; 01155 } 01156 break; 01157 } 01158 default: 01159 { 01160 QuantumAny 01161 range; 01162 01163 for (x=0; x < (ssize_t) number_pixels; x+=2) 01164 { 01165 for (i=0; i < 4; i++) 01166 { 01167 switch (n % 3) 01168 { 01169 case 0: 01170 { 01171 quantum=GetPixelRed(image,p); 01172 break; 01173 } 01174 case 1: 01175 { 01176 quantum=GetPixelGreen(image,p); 01177 break; 01178 } 01179 case 2: 01180 { 01181 quantum=GetPixelBlue(image,p); 01182 break; 01183 } 01184 } 01185 cbcr[i]=(Quantum) quantum; 01186 n++; 01187 } 01188 range=GetQuantumRange(quantum_info->depth); 01189 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[1],range),q); 01190 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[0],range),q); 01191 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[2],range),q); 01192 p+=GetPixelChannels(image); 01193 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[3],range),q); 01194 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[0],range),q); 01195 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[2],range),q); 01196 p+=GetPixelChannels(image); 01197 q+=quantum_info->pad; 01198 } 01199 break; 01200 } 01201 } 01202 } 01203 01204 static void ExportCMYKQuantum(const Image *image,QuantumInfo *quantum_info, 01205 const MagickSizeType number_pixels,const Quantum *restrict p, 01206 unsigned char *restrict q,ExceptionInfo *exception) 01207 { 01208 register ssize_t 01209 x; 01210 01211 if (image->colorspace != CMYKColorspace) 01212 { 01213 (void) ThrowMagickException(exception,GetMagickModule(),ImageError, 01214 "ColorSeparatedImageRequired","`%s'",image->filename); 01215 return; 01216 } 01217 switch (quantum_info->depth) 01218 { 01219 case 8: 01220 { 01221 register unsigned char 01222 pixel; 01223 01224 for (x=0; x < (ssize_t) number_pixels; x++) 01225 { 01226 pixel=ScaleQuantumToChar(GetPixelRed(image,p)); 01227 q=PopCharPixel(pixel,q); 01228 pixel=ScaleQuantumToChar(GetPixelGreen(image,p)); 01229 q=PopCharPixel(pixel,q); 01230 pixel=ScaleQuantumToChar(GetPixelBlue(image,p)); 01231 q=PopCharPixel(pixel,q); 01232 pixel=ScaleQuantumToChar(GetPixelBlack(image,p)); 01233 q=PopCharPixel(pixel,q); 01234 p+=GetPixelChannels(image); 01235 q+=quantum_info->pad; 01236 } 01237 break; 01238 } 01239 case 16: 01240 { 01241 register unsigned short 01242 pixel; 01243 01244 if (quantum_info->format == FloatingPointQuantumFormat) 01245 { 01246 for (x=0; x < (ssize_t) number_pixels; x++) 01247 { 01248 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelRed(image,p)); 01249 q=PopShortPixel(quantum_info->endian,pixel,q); 01250 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelGreen(image,p)); 01251 q=PopShortPixel(quantum_info->endian,pixel,q); 01252 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlue(image,p)); 01253 q=PopShortPixel(quantum_info->endian,pixel,q); 01254 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlack(image,p)); 01255 q=PopShortPixel(quantum_info->endian,pixel,q); 01256 p+=GetPixelChannels(image); 01257 q+=quantum_info->pad; 01258 } 01259 break; 01260 } 01261 for (x=0; x < (ssize_t) number_pixels; x++) 01262 { 01263 pixel=ScaleQuantumToShort(GetPixelRed(image,p)); 01264 q=PopShortPixel(quantum_info->endian,pixel,q); 01265 pixel=ScaleQuantumToShort(GetPixelGreen(image,p)); 01266 q=PopShortPixel(quantum_info->endian,pixel,q); 01267 pixel=ScaleQuantumToShort(GetPixelBlue(image,p)); 01268 q=PopShortPixel(quantum_info->endian,pixel,q); 01269 pixel=ScaleQuantumToShort(GetPixelBlack(image,p)); 01270 q=PopShortPixel(quantum_info->endian,pixel,q); 01271 p+=GetPixelChannels(image); 01272 q+=quantum_info->pad; 01273 } 01274 break; 01275 } 01276 case 32: 01277 { 01278 register unsigned int 01279 pixel; 01280 01281 if (quantum_info->format == FloatingPointQuantumFormat) 01282 { 01283 for (x=0; x < (ssize_t) number_pixels; x++) 01284 { 01285 q=PopFloatPixel(quantum_info,(float) GetPixelRed(image,p),q); 01286 q=PopFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q); 01287 q=PopFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q); 01288 q=PopFloatPixel(quantum_info,(float) GetPixelBlack(image,p),q); 01289 p+=GetPixelChannels(image); 01290 q+=quantum_info->pad; 01291 } 01292 break; 01293 } 01294 for (x=0; x < (ssize_t) number_pixels; x++) 01295 { 01296 pixel=ScaleQuantumToLong(GetPixelRed(image,p)); 01297 q=PopLongPixel(quantum_info->endian,pixel,q); 01298 pixel=ScaleQuantumToLong(GetPixelGreen(image,p)); 01299 q=PopLongPixel(quantum_info->endian,pixel,q); 01300 pixel=ScaleQuantumToLong(GetPixelBlue(image,p)); 01301 q=PopLongPixel(quantum_info->endian,pixel,q); 01302 pixel=ScaleQuantumToLong(GetPixelBlack(image,p)); 01303 q=PopLongPixel(quantum_info->endian,pixel,q); 01304 p+=GetPixelChannels(image); 01305 q+=quantum_info->pad; 01306 } 01307 break; 01308 } 01309 case 64: 01310 { 01311 if (quantum_info->format == FloatingPointQuantumFormat) 01312 { 01313 for (x=0; x < (ssize_t) number_pixels; x++) 01314 { 01315 q=PopDoublePixel(quantum_info,(double) GetPixelRed(image,p),q); 01316 q=PopDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q); 01317 q=PopDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q); 01318 q=PopDoublePixel(quantum_info,(double) GetPixelBlack(image,p),q); 01319 p+=GetPixelChannels(image); 01320 q+=quantum_info->pad; 01321 } 01322 break; 01323 } 01324 } 01325 default: 01326 { 01327 QuantumAny 01328 range; 01329 01330 range=GetQuantumRange(quantum_info->depth); 01331 for (x=0; x < (ssize_t) number_pixels; x++) 01332 { 01333 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p), 01334 range),q); 01335 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p), 01336 range),q); 01337 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p), 01338 range),q); 01339 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlack(image,p), 01340 range),q); 01341 p+=GetPixelChannels(image); 01342 q+=quantum_info->pad; 01343 } 01344 break; 01345 } 01346 } 01347 } 01348 01349 static void ExportCMYKAQuantum(const Image *image,QuantumInfo *quantum_info, 01350 const MagickSizeType number_pixels,const Quantum *restrict p, 01351 unsigned char *restrict q,ExceptionInfo *exception) 01352 { 01353 register ssize_t 01354 x; 01355 01356 if (image->colorspace != CMYKColorspace) 01357 { 01358 (void) ThrowMagickException(exception,GetMagickModule(),ImageError, 01359 "ColorSeparatedImageRequired","`%s'",image->filename); 01360 return; 01361 } 01362 switch (quantum_info->depth) 01363 { 01364 case 8: 01365 { 01366 register unsigned char 01367 pixel; 01368 01369 for (x=0; x < (ssize_t) number_pixels; x++) 01370 { 01371 pixel=ScaleQuantumToChar(GetPixelRed(image,p)); 01372 q=PopCharPixel(pixel,q); 01373 pixel=ScaleQuantumToChar(GetPixelGreen(image,p)); 01374 q=PopCharPixel(pixel,q); 01375 pixel=ScaleQuantumToChar(GetPixelBlue(image,p)); 01376 q=PopCharPixel(pixel,q); 01377 pixel=ScaleQuantumToChar(GetPixelBlack(image,p)); 01378 q=PopCharPixel(pixel,q); 01379 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p)); 01380 q=PopCharPixel(pixel,q); 01381 p+=GetPixelChannels(image); 01382 q+=quantum_info->pad; 01383 } 01384 break; 01385 } 01386 case 16: 01387 { 01388 register unsigned short 01389 pixel; 01390 01391 if (quantum_info->format == FloatingPointQuantumFormat) 01392 { 01393 for (x=0; x < (ssize_t) number_pixels; x++) 01394 { 01395 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelRed(image,p)); 01396 q=PopShortPixel(quantum_info->endian,pixel,q); 01397 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelGreen(image,p)); 01398 q=PopShortPixel(quantum_info->endian,pixel,q); 01399 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlue(image,p)); 01400 q=PopShortPixel(quantum_info->endian,pixel,q); 01401 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlack(image,p)); 01402 q=PopShortPixel(quantum_info->endian,pixel,q); 01403 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelAlpha(image,p)); 01404 q=PopShortPixel(quantum_info->endian,pixel,q); 01405 p+=GetPixelChannels(image); 01406 q+=quantum_info->pad; 01407 } 01408 break; 01409 } 01410 for (x=0; x < (ssize_t) number_pixels; x++) 01411 { 01412 pixel=ScaleQuantumToShort(GetPixelRed(image,p)); 01413 q=PopShortPixel(quantum_info->endian,pixel,q); 01414 pixel=ScaleQuantumToShort(GetPixelGreen(image,p)); 01415 q=PopShortPixel(quantum_info->endian,pixel,q); 01416 pixel=ScaleQuantumToShort(GetPixelBlue(image,p)); 01417 q=PopShortPixel(quantum_info->endian,pixel,q); 01418 pixel=ScaleQuantumToShort(GetPixelBlack(image,p)); 01419 q=PopShortPixel(quantum_info->endian,pixel,q); 01420 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p)); 01421 q=PopShortPixel(quantum_info->endian,pixel,q); 01422 p+=GetPixelChannels(image); 01423 q+=quantum_info->pad; 01424 } 01425 break; 01426 } 01427 case 32: 01428 { 01429 register unsigned int 01430 pixel; 01431 01432 if (quantum_info->format == FloatingPointQuantumFormat) 01433 { 01434 for (x=0; x < (ssize_t) number_pixels; x++) 01435 { 01436 float 01437 pixel; 01438 01439 q=PopFloatPixel(quantum_info,(float) GetPixelRed(image,p),q); 01440 q=PopFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q); 01441 q=PopFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q); 01442 q=PopFloatPixel(quantum_info,(float) GetPixelBlack(image,p),q); 01443 pixel=(float) (GetPixelAlpha(image,p)); 01444 q=PopFloatPixel(quantum_info,pixel,q); 01445 p+=GetPixelChannels(image); 01446 q+=quantum_info->pad; 01447 } 01448 break; 01449 } 01450 for (x=0; x < (ssize_t) number_pixels; x++) 01451 { 01452 pixel=ScaleQuantumToLong(GetPixelRed(image,p)); 01453 q=PopLongPixel(quantum_info->endian,pixel,q); 01454 pixel=ScaleQuantumToLong(GetPixelGreen(image,p)); 01455 q=PopLongPixel(quantum_info->endian,pixel,q); 01456 pixel=ScaleQuantumToLong(GetPixelBlue(image,p)); 01457 q=PopLongPixel(quantum_info->endian,pixel,q); 01458 pixel=ScaleQuantumToLong(GetPixelBlack(image,p)); 01459 q=PopLongPixel(quantum_info->endian,pixel,q); 01460 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p)); 01461 q=PopLongPixel(quantum_info->endian,pixel,q); 01462 p+=GetPixelChannels(image); 01463 q+=quantum_info->pad; 01464 } 01465 break; 01466 } 01467 case 64: 01468 { 01469 if (quantum_info->format == FloatingPointQuantumFormat) 01470 { 01471 double 01472 pixel; 01473 01474 for (x=0; x < (ssize_t) number_pixels; x++) 01475 { 01476 q=PopDoublePixel(quantum_info,(double) GetPixelRed(image,p),q); 01477 q=PopDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q); 01478 q=PopDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q); 01479 q=PopDoublePixel(quantum_info,(double) GetPixelBlack(image,p),q); 01480 pixel=(double) (GetPixelAlpha(image,p)); 01481 q=PopDoublePixel(quantum_info,pixel,q); 01482 p+=GetPixelChannels(image); 01483 q+=quantum_info->pad; 01484 } 01485 break; 01486 } 01487 } 01488 default: 01489 { 01490 QuantumAny 01491 range; 01492 01493 range=GetQuantumRange(quantum_info->depth); 01494 for (x=0; x < (ssize_t) number_pixels; x++) 01495 { 01496 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p), 01497 range),q); 01498 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p), 01499 range),q); 01500 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p), 01501 range),q); 01502 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlack(image,p), 01503 range),q); 01504 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p), 01505 range),q); 01506 p+=GetPixelChannels(image); 01507 q+=quantum_info->pad; 01508 } 01509 break; 01510 } 01511 } 01512 } 01513 01514 static void ExportGrayQuantum(const Image *image,QuantumInfo *quantum_info, 01515 const MagickSizeType number_pixels,const Quantum *restrict p, 01516 unsigned char *restrict q,ExceptionInfo *exception) 01517 { 01518 QuantumAny 01519 range; 01520 01521 register ssize_t 01522 x; 01523 01524 switch (quantum_info->depth) 01525 { 01526 case 1: 01527 { 01528 register Quantum 01529 threshold; 01530 01531 register unsigned char 01532 black, 01533 white; 01534 01535 ssize_t 01536 bit; 01537 01538 black=0x00; 01539 white=0x01; 01540 if (quantum_info->min_is_white != MagickFalse) 01541 { 01542 black=0x01; 01543 white=0x00; 01544 } 01545 threshold=(Quantum) (QuantumRange/2); 01546 for (x=((ssize_t) number_pixels-7); x > 0; x-=8) 01547 { 01548 *q='\0'; 01549 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) << 7; 01550 p+=GetPixelChannels(image); 01551 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) << 6; 01552 p+=GetPixelChannels(image); 01553 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) << 5; 01554 p+=GetPixelChannels(image); 01555 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) << 4; 01556 p+=GetPixelChannels(image); 01557 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) << 3; 01558 p+=GetPixelChannels(image); 01559 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) << 2; 01560 p+=GetPixelChannels(image); 01561 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) << 1; 01562 p+=GetPixelChannels(image); 01563 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) << 0; 01564 p+=GetPixelChannels(image); 01565 q++; 01566 } 01567 if ((number_pixels % 8) != 0) 01568 { 01569 *q='\0'; 01570 for (bit=7; bit >= (ssize_t) (8-(number_pixels % 8)); bit--) 01571 { 01572 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) << bit; 01573 p+=GetPixelChannels(image); 01574 } 01575 q++; 01576 } 01577 break; 01578 } 01579 case 4: 01580 { 01581 register unsigned char 01582 pixel; 01583 01584 for (x=0; x < (ssize_t) (number_pixels-1) ; x+=2) 01585 { 01586 pixel=ScaleQuantumToChar(GetPixelIntensity(image,p)); 01587 *q=(((pixel >> 4) & 0xf) << 4); 01588 p+=GetPixelChannels(image); 01589 pixel=ScaleQuantumToChar(GetPixelIntensity(image,p)); 01590 *q|=pixel >> 4; 01591 p+=GetPixelChannels(image); 01592 q++; 01593 } 01594 if ((number_pixels % 2) != 0) 01595 { 01596 pixel=ScaleQuantumToChar(GetPixelIntensity(image,p)); 01597 *q=(((pixel >> 4) & 0xf) << 4); 01598 p+=GetPixelChannels(image); 01599 q++; 01600 } 01601 break; 01602 } 01603 case 8: 01604 { 01605 register unsigned char 01606 pixel; 01607 01608 for (x=0; x < (ssize_t) number_pixels; x++) 01609 { 01610 pixel=ScaleQuantumToChar(GetPixelIntensity(image,p)); 01611 q=PopCharPixel(pixel,q); 01612 p+=GetPixelChannels(image); 01613 q+=quantum_info->pad; 01614 } 01615 break; 01616 } 01617 case 10: 01618 { 01619 range=GetQuantumRange(quantum_info->depth); 01620 if (quantum_info->pack == MagickFalse) 01621 { 01622 register unsigned int 01623 pixel; 01624 01625 for (x=0; x < (ssize_t) (number_pixels-2); x+=3) 01626 { 01627 pixel=(unsigned int) (ScaleQuantumToAny(GetPixelIntensity(image, 01628 p+2*GetPixelChannels(image)),range) << 22 | ScaleQuantumToAny( 01629 GetPixelIntensity(image,p+GetPixelChannels(image)),range) << 12 | 01630 ScaleQuantumToAny(GetPixelIntensity(image,p),range) << 2); 01631 q=PopLongPixel(quantum_info->endian,pixel,q); 01632 p+=3*GetPixelChannels(image); 01633 q+=quantum_info->pad; 01634 } 01635 if (x < (ssize_t) number_pixels) 01636 { 01637 pixel=0U; 01638 if (x++ < (ssize_t) (number_pixels-1)) 01639 pixel|=ScaleQuantumToAny(GetPixelIntensity(image,p+ 01640 GetPixelChannels(image)),range) << 12; 01641 if (x++ < (ssize_t) number_pixels) 01642 pixel|=ScaleQuantumToAny(GetPixelIntensity(image,p),range) << 2; 01643 q=PopLongPixel(quantum_info->endian,pixel,q); 01644 } 01645 break; 01646 } 01647 for (x=0; x < (ssize_t) number_pixels; x++) 01648 { 01649 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny( 01650 GetPixelIntensity(image,p),range),q); 01651 p+=GetPixelChannels(image); 01652 q+=quantum_info->pad; 01653 } 01654 break; 01655 } 01656 case 12: 01657 { 01658 register unsigned short 01659 pixel; 01660 01661 range=GetQuantumRange(quantum_info->depth); 01662 if (quantum_info->pack == MagickFalse) 01663 { 01664 for (x=0; x < (ssize_t) number_pixels; x++) 01665 { 01666 pixel=ScaleQuantumToShort(GetPixelIntensity(image,p)); 01667 q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel >> 4), 01668 q); 01669 p+=GetPixelChannels(image); 01670 q+=quantum_info->pad; 01671 } 01672 break; 01673 } 01674 for (x=0; x < (ssize_t) number_pixels; x++) 01675 { 01676 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny( 01677 GetPixelIntensity(image,p),range),q); 01678 p+=GetPixelChannels(image); 01679 q+=quantum_info->pad; 01680 } 01681 break; 01682 } 01683 case 16: 01684 { 01685 register unsigned short 01686 pixel; 01687 01688 if (quantum_info->format == FloatingPointQuantumFormat) 01689 { 01690 for (x=0; x < (ssize_t) number_pixels; x++) 01691 { 01692 pixel=SinglePrecisionToHalf(QuantumScale* 01693 GetPixelIntensity(image,p)); 01694 q=PopShortPixel(quantum_info->endian,pixel,q); 01695 p+=GetPixelChannels(image); 01696 q+=quantum_info->pad; 01697 } 01698 break; 01699 } 01700 for (x=0; x < (ssize_t) number_pixels; x++) 01701 { 01702 pixel=ScaleQuantumToShort(GetPixelIntensity(image,p)); 01703 q=PopShortPixel(quantum_info->endian,pixel,q); 01704 p+=GetPixelChannels(image); 01705 q+=quantum_info->pad; 01706 } 01707 break; 01708 } 01709 case 32: 01710 { 01711 register unsigned int 01712 pixel; 01713 01714 if (quantum_info->format == FloatingPointQuantumFormat) 01715 { 01716 for (x=0; x < (ssize_t) number_pixels; x++) 01717 { 01718 float 01719 pixel; 01720 01721 pixel=(float) GetPixelIntensity(image,p); 01722 q=PopFloatPixel(quantum_info,pixel,q); 01723 p+=GetPixelChannels(image); 01724 q+=quantum_info->pad; 01725 } 01726 break; 01727 } 01728 for (x=0; x < (ssize_t) number_pixels; x++) 01729 { 01730 pixel=ScaleQuantumToLong(GetPixelIntensity(image,p)); 01731 q=PopLongPixel(quantum_info->endian,pixel,q); 01732 p+=GetPixelChannels(image); 01733 q+=quantum_info->pad; 01734 } 01735 break; 01736 } 01737 case 64: 01738 { 01739 if (quantum_info->format == FloatingPointQuantumFormat) 01740 { 01741 for (x=0; x < (ssize_t) number_pixels; x++) 01742 { 01743 double 01744 pixel; 01745 01746 pixel=(double) GetPixelIntensity(image,p); 01747 q=PopDoublePixel(quantum_info,pixel,q); 01748 p+=GetPixelChannels(image); 01749 q+=quantum_info->pad; 01750 } 01751 break; 01752 } 01753 } 01754 default: 01755 { 01756 range=GetQuantumRange(quantum_info->depth); 01757 for (x=0; x < (ssize_t) number_pixels; x++) 01758 { 01759 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny( 01760 GetPixelIntensity(image,p),range),q); 01761 p+=GetPixelChannels(image); 01762 q+=quantum_info->pad; 01763 } 01764 break; 01765 } 01766 } 01767 } 01768 01769 static void ExportGrayAlphaQuantum(const Image *image,QuantumInfo *quantum_info, 01770 const MagickSizeType number_pixels,const Quantum *restrict p, 01771 unsigned char *restrict q,ExceptionInfo *exception) 01772 { 01773 QuantumAny 01774 range; 01775 01776 register ssize_t 01777 x; 01778 01779 switch (quantum_info->depth) 01780 { 01781 case 1: 01782 { 01783 register Quantum 01784 threshold; 01785 01786 register unsigned char 01787 black, 01788 pixel, 01789 white; 01790 01791 ssize_t 01792 bit; 01793 01794 black=0x00; 01795 white=0x01; 01796 if (quantum_info->min_is_white == MagickFalse) 01797 { 01798 black=0x01; 01799 white=0x00; 01800 } 01801 threshold=(Quantum) (QuantumRange/2); 01802 for (x=((ssize_t) number_pixels-3); x > 0; x-=4) 01803 { 01804 *q='\0'; 01805 *q|=(GetPixelIntensity(image,p) > threshold ? black : white) << 7; 01806 pixel=(unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ? 01807 0x00 : 0x01); 01808 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 6); 01809 p+=GetPixelChannels(image); 01810 *q|=(GetPixelIntensity(image,p) > threshold ? black : white) << 5; 01811 pixel=(unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ? 01812 0x00 : 0x01); 01813 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 4); 01814 p+=GetPixelChannels(image); 01815 *q|=(GetPixelIntensity(image,p) > threshold ? black : white) << 3; 01816 pixel=(unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ? 01817 0x00 : 0x01); 01818 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 2); 01819 p+=GetPixelChannels(image); 01820 *q|=(GetPixelIntensity(image,p) > threshold ? black : white) << 1; 01821 pixel=(unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ? 01822 0x00 : 0x01); 01823 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 0); 01824 p+=GetPixelChannels(image); 01825 q++; 01826 } 01827 if ((number_pixels % 4) != 0) 01828 { 01829 *q='\0'; 01830 for (bit=0; bit <= (ssize_t) (number_pixels % 4); bit+=2) 01831 { 01832 *q|=(GetPixelIntensity(image,p) > threshold ? black : white) << 01833 (7-bit); 01834 pixel=(unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ? 01835 0x00 : 0x01); 01836 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << (unsigned char) 01837 (7-bit-1)); 01838 p+=GetPixelChannels(image); 01839 } 01840 q++; 01841 } 01842 break; 01843 } 01844 case 4: 01845 { 01846 register unsigned char 01847 pixel; 01848 01849 for (x=0; x < (ssize_t) number_pixels ; x++) 01850 { 01851 pixel=ScaleQuantumToChar(GetPixelIntensity(image,p)); 01852 *q=(((pixel >> 4) & 0xf) << 4); 01853 pixel=(unsigned char) (16*QuantumScale*GetPixelAlpha(image,p)+0.5); 01854 *q|=pixel & 0xf; 01855 p+=GetPixelChannels(image); 01856 q++; 01857 } 01858 break; 01859 } 01860 case 8: 01861 { 01862 register unsigned char 01863 pixel; 01864 01865 for (x=0; x < (ssize_t) number_pixels; x++) 01866 { 01867 pixel=ScaleQuantumToChar(GetPixelIntensity(image,p)); 01868 q=PopCharPixel(pixel,q); 01869 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p)); 01870 q=PopCharPixel(pixel,q); 01871 p+=GetPixelChannels(image); 01872 q+=quantum_info->pad; 01873 } 01874 break; 01875 } 01876 case 16: 01877 { 01878 register unsigned short 01879 pixel; 01880 01881 if (quantum_info->format == FloatingPointQuantumFormat) 01882 { 01883 for (x=0; x < (ssize_t) number_pixels; x++) 01884 { 01885 pixel=SinglePrecisionToHalf(QuantumScale* 01886 GetPixelIntensity(image,p)); 01887 q=PopShortPixel(quantum_info->endian,pixel,q); 01888 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelAlpha(image,p)); 01889 q=PopShortPixel(quantum_info->endian,pixel,q); 01890 p+=GetPixelChannels(image); 01891 q+=quantum_info->pad; 01892 } 01893 break; 01894 } 01895 for (x=0; x < (ssize_t) number_pixels; x++) 01896 { 01897 pixel=ScaleQuantumToShort(GetPixelIntensity(image,p)); 01898 q=PopShortPixel(quantum_info->endian,pixel,q); 01899 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p)); 01900 q=PopShortPixel(quantum_info->endian,pixel,q); 01901 p+=GetPixelChannels(image); 01902 q+=quantum_info->pad; 01903 } 01904 break; 01905 } 01906 case 32: 01907 { 01908 register unsigned int 01909 pixel; 01910 01911 if (quantum_info->format == FloatingPointQuantumFormat) 01912 { 01913 for (x=0; x < (ssize_t) number_pixels; x++) 01914 { 01915 float 01916 pixel; 01917 01918 pixel=(float) GetPixelIntensity(image,p); 01919 q=PopFloatPixel(quantum_info,pixel,q); 01920 pixel=(float) (GetPixelAlpha(image,p)); 01921 q=PopFloatPixel(quantum_info,pixel,q); 01922 p+=GetPixelChannels(image); 01923 q+=quantum_info->pad; 01924 } 01925 break; 01926 } 01927 for (x=0; x < (ssize_t) number_pixels; x++) 01928 { 01929 pixel=ScaleQuantumToLong(GetPixelIntensity(image,p)); 01930 q=PopLongPixel(quantum_info->endian,pixel,q); 01931 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p)); 01932 q=PopLongPixel(quantum_info->endian,pixel,q); 01933 p+=GetPixelChannels(image); 01934 q+=quantum_info->pad; 01935 } 01936 break; 01937 } 01938 case 64: 01939 { 01940 if (quantum_info->format == FloatingPointQuantumFormat) 01941 { 01942 for (x=0; x < (ssize_t) number_pixels; x++) 01943 { 01944 double 01945 pixel; 01946 01947 pixel=(double) GetPixelIntensity(image,p); 01948 q=PopDoublePixel(quantum_info,pixel,q); 01949 pixel=(double) (GetPixelAlpha(image,p)); 01950 q=PopDoublePixel(quantum_info,pixel,q); 01951 p+=GetPixelChannels(image); 01952 q+=quantum_info->pad; 01953 } 01954 break; 01955 } 01956 } 01957 default: 01958 { 01959 range=GetQuantumRange(quantum_info->depth); 01960 for (x=0; x < (ssize_t) number_pixels; x++) 01961 { 01962 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny( 01963 GetPixelIntensity(image,p),range),q); 01964 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p), 01965 range),q); 01966 p+=GetPixelChannels(image); 01967 q+=quantum_info->pad; 01968 } 01969 break; 01970 } 01971 } 01972 } 01973 01974 static void ExportGreenQuantum(const Image *image,QuantumInfo *quantum_info, 01975 const MagickSizeType number_pixels,const Quantum *restrict p, 01976 unsigned char *restrict q,ExceptionInfo *exception) 01977 { 01978 QuantumAny 01979 range; 01980 01981 register ssize_t 01982 x; 01983 01984 switch (quantum_info->depth) 01985 { 01986 case 8: 01987 { 01988 register unsigned char 01989 pixel; 01990 01991 for (x=0; x < (ssize_t) number_pixels; x++) 01992 { 01993 pixel=ScaleQuantumToChar(GetPixelGreen(image,p)); 01994 q=PopCharPixel(pixel,q); 01995 p+=GetPixelChannels(image); 01996 q+=quantum_info->pad; 01997 } 01998 break; 01999 } 02000 case 16: 02001 { 02002 register unsigned short 02003 pixel; 02004 02005 if (quantum_info->format == FloatingPointQuantumFormat) 02006 { 02007 for (x=0; x < (ssize_t) number_pixels; x++) 02008 { 02009 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelGreen(image,p)); 02010 q=PopShortPixel(quantum_info->endian,pixel,q); 02011 p+=GetPixelChannels(image); 02012 q+=quantum_info->pad; 02013 } 02014 break; 02015 } 02016 for (x=0; x < (ssize_t) number_pixels; x++) 02017 { 02018 pixel=ScaleQuantumToShort(GetPixelGreen(image,p)); 02019 q=PopShortPixel(quantum_info->endian,pixel,q); 02020 p+=GetPixelChannels(image); 02021 q+=quantum_info->pad; 02022 } 02023 break; 02024 } 02025 case 32: 02026 { 02027 register unsigned int 02028 pixel; 02029 02030 if (quantum_info->format == FloatingPointQuantumFormat) 02031 { 02032 for (x=0; x < (ssize_t) number_pixels; x++) 02033 { 02034 q=PopFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q); 02035 p+=GetPixelChannels(image); 02036 q+=quantum_info->pad; 02037 } 02038 break; 02039 } 02040 for (x=0; x < (ssize_t) number_pixels; x++) 02041 { 02042 pixel=ScaleQuantumToLong(GetPixelGreen(image,p)); 02043 q=PopLongPixel(quantum_info->endian,pixel,q); 02044 p+=GetPixelChannels(image); 02045 q+=quantum_info->pad; 02046 } 02047 break; 02048 } 02049 case 64: 02050 { 02051 if (quantum_info->format == FloatingPointQuantumFormat) 02052 { 02053 for (x=0; x < (ssize_t) number_pixels; x++) 02054 { 02055 q=PopDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q); 02056 p+=GetPixelChannels(image); 02057 q+=quantum_info->pad; 02058 } 02059 break; 02060 } 02061 } 02062 default: 02063 { 02064 range=GetQuantumRange(quantum_info->depth); 02065 for (x=0; x < (ssize_t) number_pixels; x++) 02066 { 02067 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p), 02068 range),q); 02069 p+=GetPixelChannels(image); 02070 q+=quantum_info->pad; 02071 } 02072 break; 02073 } 02074 } 02075 } 02076 02077 static void ExportIndexQuantum(const Image *image,QuantumInfo *quantum_info, 02078 const MagickSizeType number_pixels,const Quantum *restrict p, 02079 unsigned char *restrict q,ExceptionInfo *exception) 02080 { 02081 register ssize_t 02082 x; 02083 02084 ssize_t 02085 bit; 02086 02087 if (image->storage_class != PseudoClass) 02088 { 02089 (void) ThrowMagickException(exception,GetMagickModule(),ImageError, 02090 "ColormappedImageRequired","`%s'",image->filename); 02091 return; 02092 } 02093 switch (quantum_info->depth) 02094 { 02095 case 1: 02096 { 02097 register unsigned char 02098 pixel; 02099 02100 for (x=((ssize_t) number_pixels-7); x > 0; x-=8) 02101 { 02102 pixel=(unsigned char) GetPixelIndex(image,p); 02103 *q=((pixel & 0x01) << 7); 02104 p+=GetPixelChannels(image); 02105 pixel=(unsigned char) GetPixelIndex(image,p); 02106 *q|=((pixel & 0x01) << 6); 02107 p+=GetPixelChannels(image); 02108 pixel=(unsigned char) GetPixelIndex(image,p); 02109 *q|=((pixel & 0x01) << 5); 02110 p+=GetPixelChannels(image); 02111 pixel=(unsigned char) GetPixelIndex(image,p); 02112 *q|=((pixel & 0x01) << 4); 02113 p+=GetPixelChannels(image); 02114 pixel=(unsigned char) GetPixelIndex(image,p); 02115 *q|=((pixel & 0x01) << 3); 02116 p+=GetPixelChannels(image); 02117 pixel=(unsigned char) GetPixelIndex(image,p); 02118 *q|=((pixel & 0x01) << 2); 02119 p+=GetPixelChannels(image); 02120 pixel=(unsigned char) GetPixelIndex(image,p); 02121 *q|=((pixel & 0x01) << 1); 02122 p+=GetPixelChannels(image); 02123 pixel=(unsigned char) GetPixelIndex(image,p); 02124 *q|=((pixel & 0x01) << 0); 02125 p+=GetPixelChannels(image); 02126 q++; 02127 } 02128 if ((number_pixels % 8) != 0) 02129 { 02130 *q='\0'; 02131 for (bit=7; bit >= (ssize_t) (8-(number_pixels % 8)); bit--) 02132 { 02133 pixel=(unsigned char) GetPixelIndex(image,p); 02134 *q|=((pixel & 0x01) << (unsigned char) bit); 02135 p+=GetPixelChannels(image); 02136 } 02137 q++; 02138 } 02139 break; 02140 } 02141 case 4: 02142 { 02143 register unsigned char 02144 pixel; 02145 02146 for (x=0; x < (ssize_t) (number_pixels-1) ; x+=2) 02147 { 02148 pixel=(unsigned char) GetPixelIndex(image,p); 02149 *q=((pixel & 0xf) << 4); 02150 p+=GetPixelChannels(image); 02151 pixel=(unsigned char) GetPixelIndex(image,p); 02152 *q|=((pixel & 0xf) << 0); 02153 p+=GetPixelChannels(image); 02154 q++; 02155 } 02156 if ((number_pixels % 2) != 0) 02157 { 02158 pixel=(unsigned char) GetPixelIndex(image,p); 02159 *q=((pixel & 0xf) << 4); 02160 p+=GetPixelChannels(image); 02161 q++; 02162 } 02163 break; 02164 } 02165 case 8: 02166 { 02167 for (x=0; x < (ssize_t) number_pixels; x++) 02168 { 02169 q=PopCharPixel((unsigned char) GetPixelIndex(image,p),q); 02170 p+=GetPixelChannels(image); 02171 q+=quantum_info->pad; 02172 } 02173 break; 02174 } 02175 case 16: 02176 { 02177 if (quantum_info->format == FloatingPointQuantumFormat) 02178 { 02179 for (x=0; x < (ssize_t) number_pixels; x++) 02180 { 02181 q=PopShortPixel(quantum_info->endian,SinglePrecisionToHalf( 02182 QuantumScale*GetPixelIndex(image,p)),q); 02183 p+=GetPixelChannels(image); 02184 q+=quantum_info->pad; 02185 } 02186 break; 02187 } 02188 for (x=0; x < (ssize_t) number_pixels; x++) 02189 { 02190 q=PopShortPixel(quantum_info->endian,(unsigned short) 02191 GetPixelIndex(image,p),q); 02192 p+=GetPixelChannels(image); 02193 q+=quantum_info->pad; 02194 } 02195 break; 02196 } 02197 case 32: 02198 { 02199 if (quantum_info->format == FloatingPointQuantumFormat) 02200 { 02201 for (x=0; x < (ssize_t) number_pixels; x++) 02202 { 02203 q=PopFloatPixel(quantum_info,(float) GetPixelIndex(image,p),q); 02204 p+=GetPixelChannels(image); 02205 q+=quantum_info->pad; 02206 } 02207 break; 02208 } 02209 for (x=0; x < (ssize_t) number_pixels; x++) 02210 { 02211 q=PopLongPixel(quantum_info->endian,(unsigned int) 02212 GetPixelIndex(image,p),q); 02213 p+=GetPixelChannels(image); 02214 q+=quantum_info->pad; 02215 } 02216 break; 02217 } 02218 case 64: 02219 { 02220 if (quantum_info->format == FloatingPointQuantumFormat) 02221 { 02222 for (x=0; x < (ssize_t) number_pixels; x++) 02223 { 02224 q=PopDoublePixel(quantum_info,(double) GetPixelIndex(image,p),q); 02225 p+=GetPixelChannels(image); 02226 q+=quantum_info->pad; 02227 } 02228 break; 02229 } 02230 } 02231 default: 02232 { 02233 for (x=0; x < (ssize_t) number_pixels; x++) 02234 { 02235 q=PopQuantumPixel(quantum_info,GetPixelIndex(image,p),q); 02236 p+=GetPixelChannels(image); 02237 q+=quantum_info->pad; 02238 } 02239 break; 02240 } 02241 } 02242 } 02243 02244 static void ExportIndexAlphaQuantum(const Image *image, 02245 QuantumInfo *quantum_info,const MagickSizeType number_pixels, 02246 const Quantum *restrict p,unsigned char *restrict q,ExceptionInfo *exception) 02247 { 02248 register ssize_t 02249 x; 02250 02251 ssize_t 02252 bit; 02253 02254 if (image->storage_class != PseudoClass) 02255 { 02256 (void) ThrowMagickException(exception,GetMagickModule(),ImageError, 02257 "ColormappedImageRequired","`%s'",image->filename); 02258 return; 02259 } 02260 switch (quantum_info->depth) 02261 { 02262 case 1: 02263 { 02264 register unsigned char 02265 pixel; 02266 02267 for (x=((ssize_t) number_pixels-3); x > 0; x-=4) 02268 { 02269 pixel=(unsigned char) GetPixelIndex(image,p); 02270 *q=((pixel & 0x01) << 7); 02271 pixel=(unsigned char) (GetPixelAlpha(image,p) == (Quantum) 02272 TransparentAlpha ? 1 : 0); 02273 *q|=((pixel & 0x01) << 6); 02274 p+=GetPixelChannels(image); 02275 pixel=(unsigned char) GetPixelIndex(image,p); 02276 *q|=((pixel & 0x01) << 5); 02277 pixel=(unsigned char) (GetPixelAlpha(image,p) == (Quantum) 02278 TransparentAlpha ? 1 : 0); 02279 *q|=((pixel & 0x01) << 4); 02280 p+=GetPixelChannels(image); 02281 pixel=(unsigned char) GetPixelIndex(image,p); 02282 *q|=((pixel & 0x01) << 3); 02283 pixel=(unsigned char) (GetPixelAlpha(image,p) == (Quantum) 02284 TransparentAlpha ? 1 : 0); 02285 *q|=((pixel & 0x01) << 2); 02286 p+=GetPixelChannels(image); 02287 pixel=(unsigned char) GetPixelIndex(image,p); 02288 *q|=((pixel & 0x01) << 1); 02289 pixel=(unsigned char) (GetPixelAlpha(image,p) == (Quantum) 02290 TransparentAlpha ? 1 : 0); 02291 *q|=((pixel & 0x01) << 0); 02292 p+=GetPixelChannels(image); 02293 q++; 02294 } 02295 if ((number_pixels % 4) != 0) 02296 { 02297 *q='\0'; 02298 for (bit=3; bit >= (ssize_t) (4-(number_pixels % 4)); bit-=2) 02299 { 02300 pixel=(unsigned char) GetPixelIndex(image,p); 02301 *q|=((pixel & 0x01) << (unsigned char) (bit+4)); 02302 pixel=(unsigned char) (GetPixelAlpha(image,p) == (Quantum) 02303 TransparentAlpha ? 1 : 0); 02304 *q|=((pixel & 0x01) << (unsigned char) (bit+4-1)); 02305 p+=GetPixelChannels(image); 02306 } 02307 q++; 02308 } 02309 break; 02310 } 02311 case 4: 02312 { 02313 register unsigned char 02314 pixel; 02315 02316 for (x=0; x < (ssize_t) number_pixels ; x++) 02317 { 02318 pixel=(unsigned char) GetPixelIndex(image,p); 02319 *q=((pixel & 0xf) << 4); 02320 pixel=(unsigned char) (16*QuantumScale*GetPixelAlpha(image,p)+0.5); 02321 *q|=((pixel & 0xf) << 0); 02322 p+=GetPixelChannels(image); 02323 q++; 02324 } 02325 break; 02326 } 02327 case 8: 02328 { 02329 register unsigned char 02330 pixel; 02331 02332 for (x=0; x < (ssize_t) number_pixels; x++) 02333 { 02334 q=PopCharPixel((unsigned char) GetPixelIndex(image,p),q); 02335 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p)); 02336 q=PopCharPixel(pixel,q); 02337 p+=GetPixelChannels(image); 02338 q+=quantum_info->pad; 02339 } 02340 break; 02341 } 02342 case 16: 02343 { 02344 register unsigned short 02345 pixel; 02346 02347 if (quantum_info->format == FloatingPointQuantumFormat) 02348 { 02349 for (x=0; x < (ssize_t) number_pixels; x++) 02350 { 02351 q=PopShortPixel(quantum_info->endian,(unsigned short) 02352 GetPixelIndex(image,p),q); 02353 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelAlpha(image,p)); 02354 q=PopShortPixel(quantum_info->endian,pixel,q); 02355 p+=GetPixelChannels(image); 02356 q+=quantum_info->pad; 02357 } 02358 break; 02359 } 02360 for (x=0; x < (ssize_t) number_pixels; x++) 02361 { 02362 q=PopShortPixel(quantum_info->endian,(unsigned short) 02363 GetPixelIndex(image,p),q); 02364 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p)); 02365 q=PopShortPixel(quantum_info->endian,pixel,q); 02366 p+=GetPixelChannels(image); 02367 q+=quantum_info->pad; 02368 } 02369 break; 02370 } 02371 case 32: 02372 { 02373 register unsigned int 02374 pixel; 02375 02376 if (quantum_info->format == FloatingPointQuantumFormat) 02377 { 02378 for (x=0; x < (ssize_t) number_pixels; x++) 02379 { 02380 float 02381 pixel; 02382 02383 q=PopFloatPixel(quantum_info,(float) GetPixelIndex(image,p),q); 02384 pixel=(float) GetPixelAlpha(image,p); 02385 q=PopFloatPixel(quantum_info,pixel,q); 02386 p+=GetPixelChannels(image); 02387 q+=quantum_info->pad; 02388 } 02389 break; 02390 } 02391 for (x=0; x < (ssize_t) number_pixels; x++) 02392 { 02393 q=PopLongPixel(quantum_info->endian,(unsigned int) 02394 GetPixelIndex(image,p),q); 02395 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p)); 02396 q=PopLongPixel(quantum_info->endian,pixel,q); 02397 p+=GetPixelChannels(image); 02398 q+=quantum_info->pad; 02399 } 02400 break; 02401 } 02402 case 64: 02403 { 02404 if (quantum_info->format == FloatingPointQuantumFormat) 02405 { 02406 for (x=0; x < (ssize_t) number_pixels; x++) 02407 { 02408 double 02409 pixel; 02410 02411 q=PopDoublePixel(quantum_info,(double) GetPixelIndex(image,p),q); 02412 pixel=(double) GetPixelAlpha(image,p); 02413 q=PopDoublePixel(quantum_info,pixel,q); 02414 p+=GetPixelChannels(image); 02415 q+=quantum_info->pad; 02416 } 02417 break; 02418 } 02419 } 02420 default: 02421 { 02422 QuantumAny 02423 range; 02424 02425 range=GetQuantumRange(quantum_info->depth); 02426 for (x=0; x < (ssize_t) number_pixels; x++) 02427 { 02428 q=PopQuantumPixel(quantum_info,GetPixelIndex(image,p),q); 02429 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p), 02430 range),q); 02431 p+=GetPixelChannels(image); 02432 q+=quantum_info->pad; 02433 } 02434 break; 02435 } 02436 } 02437 } 02438 02439 static void ExportOpacityQuantum(const Image *image,QuantumInfo *quantum_info, 02440 const MagickSizeType number_pixels,const Quantum *restrict p, 02441 unsigned char *restrict q,ExceptionInfo *exception) 02442 { 02443 QuantumAny 02444 range; 02445 02446 register ssize_t 02447 x; 02448 02449 switch (quantum_info->depth) 02450 { 02451 case 8: 02452 { 02453 register unsigned char 02454 pixel; 02455 02456 for (x=0; x < (ssize_t) number_pixels; x++) 02457 { 02458 pixel=ScaleQuantumToChar(GetPixelOpacity(image,p)); 02459 q=PopCharPixel(pixel,q); 02460 p+=GetPixelChannels(image); 02461 q+=quantum_info->pad; 02462 } 02463 break; 02464 } 02465 case 16: 02466 { 02467 register unsigned short 02468 pixel; 02469 02470 if (quantum_info->format == FloatingPointQuantumFormat) 02471 { 02472 for (x=0; x < (ssize_t) number_pixels; x++) 02473 { 02474 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelOpacity(image,p)); 02475 q=PopShortPixel(quantum_info->endian,pixel,q); 02476 p+=GetPixelChannels(image); 02477 q+=quantum_info->pad; 02478 } 02479 break; 02480 } 02481 for (x=0; x < (ssize_t) number_pixels; x++) 02482 { 02483 pixel=ScaleQuantumToShort(GetPixelOpacity(image,p)); 02484 q=PopShortPixel(quantum_info->endian,pixel,q); 02485 p+=GetPixelChannels(image); 02486 q+=quantum_info->pad; 02487 } 02488 break; 02489 } 02490 case 32: 02491 { 02492 register unsigned int 02493 pixel; 02494 02495 if (quantum_info->format == FloatingPointQuantumFormat) 02496 { 02497 for (x=0; x < (ssize_t) number_pixels; x++) 02498 { 02499 q=PopFloatPixel(quantum_info,(float) GetPixelOpacity(image,p),q); 02500 p+=GetPixelChannels(image); 02501 q+=quantum_info->pad; 02502 } 02503 break; 02504 } 02505 for (x=0; x < (ssize_t) number_pixels; x++) 02506 { 02507 pixel=ScaleQuantumToLong(GetPixelOpacity(image,p)); 02508 q=PopLongPixel(quantum_info->endian,pixel,q); 02509 p+=GetPixelChannels(image); 02510 q+=quantum_info->pad; 02511 } 02512 break; 02513 } 02514 case 64: 02515 { 02516 if (quantum_info->format == FloatingPointQuantumFormat) 02517 { 02518 for (x=0; x < (ssize_t) number_pixels; x++) 02519 { 02520 q=PopDoublePixel(quantum_info,(double) GetPixelOpacity(image,p),q); 02521 p+=GetPixelChannels(image); 02522 q+=quantum_info->pad; 02523 } 02524 break; 02525 } 02526 } 02527 default: 02528 { 02529 range=GetQuantumRange(quantum_info->depth); 02530 for (x=0; x < (ssize_t) number_pixels; x++) 02531 { 02532 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny( 02533 GetPixelOpacity(image,p),range),q); 02534 p+=GetPixelChannels(image); 02535 q+=quantum_info->pad; 02536 } 02537 break; 02538 } 02539 } 02540 } 02541 02542 static void ExportRedQuantum(const Image *image,QuantumInfo *quantum_info, 02543 const MagickSizeType number_pixels,const Quantum *restrict p, 02544 unsigned char *restrict q,ExceptionInfo *exception) 02545 { 02546 QuantumAny 02547 range; 02548 02549 register ssize_t 02550 x; 02551 02552 switch (quantum_info->depth) 02553 { 02554 case 8: 02555 { 02556 register unsigned char 02557 pixel; 02558 02559 for (x=0; x < (ssize_t) number_pixels; x++) 02560 { 02561 pixel=ScaleQuantumToChar(GetPixelRed(image,p)); 02562 q=PopCharPixel(pixel,q); 02563 p+=GetPixelChannels(image); 02564 q+=quantum_info->pad; 02565 } 02566 break; 02567 } 02568 case 16: 02569 { 02570 register unsigned short 02571 pixel; 02572 02573 if (quantum_info->format == FloatingPointQuantumFormat) 02574 { 02575 for (x=0; x < (ssize_t) number_pixels; x++) 02576 { 02577 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelRed(image,p)); 02578 q=PopShortPixel(quantum_info->endian,pixel,q); 02579 p+=GetPixelChannels(image); 02580 q+=quantum_info->pad; 02581 } 02582 break; 02583 } 02584 for (x=0; x < (ssize_t) number_pixels; x++) 02585 { 02586 pixel=ScaleQuantumToShort(GetPixelRed(image,p)); 02587 q=PopShortPixel(quantum_info->endian,pixel,q); 02588 p+=GetPixelChannels(image); 02589 q+=quantum_info->pad; 02590 } 02591 break; 02592 } 02593 case 32: 02594 { 02595 register unsigned int 02596 pixel; 02597 02598 if (quantum_info->format == FloatingPointQuantumFormat) 02599 { 02600 for (x=0; x < (ssize_t) number_pixels; x++) 02601 { 02602 q=PopFloatPixel(quantum_info,(float) GetPixelRed(image,p),q); 02603 p+=GetPixelChannels(image); 02604 q+=quantum_info->pad; 02605 } 02606 break; 02607 } 02608 for (x=0; x < (ssize_t) number_pixels; x++) 02609 { 02610 pixel=ScaleQuantumToLong(GetPixelRed(image,p)); 02611 q=PopLongPixel(quantum_info->endian,pixel,q); 02612 p+=GetPixelChannels(image); 02613 q+=quantum_info->pad; 02614 } 02615 break; 02616 } 02617 case 64: 02618 { 02619 if (quantum_info->format == FloatingPointQuantumFormat) 02620 { 02621 for (x=0; x < (ssize_t) number_pixels; x++) 02622 { 02623 q=PopDoublePixel(quantum_info,(double) GetPixelRed(image,p),q); 02624 p+=GetPixelChannels(image); 02625 q+=quantum_info->pad; 02626 } 02627 break; 02628 } 02629 } 02630 default: 02631 { 02632 range=GetQuantumRange(quantum_info->depth); 02633 for (x=0; x < (ssize_t) number_pixels; x++) 02634 { 02635 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p), 02636 range),q); 02637 p+=GetPixelChannels(image); 02638 q+=quantum_info->pad; 02639 } 02640 break; 02641 } 02642 } 02643 } 02644 02645 static void ExportRGBQuantum(const Image *image,QuantumInfo *quantum_info, 02646 const MagickSizeType number_pixels,const Quantum *restrict p, 02647 unsigned char *restrict q,ExceptionInfo *exception) 02648 { 02649 QuantumAny 02650 range; 02651 02652 register ssize_t 02653 x; 02654 02655 ssize_t 02656 bit; 02657 02658 switch (quantum_info->depth) 02659 { 02660 case 8: 02661 { 02662 for (x=0; x < (ssize_t) number_pixels; x++) 02663 { 02664 q=PopCharPixel(ScaleQuantumToChar(GetPixelRed(image,p)),q); 02665 q=PopCharPixel(ScaleQuantumToChar(GetPixelGreen(image,p)),q); 02666 q=PopCharPixel(ScaleQuantumToChar(GetPixelBlue(image,p)),q); 02667 p+=GetPixelChannels(image); 02668 q+=quantum_info->pad; 02669 } 02670 break; 02671 } 02672 case 10: 02673 { 02674 register unsigned int 02675 pixel; 02676 02677 range=GetQuantumRange(quantum_info->depth); 02678 if (quantum_info->pack == MagickFalse) 02679 { 02680 for (x=0; x < (ssize_t) number_pixels; x++) 02681 { 02682 pixel=(unsigned int) ( 02683 ScaleQuantumToAny(GetPixelRed(image,p),range) << 22 | 02684 ScaleQuantumToAny(GetPixelGreen(image,p),range) << 12 | 02685 ScaleQuantumToAny(GetPixelBlue(image,p),range) << 2); 02686 q=PopLongPixel(quantum_info->endian,pixel,q); 02687 p+=GetPixelChannels(image); 02688 q+=quantum_info->pad; 02689 } 02690 break; 02691 } 02692 if (quantum_info->quantum == 32UL) 02693 { 02694 for (x=0; x < (ssize_t) number_pixels; x++) 02695 { 02696 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); 02697 q=PopQuantumLongPixel(quantum_info,pixel,q); 02698 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), 02699 range); 02700 q=PopQuantumLongPixel(quantum_info,pixel,q); 02701 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); 02702 q=PopQuantumLongPixel(quantum_info,pixel,q); 02703 p+=GetPixelChannels(image); 02704 q+=quantum_info->pad; 02705 } 02706 break; 02707 } 02708 for (x=0; x < (ssize_t) number_pixels; x++) 02709 { 02710 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); 02711 q=PopQuantumPixel(quantum_info,pixel,q); 02712 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range); 02713 q=PopQuantumPixel(quantum_info,pixel,q); 02714 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); 02715 q=PopQuantumPixel(quantum_info,pixel,q); 02716 p+=GetPixelChannels(image); 02717 q+=quantum_info->pad; 02718 } 02719 break; 02720 } 02721 case 12: 02722 { 02723 register unsigned int 02724 pixel; 02725 02726 range=GetQuantumRange(quantum_info->depth); 02727 if (quantum_info->pack == MagickFalse) 02728 { 02729 for (x=0; x < (ssize_t) (3*number_pixels-1); x+=2) 02730 { 02731 switch (x % 3) 02732 { 02733 default: 02734 case 0: 02735 { 02736 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p), 02737 range); 02738 break; 02739 } 02740 case 1: 02741 { 02742 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), 02743 range); 02744 break; 02745 } 02746 case 2: 02747 { 02748 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p), 02749 range); 02750 p+=GetPixelChannels(image); 02751 break; 02752 } 02753 } 02754 q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel << 4), 02755 q); 02756 switch ((x+1) % 3) 02757 { 02758 default: 02759 case 0: 02760 { 02761 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p), 02762 range); 02763 break; 02764 } 02765 case 1: 02766 { 02767 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), 02768 range); 02769 break; 02770 } 02771 case 2: 02772 { 02773 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p), 02774 range); 02775 p+=GetPixelChannels(image); 02776 break; 02777 } 02778 } 02779 q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel << 4), 02780 q); 02781 q+=quantum_info->pad; 02782 } 02783 for (bit=0; bit < (ssize_t) (3*number_pixels % 2); bit++) 02784 { 02785 switch ((x+bit) % 3) 02786 { 02787 default: 02788 case 0: 02789 { 02790 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p), 02791 range); 02792 break; 02793 } 02794 case 1: 02795 { 02796 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), 02797 range); 02798 break; 02799 } 02800 case 2: 02801 { 02802 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p), 02803 range); 02804 p+=GetPixelChannels(image); 02805 break; 02806 } 02807 } 02808 q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel << 4), 02809 q); 02810 q+=quantum_info->pad; 02811 } 02812 if (bit != 0) 02813 p+=GetPixelChannels(image); 02814 break; 02815 } 02816 if (quantum_info->quantum == 32UL) 02817 { 02818 for (x=0; x < (ssize_t) number_pixels; x++) 02819 { 02820 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); 02821 q=PopQuantumLongPixel(quantum_info,pixel,q); 02822 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), 02823 range); 02824 q=PopQuantumLongPixel(quantum_info,pixel,q); 02825 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); 02826 q=PopQuantumLongPixel(quantum_info,pixel,q); 02827 p+=GetPixelChannels(image); 02828 q+=quantum_info->pad; 02829 } 02830 break; 02831 } 02832 for (x=0; x < (ssize_t) number_pixels; x++) 02833 { 02834 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); 02835 q=PopQuantumPixel(quantum_info,pixel,q); 02836 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range); 02837 q=PopQuantumPixel(quantum_info,pixel,q); 02838 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); 02839 q=PopQuantumPixel(quantum_info,pixel,q); 02840 p+=GetPixelChannels(image); 02841 q+=quantum_info->pad; 02842 } 02843 break; 02844 } 02845 case 16: 02846 { 02847 register unsigned short 02848 pixel; 02849 02850 if (quantum_info->format == FloatingPointQuantumFormat) 02851 { 02852 for (x=0; x < (ssize_t) number_pixels; x++) 02853 { 02854 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelRed(image,p)); 02855 q=PopShortPixel(quantum_info->endian,pixel,q); 02856 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelGreen(image,p)); 02857 q=PopShortPixel(quantum_info->endian,pixel,q); 02858 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlue(image,p)); 02859 q=PopShortPixel(quantum_info->endian,pixel,q); 02860 p+=GetPixelChannels(image); 02861 q+=quantum_info->pad; 02862 } 02863 break; 02864 } 02865 for (x=0; x < (ssize_t) number_pixels; x++) 02866 { 02867 pixel=ScaleQuantumToShort(GetPixelRed(image,p)); 02868 q=PopShortPixel(quantum_info->endian,pixel,q); 02869 pixel=ScaleQuantumToShort(GetPixelGreen(image,p)); 02870 q=PopShortPixel(quantum_info->endian,pixel,q); 02871 pixel=ScaleQuantumToShort(GetPixelBlue(image,p)); 02872 q=PopShortPixel(quantum_info->endian,pixel,q); 02873 p+=GetPixelChannels(image); 02874 q+=quantum_info->pad; 02875 } 02876 break; 02877 } 02878 case 32: 02879 { 02880 register unsigned int 02881 pixel; 02882 02883 if (quantum_info->format == FloatingPointQuantumFormat) 02884 { 02885 for (x=0; x < (ssize_t) number_pixels; x++) 02886 { 02887 q=PopFloatPixel(quantum_info,(float) GetPixelRed(image,p),q); 02888 q=PopFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q); 02889 q=PopFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q); 02890 p+=GetPixelChannels(image); 02891 q+=quantum_info->pad; 02892 } 02893 break; 02894 } 02895 for (x=0; x < (ssize_t) number_pixels; x++) 02896 { 02897 pixel=ScaleQuantumToLong(GetPixelRed(image,p)); 02898 q=PopLongPixel(quantum_info->endian,pixel,q); 02899 pixel=ScaleQuantumToLong(GetPixelGreen(image,p)); 02900 q=PopLongPixel(quantum_info->endian,pixel,q); 02901 pixel=ScaleQuantumToLong(GetPixelBlue(image,p)); 02902 q=PopLongPixel(quantum_info->endian,pixel,q); 02903 p+=GetPixelChannels(image); 02904 q+=quantum_info->pad; 02905 } 02906 break; 02907 } 02908 case 64: 02909 { 02910 if (quantum_info->format == FloatingPointQuantumFormat) 02911 { 02912 for (x=0; x < (ssize_t) number_pixels; x++) 02913 { 02914 q=PopDoublePixel(quantum_info,(double) GetPixelRed(image,p),q); 02915 q=PopDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q); 02916 q=PopDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q); 02917 p+=GetPixelChannels(image); 02918 q+=quantum_info->pad; 02919 } 02920 break; 02921 } 02922 } 02923 default: 02924 { 02925 range=GetQuantumRange(quantum_info->depth); 02926 for (x=0; x < (ssize_t) number_pixels; x++) 02927 { 02928 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p), 02929 range),q); 02930 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p), 02931 range),q); 02932 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p), 02933 range),q); 02934 p+=GetPixelChannels(image); 02935 q+=quantum_info->pad; 02936 } 02937 break; 02938 } 02939 } 02940 } 02941 02942 static void ExportRGBAQuantum(const Image *image,QuantumInfo *quantum_info, 02943 const MagickSizeType number_pixels,const Quantum *restrict p, 02944 unsigned char *restrict q,ExceptionInfo *exception) 02945 { 02946 QuantumAny 02947 range; 02948 02949 register ssize_t 02950 x; 02951 02952 switch (quantum_info->depth) 02953 { 02954 case 8: 02955 { 02956 register unsigned char 02957 pixel; 02958 02959 for (x=0; x < (ssize_t) number_pixels; x++) 02960 { 02961 pixel=ScaleQuantumToChar(GetPixelRed(image,p)); 02962 q=PopCharPixel(pixel,q); 02963 pixel=ScaleQuantumToChar(GetPixelGreen(image,p)); 02964 q=PopCharPixel(pixel,q); 02965 pixel=ScaleQuantumToChar(GetPixelBlue(image,p)); 02966 q=PopCharPixel(pixel,q); 02967 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p)); 02968 q=PopCharPixel(pixel,q); 02969 p+=GetPixelChannels(image); 02970 q+=quantum_info->pad; 02971 } 02972 break; 02973 } 02974 case 10: 02975 { 02976 register unsigned int 02977 pixel; 02978 02979 range=GetQuantumRange(quantum_info->depth); 02980 if (quantum_info->pack == MagickFalse) 02981 { 02982 register ssize_t 02983 i; 02984 02985 size_t 02986 quantum; 02987 02988 ssize_t 02989 n; 02990 02991 n=0; 02992 quantum=0; 02993 pixel=0; 02994 for (x=0; x < (ssize_t) number_pixels; x++) 02995 { 02996 for (i=0; i < 4; i++) 02997 { 02998 switch (i) 02999 { 03000 case 0: quantum=GetPixelRed(image,p); break; 03001 case 1: quantum=GetPixelGreen(image,p); break; 03002 case 2: quantum=GetPixelBlue(image,p); break; 03003 case 3: quantum=GetPixelAlpha(image,p); break; 03004 } 03005 switch (n % 3) 03006 { 03007 case 0: 03008 { 03009 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum, 03010 range) << 22); 03011 break; 03012 } 03013 case 1: 03014 { 03015 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum, 03016 range) << 12); 03017 break; 03018 } 03019 case 2: 03020 { 03021 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum, 03022 range) << 2); 03023 q=PopLongPixel(quantum_info->endian,pixel,q); 03024 pixel=0; 03025 break; 03026 } 03027 } 03028 n++; 03029 } 03030 p+=GetPixelChannels(image); 03031 q+=quantum_info->pad; 03032 } 03033 break; 03034 } 03035 if (quantum_info->quantum == 32UL) 03036 { 03037 for (x=0; x < (ssize_t) number_pixels; x++) 03038 { 03039 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); 03040 q=PopQuantumLongPixel(quantum_info,pixel,q); 03041 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), 03042 range); 03043 q=PopQuantumLongPixel(quantum_info,pixel,q); 03044 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); 03045 q=PopQuantumLongPixel(quantum_info,pixel,q); 03046 pixel=(unsigned int) ScaleQuantumToAny(GetPixelAlpha(image,p), 03047 range); 03048 q=PopQuantumLongPixel(quantum_info,pixel,q); 03049 p+=GetPixelChannels(image); 03050 q+=quantum_info->pad; 03051 } 03052 break; 03053 } 03054 for (x=0; x < (ssize_t) number_pixels; x++) 03055 { 03056 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); 03057 q=PopQuantumPixel(quantum_info,pixel,q); 03058 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range); 03059 q=PopQuantumPixel(quantum_info,pixel,q); 03060 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); 03061 q=PopQuantumPixel(quantum_info,pixel,q); 03062 pixel=(unsigned int) ScaleQuantumToAny(GetPixelAlpha(image,p),range); 03063 q=PopQuantumPixel(quantum_info,pixel,q); 03064 p+=GetPixelChannels(image); 03065 q+=quantum_info->pad; 03066 } 03067 break; 03068 } 03069 case 16: 03070 { 03071 register unsigned short 03072 pixel; 03073 03074 if (quantum_info->format == FloatingPointQuantumFormat) 03075 { 03076 for (x=0; x < (ssize_t) number_pixels; x++) 03077 { 03078 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelRed(image,p)); 03079 q=PopShortPixel(quantum_info->endian,pixel,q); 03080 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelGreen(image,p)); 03081 q=PopShortPixel(quantum_info->endian,pixel,q); 03082 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlue(image,p)); 03083 q=PopShortPixel(quantum_info->endian,pixel,q); 03084 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelAlpha(image,p)); 03085 q=PopShortPixel(quantum_info->endian,pixel,q); 03086 p+=GetPixelChannels(image); 03087 q+=quantum_info->pad; 03088 } 03089 break; 03090 } 03091 for (x=0; x < (ssize_t) number_pixels; x++) 03092 { 03093 pixel=ScaleQuantumToShort(GetPixelRed(image,p)); 03094 q=PopShortPixel(quantum_info->endian,pixel,q); 03095 pixel=ScaleQuantumToShort(GetPixelGreen(image,p)); 03096 q=PopShortPixel(quantum_info->endian,pixel,q); 03097 pixel=ScaleQuantumToShort(GetPixelBlue(image,p)); 03098 q=PopShortPixel(quantum_info->endian,pixel,q); 03099 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p)); 03100 q=PopShortPixel(quantum_info->endian,pixel,q); 03101 p+=GetPixelChannels(image); 03102 q+=quantum_info->pad; 03103 } 03104 break; 03105 } 03106 case 32: 03107 { 03108 register unsigned int 03109 pixel; 03110 03111 if (quantum_info->format == FloatingPointQuantumFormat) 03112 { 03113 for (x=0; x < (ssize_t) number_pixels; x++) 03114 { 03115 float 03116 pixel; 03117 03118 q=PopFloatPixel(quantum_info,(float) GetPixelRed(image,p),q); 03119 q=PopFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q); 03120 q=PopFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q); 03121 pixel=(float) GetPixelAlpha(image,p); 03122 q=PopFloatPixel(quantum_info,pixel,q); 03123 p+=GetPixelChannels(image); 03124 q+=quantum_info->pad; 03125 } 03126 break; 03127 } 03128 for (x=0; x < (ssize_t) number_pixels; x++) 03129 { 03130 pixel=ScaleQuantumToLong(GetPixelRed(image,p)); 03131 q=PopLongPixel(quantum_info->endian,pixel,q); 03132 pixel=ScaleQuantumToLong(GetPixelGreen(image,p)); 03133 q=PopLongPixel(quantum_info->endian,pixel,q); 03134 pixel=ScaleQuantumToLong(GetPixelBlue(image,p)); 03135 q=PopLongPixel(quantum_info->endian,pixel,q); 03136 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p)); 03137 q=PopLongPixel(quantum_info->endian,pixel,q); 03138 p+=GetPixelChannels(image); 03139 q+=quantum_info->pad; 03140 } 03141 break; 03142 } 03143 case 64: 03144 { 03145 if (quantum_info->format == FloatingPointQuantumFormat) 03146 { 03147 double 03148 pixel; 03149 03150 for (x=0; x < (ssize_t) number_pixels; x++) 03151 { 03152 q=PopDoublePixel(quantum_info,(double) GetPixelRed(image,p),q); 03153 q=PopDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q); 03154 q=PopDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q); 03155 pixel=(double) GetPixelAlpha(image,p); 03156 q=PopDoublePixel(quantum_info,pixel,q); 03157 p+=GetPixelChannels(image); 03158 q+=quantum_info->pad; 03159 } 03160 break; 03161 } 03162 } 03163 default: 03164 { 03165 range=GetQuantumRange(quantum_info->depth); 03166 for (x=0; x < (ssize_t) number_pixels; x++) 03167 { 03168 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p), 03169 range),q); 03170 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p), 03171 range),q); 03172 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p), 03173 range),q); 03174 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p), 03175 range),q); 03176 p+=GetPixelChannels(image); 03177 q+=quantum_info->pad; 03178 } 03179 break; 03180 } 03181 } 03182 } 03183 03184 MagickExport size_t ExportQuantumPixels(const Image *image, 03185 CacheView *image_view,QuantumInfo *quantum_info, 03186 const QuantumType quantum_type,unsigned char *pixels,ExceptionInfo *exception) 03187 { 03188 MagickSizeType 03189 number_pixels; 03190 03191 register const Quantum 03192 *restrict p; 03193 03194 register ssize_t 03195 x; 03196 03197 register unsigned char 03198 *restrict q; 03199 03200 size_t 03201 extent; 03202 03203 assert(image != (Image *) NULL); 03204 assert(image->signature == MagickSignature); 03205 if (image->debug != MagickFalse) 03206 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); 03207 assert(quantum_info != (QuantumInfo *) NULL); 03208 assert(quantum_info->signature == MagickSignature); 03209 if (pixels == (unsigned char *) NULL) 03210 pixels=GetQuantumPixels(quantum_info); 03211 if (image_view == (CacheView *) NULL) 03212 { 03213 number_pixels=GetImageExtent(image); 03214 p=GetVirtualPixelQueue(image); 03215 } 03216 else 03217 { 03218 number_pixels=GetCacheViewExtent(image_view); 03219 p=GetCacheViewVirtualPixelQueue(image_view); 03220 } 03221 if (quantum_info->alpha_type == AssociatedQuantumAlpha) 03222 { 03223 MagickRealType 03224 Sa; 03225 03226 register Quantum 03227 *restrict q; 03228 03229 /* 03230 Associate alpha. 03231 */ 03232 q=GetAuthenticPixelQueue(image); 03233 if (image_view != (CacheView *) NULL) 03234 q=GetCacheViewAuthenticPixelQueue(image_view); 03235 for (x=0; x < (ssize_t) image->columns; x++) 03236 { 03237 register ssize_t 03238 i; 03239 03240 if (GetPixelMask(image,q) != 0) 03241 { 03242 q+=GetPixelChannels(image); 03243 continue; 03244 } 03245 Sa=QuantumScale*GetPixelAlpha(image,q); 03246 for (i=0; i < (ssize_t) GetPixelChannels(image); i++) 03247 { 03248 PixelChannel 03249 channel; 03250 03251 PixelTrait 03252 traits; 03253 03254 channel=GetPixelChannelMapChannel(image,i); 03255 traits=GetPixelChannelMapTraits(image,channel); 03256 if ((traits & UpdatePixelTrait) == 0) 03257 continue; 03258 q[i]=ClampToQuantum(Sa*q[i]); 03259 } 03260 q+=GetPixelChannels(image); 03261 } 03262 } 03263 if ((quantum_type == RGBOQuantum) || (quantum_type == CMYKOQuantum) || 03264 (quantum_type == BGROQuantum)) 03265 { 03266 register Quantum 03267 *restrict q; 03268 03269 q=GetAuthenticPixelQueue(image); 03270 if (image_view != (CacheView *) NULL) 03271 q=GetCacheViewAuthenticPixelQueue(image_view); 03272 for (x=0; x < (ssize_t) number_pixels; x++) 03273 { 03274 SetPixelAlpha(image,GetPixelAlpha(image,q),q); 03275 q+=GetPixelChannels(image); 03276 } 03277 } 03278 if ((quantum_type == CbYCrQuantum) || (quantum_type == CbYCrAQuantum)) 03279 { 03280 Quantum 03281 quantum; 03282 03283 register Quantum 03284 *restrict q; 03285 03286 q=GetAuthenticPixelQueue(image); 03287 if (image_view != (CacheView *) NULL) 03288 q=GetAuthenticPixelQueue(image); 03289 for (x=0; x < (ssize_t) number_pixels; x++) 03290 { 03291 quantum=GetPixelRed(image,q); 03292 SetPixelRed(image,GetPixelGreen(image,q),q); 03293 SetPixelGreen(image,quantum,q); 03294 q+=GetPixelChannels(image); 03295 } 03296 } 03297 x=0; 03298 q=pixels; 03299 ResetQuantumState(quantum_info); 03300 extent=GetQuantumExtent(image,quantum_info,quantum_type); 03301 switch (quantum_type) 03302 { 03303 case AlphaQuantum: 03304 { 03305 ExportAlphaQuantum(image,quantum_info,number_pixels,p,q,exception); 03306 break; 03307 } 03308 case BGRQuantum: 03309 { 03310 ExportBGRQuantum(image,quantum_info,number_pixels,p,q,exception); 03311 break; 03312 } 03313 case BGRAQuantum: 03314 case BGROQuantum: 03315 { 03316 ExportBGRAQuantum(image,quantum_info,number_pixels,p,q,exception); 03317 break; 03318 } 03319 case BlackQuantum: 03320 { 03321 ExportBlackQuantum(image,quantum_info,number_pixels,p,q,exception); 03322 break; 03323 } 03324 case BlueQuantum: 03325 case YellowQuantum: 03326 { 03327 ExportBlueQuantum(image,quantum_info,number_pixels,p,q,exception); 03328 break; 03329 } 03330 case CMYKQuantum: 03331 { 03332 ExportCMYKQuantum(image,quantum_info,number_pixels,p,q,exception); 03333 break; 03334 } 03335 case CMYKAQuantum: 03336 case CMYKOQuantum: 03337 { 03338 ExportCMYKAQuantum(image,quantum_info,number_pixels,p,q,exception); 03339 break; 03340 } 03341 case CbYCrYQuantum: 03342 { 03343 ExportCbYCrYQuantum(image,quantum_info,number_pixels,p,q,exception); 03344 break; 03345 } 03346 case GrayQuantum: 03347 { 03348 ExportGrayQuantum(image,quantum_info,number_pixels,p,q,exception); 03349 break; 03350 } 03351 case GrayAlphaQuantum: 03352 { 03353 ExportGrayAlphaQuantum(image,quantum_info,number_pixels,p,q,exception); 03354 break; 03355 } 03356 case GreenQuantum: 03357 case MagentaQuantum: 03358 { 03359 ExportGreenQuantum(image,quantum_info,number_pixels,p,q,exception); 03360 break; 03361 } 03362 case IndexQuantum: 03363 { 03364 ExportIndexQuantum(image,quantum_info,number_pixels,p,q,exception); 03365 break; 03366 } 03367 case IndexAlphaQuantum: 03368 { 03369 ExportIndexAlphaQuantum(image,quantum_info,number_pixels,p,q,exception); 03370 break; 03371 } 03372 case RedQuantum: 03373 case CyanQuantum: 03374 { 03375 ExportRedQuantum(image,quantum_info,number_pixels,p,q,exception); 03376 break; 03377 } 03378 case OpacityQuantum: 03379 { 03380 ExportOpacityQuantum(image,quantum_info,number_pixels,p,q,exception); 03381 break; 03382 } 03383 case RGBQuantum: 03384 case CbYCrQuantum: 03385 { 03386 ExportRGBQuantum(image,quantum_info,number_pixels,p,q,exception); 03387 break; 03388 } 03389 case RGBAQuantum: 03390 case RGBOQuantum: 03391 case CbYCrAQuantum: 03392 { 03393 ExportRGBAQuantum(image,quantum_info,number_pixels,p,q,exception); 03394 break; 03395 } 03396 default: 03397 break; 03398 } 03399 if ((quantum_type == CbYCrQuantum) || (quantum_type == CbYCrAQuantum)) 03400 { 03401 Quantum 03402 quantum; 03403 03404 register Quantum 03405 *restrict q; 03406 03407 q=GetAuthenticPixelQueue(image); 03408 if (image_view != (CacheView *) NULL) 03409 q=GetCacheViewAuthenticPixelQueue(image_view); 03410 for (x=0; x < (ssize_t) number_pixels; x++) 03411 { 03412 quantum=GetPixelRed(image,q); 03413 SetPixelRed(image,GetPixelGreen(image,q),q); 03414 SetPixelGreen(image,quantum,q); 03415 q+=GetPixelChannels(image); 03416 } 03417 } 03418 if ((quantum_type == RGBOQuantum) || (quantum_type == CMYKOQuantum) || 03419 (quantum_type == BGROQuantum)) 03420 { 03421 register Quantum 03422 *restrict q; 03423 03424 q=GetAuthenticPixelQueue(image); 03425 if (image_view != (CacheView *) NULL) 03426 q=GetCacheViewAuthenticPixelQueue(image_view); 03427 for (x=0; x < (ssize_t) number_pixels; x++) 03428 { 03429 SetPixelAlpha(image,GetPixelAlpha(image,q),q); 03430 q+=GetPixelChannels(image); 03431 } 03432 } 03433 return(extent); 03434 }