quantum-export.c revision 32c6843b4cfe042747eff85b4a80ec119c77bdc8
1/* 2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3% % 4% % 5% % 6% QQQ U U AAA N N TTTTT U U M M % 7% Q Q U U A A NN N T U U MM MM % 8% Q Q U U AAAAA N N N T U U M M M % 9% Q QQ U U A A N NN T U U M M % 10% QQQQ UUU A A N N T UUU M M % 11% % 12% EEEEE X X PPPP OOO RRRR TTTTT % 13% E X X P P O O R R T % 14% EEE X PPPP O O RRRR T % 15% E X X P O O R R T % 16% EEEEE X X P OOO R R T % 17% % 18% MagickCore Methods to Export Quantum Pixels % 19% % 20% Software Design % 21% John Cristy % 22% October 1998 % 23% % 24% % 25% Copyright 1999-2008 ImageMagick Studio LLC, a non-profit organization % 26% dedicated to making software imaging solutions freely available. % 27% % 28% You may not use this file except in compliance with the License. You may % 29% obtain a copy of the License at % 30% % 31% http://www.imagemagick.org/script/license.php % 32% % 33% Unless required by applicable law or agreed to in writing, software % 34% distributed under the License is distributed on an "AS IS" BASIS, % 35% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % 36% See the License for the specific language governing permissions and % 37% limitations under the License. % 38% % 39%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 40% 41% 42*/ 43 44/* 45 Include declarations. 46*/ 47#include "MagickCore/studio.h" 48#include "MagickCore/property.h" 49#include "MagickCore/blob.h" 50#include "MagickCore/blob-private.h" 51#include "MagickCore/color-private.h" 52#include "MagickCore/exception.h" 53#include "MagickCore/exception-private.h" 54#include "MagickCore/cache.h" 55#include "MagickCore/constitute.h" 56#include "MagickCore/delegate.h" 57#include "MagickCore/geometry.h" 58#include "MagickCore/list.h" 59#include "MagickCore/magick.h" 60#include "MagickCore/memory_.h" 61#include "MagickCore/monitor.h" 62#include "MagickCore/option.h" 63#include "MagickCore/pixel.h" 64#include "MagickCore/pixel-accessor.h" 65#include "MagickCore/quantum.h" 66#include "MagickCore/quantum-private.h" 67#include "MagickCore/resource_.h" 68#include "MagickCore/semaphore.h" 69#include "MagickCore/statistic.h" 70#include "MagickCore/stream.h" 71#include "MagickCore/string_.h" 72#include "MagickCore/utility.h" 73 74/* 75%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 76% % 77% % 78% % 79+ E x p o r t Q u a n t u m P i x e l s % 80% % 81% % 82% % 83%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 84% 85% ExportQuantumPixels() transfers one or more pixel components from the image 86% pixel cache to a user supplied buffer. The pixels are returned in network 87% byte order. MagickTrue is returned if the pixels are successfully 88% transferred, otherwise MagickFalse. 89% 90% The format of the ExportQuantumPixels method is: 91% 92% size_t ExportQuantumPixels(const Image *image,CacheView *image_view, 93% QuantumInfo *quantum_info,const QuantumType quantum_type, 94% unsigned char *pixels,ExceptionInfo *exception) 95% 96% A description of each parameter follows: 97% 98% o image: the image. 99% 100% o image_view: the image cache view. 101% 102% o quantum_info: the quantum info. 103% 104% o quantum_type: Declare which pixel components to transfer (RGB, RGBA, 105% etc). 106% 107% o pixels: The components are transferred to this buffer. 108% 109% o exception: return any errors or warnings in this structure. 110% 111*/ 112 113static inline unsigned char *PopDoublePixel(QuantumInfo *quantum_info, 114 const double pixel,unsigned char *pixels) 115{ 116 double 117 *p; 118 119 unsigned char 120 quantum[8]; 121 122 p=(double *) quantum; 123 *p=(double) (pixel*quantum_info->state.inverse_scale+quantum_info->minimum); 124 if (quantum_info->endian != LSBEndian) 125 { 126 *pixels++=quantum[7]; 127 *pixels++=quantum[6]; 128 *pixels++=quantum[5]; 129 *pixels++=quantum[4]; 130 *pixels++=quantum[3]; 131 *pixels++=quantum[2]; 132 *pixels++=quantum[1]; 133 *pixels++=quantum[0]; 134 return(pixels); 135 } 136 *pixels++=quantum[0]; 137 *pixels++=quantum[1]; 138 *pixels++=quantum[2]; 139 *pixels++=quantum[3]; 140 *pixels++=quantum[4]; 141 *pixels++=quantum[5]; 142 *pixels++=quantum[6]; 143 *pixels++=quantum[7]; 144 return(pixels); 145} 146 147static inline unsigned char *PopFloatPixel(QuantumInfo *quantum_info, 148 const float pixel,unsigned char *pixels) 149{ 150 float 151 *p; 152 153 unsigned char 154 quantum[4]; 155 156 p=(float *) quantum; 157 *p=(float) ((double) pixel*quantum_info->state.inverse_scale+ 158 quantum_info->minimum); 159 if (quantum_info->endian != LSBEndian) 160 { 161 *pixels++=quantum[3]; 162 *pixels++=quantum[2]; 163 *pixels++=quantum[1]; 164 *pixels++=quantum[0]; 165 return(pixels); 166 } 167 *pixels++=quantum[0]; 168 *pixels++=quantum[1]; 169 *pixels++=quantum[2]; 170 *pixels++=quantum[3]; 171 return(pixels); 172} 173 174static inline unsigned char *PopQuantumPixel(QuantumInfo *quantum_info, 175 const QuantumAny pixel,unsigned char *pixels) 176{ 177 register ssize_t 178 i; 179 180 size_t 181 quantum_bits; 182 183 if (quantum_info->state.bits == 0UL) 184 quantum_info->state.bits=8U; 185 for (i=(ssize_t) quantum_info->depth; i > 0L; ) 186 { 187 quantum_bits=(size_t) i; 188 if (quantum_bits > quantum_info->state.bits) 189 quantum_bits=quantum_info->state.bits; 190 i-=(ssize_t) quantum_bits; 191 if (quantum_info->state.bits == 8UL) 192 *pixels='\0'; 193 quantum_info->state.bits-=quantum_bits; 194 *pixels|=(((pixel >> i) &~ ((~0UL) << quantum_bits)) << 195 quantum_info->state.bits); 196 if (quantum_info->state.bits == 0UL) 197 { 198 pixels++; 199 quantum_info->state.bits=8UL; 200 } 201 } 202 return(pixels); 203} 204 205static inline unsigned char *PopQuantumLongPixel(QuantumInfo *quantum_info, 206 const size_t pixel,unsigned char *pixels) 207{ 208 register ssize_t 209 i; 210 211 size_t 212 quantum_bits; 213 214 if (quantum_info->state.bits == 0U) 215 quantum_info->state.bits=32UL; 216 for (i=(ssize_t) quantum_info->depth; i > 0; ) 217 { 218 quantum_bits=(size_t) i; 219 if (quantum_bits > quantum_info->state.bits) 220 quantum_bits=quantum_info->state.bits; 221 quantum_info->state.pixel|=(((pixel >> (quantum_info->depth-i)) & 222 quantum_info->state.mask[quantum_bits]) << (32U- 223 quantum_info->state.bits)); 224 i-=(ssize_t) quantum_bits; 225 quantum_info->state.bits-=quantum_bits; 226 if (quantum_info->state.bits == 0U) 227 { 228 pixels=PopLongPixel(quantum_info->endian,quantum_info->state.pixel, 229 pixels); 230 quantum_info->state.pixel=0U; 231 quantum_info->state.bits=32U; 232 } 233 } 234 return(pixels); 235} 236 237static void ExportAlphaQuantum(const Image *image,QuantumInfo *quantum_info, 238 const MagickSizeType number_pixels,const Quantum *restrict p, 239 unsigned char *restrict q,ExceptionInfo *exception) 240{ 241 QuantumAny 242 range; 243 244 register ssize_t 245 x; 246 247 switch (quantum_info->depth) 248 { 249 case 8: 250 { 251 register unsigned char 252 pixel; 253 254 for (x=0; x < (ssize_t) number_pixels; x++) 255 { 256 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p)); 257 q=PopCharPixel(pixel,q); 258 p+=GetPixelChannels(image); 259 q+=quantum_info->pad; 260 } 261 break; 262 } 263 case 16: 264 { 265 register unsigned short 266 pixel; 267 268 if (quantum_info->format == FloatingPointQuantumFormat) 269 { 270 for (x=0; x < (ssize_t) number_pixels; x++) 271 { 272 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelAlpha(image,p)); 273 q=PopShortPixel(quantum_info->endian,pixel,q); 274 p+=GetPixelChannels(image); 275 q+=quantum_info->pad; 276 } 277 break; 278 } 279 for (x=0; x < (ssize_t) number_pixels; x++) 280 { 281 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p)); 282 q=PopShortPixel(quantum_info->endian,pixel,q); 283 p+=GetPixelChannels(image); 284 q+=quantum_info->pad; 285 } 286 break; 287 } 288 case 32: 289 { 290 register unsigned int 291 pixel; 292 293 if (quantum_info->format == FloatingPointQuantumFormat) 294 { 295 for (x=0; x < (ssize_t) number_pixels; x++) 296 { 297 q=PopFloatPixel(quantum_info,(float) GetPixelAlpha(image,p),q); 298 p+=GetPixelChannels(image); 299 q+=quantum_info->pad; 300 } 301 break; 302 } 303 for (x=0; x < (ssize_t) number_pixels; x++) 304 { 305 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p)); 306 q=PopLongPixel(quantum_info->endian,pixel,q); 307 p+=GetPixelChannels(image); 308 q+=quantum_info->pad; 309 } 310 break; 311 } 312 case 64: 313 { 314 if (quantum_info->format == FloatingPointQuantumFormat) 315 { 316 for (x=0; x < (ssize_t) number_pixels; x++) 317 { 318 q=PopDoublePixel(quantum_info,(double) GetPixelAlpha(image,p),q); 319 p+=GetPixelChannels(image); 320 q+=quantum_info->pad; 321 } 322 break; 323 } 324 } 325 default: 326 { 327 range=GetQuantumRange(quantum_info->depth); 328 for (x=0; x < (ssize_t) number_pixels; x++) 329 { 330 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p), 331 range),q); 332 p+=GetPixelChannels(image); 333 q+=quantum_info->pad; 334 } 335 break; 336 } 337 } 338} 339 340static void ExportBGRQuantum(const Image *image,QuantumInfo *quantum_info, 341 const MagickSizeType number_pixels,const Quantum *restrict p, 342 unsigned char *restrict q,ExceptionInfo *exception) 343{ 344 QuantumAny 345 range; 346 347 register ssize_t 348 x; 349 350 ssize_t 351 bit; 352 353 switch (quantum_info->depth) 354 { 355 case 8: 356 { 357 for (x=0; x < (ssize_t) number_pixels; x++) 358 { 359 q=PopCharPixel(ScaleQuantumToChar(GetPixelBlue(image,p)),q); 360 q=PopCharPixel(ScaleQuantumToChar(GetPixelGreen(image,p)),q); 361 q=PopCharPixel(ScaleQuantumToChar(GetPixelRed(image,p)),q); 362 p+=GetPixelChannels(image); 363 q+=quantum_info->pad; 364 } 365 break; 366 } 367 case 10: 368 { 369 register unsigned int 370 pixel; 371 372 range=GetQuantumRange(quantum_info->depth); 373 if (quantum_info->pack == MagickFalse) 374 { 375 for (x=0; x < (ssize_t) number_pixels; x++) 376 { 377 pixel=(unsigned int) ( 378 ScaleQuantumToAny(GetPixelRed(image,p),range) << 22 | 379 ScaleQuantumToAny(GetPixelGreen(image,p),range) << 12 | 380 ScaleQuantumToAny(GetPixelBlue(image,p),range) << 2); 381 q=PopLongPixel(quantum_info->endian,pixel,q); 382 p+=GetPixelChannels(image); 383 q+=quantum_info->pad; 384 } 385 break; 386 } 387 if (quantum_info->quantum == 32UL) 388 { 389 for (x=0; x < (ssize_t) number_pixels; x++) 390 { 391 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); 392 q=PopQuantumLongPixel(quantum_info,pixel,q); 393 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), 394 range); 395 q=PopQuantumLongPixel(quantum_info,pixel,q); 396 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); 397 q=PopQuantumLongPixel(quantum_info,pixel,q); 398 p+=GetPixelChannels(image); 399 q+=quantum_info->pad; 400 } 401 break; 402 } 403 for (x=0; x < (ssize_t) number_pixels; x++) 404 { 405 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); 406 q=PopQuantumPixel(quantum_info,pixel,q); 407 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range); 408 q=PopQuantumPixel(quantum_info,pixel,q); 409 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); 410 q=PopQuantumPixel(quantum_info,pixel,q); 411 p+=GetPixelChannels(image); 412 q+=quantum_info->pad; 413 } 414 break; 415 } 416 case 12: 417 { 418 register unsigned int 419 pixel; 420 421 range=GetQuantumRange(quantum_info->depth); 422 if (quantum_info->pack == MagickFalse) 423 { 424 for (x=0; x < (ssize_t) (3*number_pixels-1); x+=2) 425 { 426 switch (x % 3) 427 { 428 default: 429 case 0: 430 { 431 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p), 432 range); 433 break; 434 } 435 case 1: 436 { 437 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), 438 range); 439 break; 440 } 441 case 2: 442 { 443 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p), 444 range); 445 p+=GetPixelChannels(image); 446 break; 447 } 448 } 449 q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel << 4),q); 450 switch ((x+1) % 3) 451 { 452 default: 453 case 0: 454 { 455 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p), 456 range); 457 break; 458 } 459 case 1: 460 { 461 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), 462 range); 463 break; 464 } 465 case 2: 466 { 467 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p), 468 range); 469 p+=GetPixelChannels(image); 470 break; 471 } 472 } 473 q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel << 4),q); 474 q+=quantum_info->pad; 475 } 476 for (bit=0; bit < (ssize_t) (3*number_pixels % 2); bit++) 477 { 478 switch ((x+bit) % 3) 479 { 480 default: 481 case 0: 482 { 483 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p), 484 range); 485 break; 486 } 487 case 1: 488 { 489 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), 490 range); 491 break; 492 } 493 case 2: 494 { 495 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p), 496 range); 497 p+=GetPixelChannels(image); 498 break; 499 } 500 } 501 q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel << 4),q); 502 q+=quantum_info->pad; 503 } 504 if (bit != 0) 505 p+=GetPixelChannels(image); 506 break; 507 } 508 if (quantum_info->quantum == 32UL) 509 { 510 for (x=0; x < (ssize_t) number_pixels; x++) 511 { 512 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); 513 q=PopQuantumLongPixel(quantum_info,pixel,q); 514 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), 515 range); 516 q=PopQuantumLongPixel(quantum_info,pixel,q); 517 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); 518 q=PopQuantumLongPixel(quantum_info,pixel,q); 519 p+=GetPixelChannels(image); 520 q+=quantum_info->pad; 521 } 522 break; 523 } 524 for (x=0; x < (ssize_t) number_pixels; x++) 525 { 526 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); 527 q=PopQuantumPixel(quantum_info,pixel,q); 528 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range); 529 q=PopQuantumPixel(quantum_info,pixel,q); 530 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); 531 q=PopQuantumPixel(quantum_info,pixel,q); 532 p+=GetPixelChannels(image); 533 q+=quantum_info->pad; 534 } 535 break; 536 } 537 case 16: 538 { 539 register unsigned short 540 pixel; 541 542 if (quantum_info->format == FloatingPointQuantumFormat) 543 { 544 for (x=0; x < (ssize_t) number_pixels; x++) 545 { 546 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlue(image,p)); 547 q=PopShortPixel(quantum_info->endian,pixel,q); 548 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelGreen(image,p)); 549 q=PopShortPixel(quantum_info->endian,pixel,q); 550 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelRed(image,p)); 551 q=PopShortPixel(quantum_info->endian,pixel,q); 552 p+=GetPixelChannels(image); 553 q+=quantum_info->pad; 554 } 555 break; 556 } 557 for (x=0; x < (ssize_t) number_pixels; x++) 558 { 559 pixel=ScaleQuantumToShort(GetPixelBlue(image,p)); 560 q=PopShortPixel(quantum_info->endian,pixel,q); 561 pixel=ScaleQuantumToShort(GetPixelGreen(image,p)); 562 q=PopShortPixel(quantum_info->endian,pixel,q); 563 pixel=ScaleQuantumToShort(GetPixelRed(image,p)); 564 q=PopShortPixel(quantum_info->endian,pixel,q); 565 p+=GetPixelChannels(image); 566 q+=quantum_info->pad; 567 } 568 break; 569 } 570 case 32: 571 { 572 register unsigned int 573 pixel; 574 575 if (quantum_info->format == FloatingPointQuantumFormat) 576 { 577 for (x=0; x < (ssize_t) number_pixels; x++) 578 { 579 q=PopFloatPixel(quantum_info,(float) GetPixelRed(image,p),q); 580 q=PopFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q); 581 q=PopFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q); 582 p+=GetPixelChannels(image); 583 q+=quantum_info->pad; 584 } 585 break; 586 } 587 for (x=0; x < (ssize_t) number_pixels; x++) 588 { 589 pixel=ScaleQuantumToLong(GetPixelBlue(image,p)); 590 q=PopLongPixel(quantum_info->endian,pixel,q); 591 pixel=ScaleQuantumToLong(GetPixelGreen(image,p)); 592 q=PopLongPixel(quantum_info->endian,pixel,q); 593 pixel=ScaleQuantumToLong(GetPixelRed(image,p)); 594 q=PopLongPixel(quantum_info->endian,pixel,q); 595 p+=GetPixelChannels(image); 596 q+=quantum_info->pad; 597 } 598 break; 599 } 600 case 64: 601 { 602 if (quantum_info->format == FloatingPointQuantumFormat) 603 { 604 for (x=0; x < (ssize_t) number_pixels; x++) 605 { 606 q=PopDoublePixel(quantum_info,(double) GetPixelRed(image,p),q); 607 q=PopDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q); 608 q=PopDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q); 609 p+=GetPixelChannels(image); 610 q+=quantum_info->pad; 611 } 612 break; 613 } 614 } 615 default: 616 { 617 range=GetQuantumRange(quantum_info->depth); 618 for (x=0; x < (ssize_t) number_pixels; x++) 619 { 620 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p), 621 range),q); 622 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p), 623 range),q); 624 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p), 625 range),q); 626 p+=GetPixelChannels(image); 627 q+=quantum_info->pad; 628 } 629 break; 630 } 631 } 632} 633 634static void ExportBGRAQuantum(const Image *image,QuantumInfo *quantum_info, 635 const MagickSizeType number_pixels,const Quantum *restrict p, 636 unsigned char *restrict q,ExceptionInfo *exception) 637{ 638 QuantumAny 639 range; 640 641 register ssize_t 642 x; 643 644 switch (quantum_info->depth) 645 { 646 case 8: 647 { 648 register unsigned char 649 pixel; 650 651 for (x=0; x < (ssize_t) number_pixels; x++) 652 { 653 pixel=ScaleQuantumToChar(GetPixelBlue(image,p)); 654 q=PopCharPixel(pixel,q); 655 pixel=ScaleQuantumToChar(GetPixelGreen(image,p)); 656 q=PopCharPixel(pixel,q); 657 pixel=ScaleQuantumToChar(GetPixelRed(image,p)); 658 q=PopCharPixel(pixel,q); 659 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p)); 660 q=PopCharPixel(pixel,q); 661 p+=GetPixelChannels(image); 662 q+=quantum_info->pad; 663 } 664 break; 665 } 666 case 10: 667 { 668 register unsigned int 669 pixel; 670 671 range=GetQuantumRange(quantum_info->depth); 672 if (quantum_info->pack == MagickFalse) 673 { 674 register ssize_t 675 i; 676 677 size_t 678 quantum; 679 680 ssize_t 681 n; 682 683 n=0; 684 quantum=0; 685 pixel=0; 686 for (x=0; x < (ssize_t) number_pixels; x++) 687 { 688 for (i=0; i < 4; i++) 689 { 690 switch (i) 691 { 692 case 0: quantum=GetPixelRed(image,p); break; 693 case 1: quantum=GetPixelGreen(image,p); break; 694 case 2: quantum=GetPixelBlue(image,p); break; 695 case 3: quantum=GetPixelAlpha(image,p); break; 696 } 697 switch (n % 3) 698 { 699 case 0: 700 { 701 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum, 702 range) << 22); 703 break; 704 } 705 case 1: 706 { 707 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum, 708 range) << 12); 709 break; 710 } 711 case 2: 712 { 713 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum, 714 range) << 2); 715 q=PopLongPixel(quantum_info->endian,pixel,q); 716 pixel=0; 717 break; 718 } 719 } 720 n++; 721 } 722 p+=GetPixelChannels(image); 723 q+=quantum_info->pad; 724 } 725 break; 726 } 727 if (quantum_info->quantum == 32UL) 728 { 729 for (x=0; x < (ssize_t) number_pixels; x++) 730 { 731 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); 732 q=PopQuantumLongPixel(quantum_info,pixel,q); 733 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), 734 range); 735 q=PopQuantumLongPixel(quantum_info,pixel,q); 736 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); 737 q=PopQuantumLongPixel(quantum_info,pixel,q); 738 pixel=(unsigned int) ScaleQuantumToAny(GetPixelAlpha(image,p), 739 range); 740 q=PopQuantumLongPixel(quantum_info,pixel,q); 741 p+=GetPixelChannels(image); 742 q+=quantum_info->pad; 743 } 744 break; 745 } 746 for (x=0; x < (ssize_t) number_pixels; x++) 747 { 748 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); 749 q=PopQuantumPixel(quantum_info,pixel,q); 750 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range); 751 q=PopQuantumPixel(quantum_info,pixel,q); 752 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); 753 q=PopQuantumPixel(quantum_info,pixel,q); 754 pixel=(unsigned int) ScaleQuantumToAny(GetPixelAlpha(image,p),range); 755 q=PopQuantumPixel(quantum_info,pixel,q); 756 p+=GetPixelChannels(image); 757 q+=quantum_info->pad; 758 } 759 break; 760 } 761 case 16: 762 { 763 register unsigned short 764 pixel; 765 766 if (quantum_info->format == FloatingPointQuantumFormat) 767 { 768 for (x=0; x < (ssize_t) number_pixels; x++) 769 { 770 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlue(image,p)); 771 q=PopShortPixel(quantum_info->endian,pixel,q); 772 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelGreen(image,p)); 773 q=PopShortPixel(quantum_info->endian,pixel,q); 774 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelRed(image,p)); 775 q=PopShortPixel(quantum_info->endian,pixel,q); 776 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelAlpha(image,p)); 777 q=PopShortPixel(quantum_info->endian,pixel,q); 778 p+=GetPixelChannels(image); 779 q+=quantum_info->pad; 780 } 781 break; 782 } 783 for (x=0; x < (ssize_t) number_pixels; x++) 784 { 785 pixel=ScaleQuantumToShort(GetPixelBlue(image,p)); 786 q=PopShortPixel(quantum_info->endian,pixel,q); 787 pixel=ScaleQuantumToShort(GetPixelGreen(image,p)); 788 q=PopShortPixel(quantum_info->endian,pixel,q); 789 pixel=ScaleQuantumToShort(GetPixelRed(image,p)); 790 q=PopShortPixel(quantum_info->endian,pixel,q); 791 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p)); 792 q=PopShortPixel(quantum_info->endian,pixel,q); 793 p+=GetPixelChannels(image); 794 q+=quantum_info->pad; 795 } 796 break; 797 } 798 case 32: 799 { 800 register unsigned int 801 pixel; 802 803 if (quantum_info->format == FloatingPointQuantumFormat) 804 { 805 for (x=0; x < (ssize_t) number_pixels; x++) 806 { 807 float 808 pixel; 809 810 q=PopFloatPixel(quantum_info,(float) GetPixelRed(image,p),q); 811 q=PopFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q); 812 q=PopFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q); 813 pixel=(float) GetPixelAlpha(image,p); 814 q=PopFloatPixel(quantum_info,pixel,q); 815 p+=GetPixelChannels(image); 816 q+=quantum_info->pad; 817 } 818 break; 819 } 820 for (x=0; x < (ssize_t) number_pixels; x++) 821 { 822 pixel=ScaleQuantumToLong(GetPixelBlue(image,p)); 823 q=PopLongPixel(quantum_info->endian,pixel,q); 824 pixel=ScaleQuantumToLong(GetPixelGreen(image,p)); 825 q=PopLongPixel(quantum_info->endian,pixel,q); 826 pixel=ScaleQuantumToLong(GetPixelRed(image,p)); 827 q=PopLongPixel(quantum_info->endian,pixel,q); 828 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p)); 829 q=PopLongPixel(quantum_info->endian,pixel,q); 830 p+=GetPixelChannels(image); 831 q+=quantum_info->pad; 832 } 833 break; 834 } 835 case 64: 836 { 837 if (quantum_info->format == FloatingPointQuantumFormat) 838 { 839 double 840 pixel; 841 842 for (x=0; x < (ssize_t) number_pixels; x++) 843 { 844 q=PopDoublePixel(quantum_info,(double) GetPixelRed(image,p),q); 845 q=PopDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q); 846 q=PopDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q); 847 pixel=(double) GetPixelAlpha(image,p); 848 q=PopDoublePixel(quantum_info,pixel,q); 849 p+=GetPixelChannels(image); 850 q+=quantum_info->pad; 851 } 852 break; 853 } 854 } 855 default: 856 { 857 range=GetQuantumRange(quantum_info->depth); 858 for (x=0; x < (ssize_t) number_pixels; x++) 859 { 860 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p), 861 range),q); 862 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p), 863 range),q); 864 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p), 865 range),q); 866 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p), 867 range),q); 868 p+=GetPixelChannels(image); 869 q+=quantum_info->pad; 870 } 871 break; 872 } 873 } 874} 875 876static void ExportBlackQuantum(const Image *image,QuantumInfo *quantum_info, 877 const MagickSizeType number_pixels,const Quantum *restrict p, 878 unsigned char *restrict q,ExceptionInfo *exception) 879{ 880 QuantumAny 881 range; 882 883 register ssize_t 884 x; 885 886 if (image->colorspace != CMYKColorspace) 887 { 888 (void) ThrowMagickException(exception,GetMagickModule(),ImageError, 889 "ColorSeparatedImageRequired","`%s'",image->filename); 890 return; 891 } 892 switch (quantum_info->depth) 893 { 894 case 8: 895 { 896 register unsigned char 897 pixel; 898 899 for (x=0; x < (ssize_t) number_pixels; x++) 900 { 901 pixel=ScaleQuantumToChar(GetPixelBlack(image,p)); 902 q=PopCharPixel(pixel,q); 903 p+=GetPixelChannels(image); 904 q+=quantum_info->pad; 905 } 906 break; 907 } 908 case 16: 909 { 910 register unsigned short 911 pixel; 912 913 if (quantum_info->format == FloatingPointQuantumFormat) 914 { 915 for (x=0; x < (ssize_t) number_pixels; x++) 916 { 917 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlack(image,p)); 918 q=PopShortPixel(quantum_info->endian,pixel,q); 919 p+=GetPixelChannels(image); 920 q+=quantum_info->pad; 921 } 922 break; 923 } 924 for (x=0; x < (ssize_t) number_pixels; x++) 925 { 926 pixel=ScaleQuantumToShort(GetPixelBlack(image,p)); 927 q=PopShortPixel(quantum_info->endian,pixel,q); 928 p+=GetPixelChannels(image); 929 q+=quantum_info->pad; 930 } 931 break; 932 } 933 case 32: 934 { 935 register unsigned int 936 pixel; 937 938 if (quantum_info->format == FloatingPointQuantumFormat) 939 { 940 for (x=0; x < (ssize_t) number_pixels; x++) 941 { 942 q=PopFloatPixel(quantum_info,(float) GetPixelBlack(image,p),q); 943 p+=GetPixelChannels(image); 944 q+=quantum_info->pad; 945 } 946 break; 947 } 948 for (x=0; x < (ssize_t) number_pixels; x++) 949 { 950 pixel=ScaleQuantumToLong(GetPixelBlack(image,p)); 951 q=PopLongPixel(quantum_info->endian,pixel,q); 952 p+=GetPixelChannels(image); 953 q+=quantum_info->pad; 954 } 955 break; 956 } 957 case 64: 958 { 959 if (quantum_info->format == FloatingPointQuantumFormat) 960 { 961 for (x=0; x < (ssize_t) number_pixels; x++) 962 { 963 q=PopDoublePixel(quantum_info,(double) GetPixelBlack(image,p),q); 964 p+=GetPixelChannels(image); 965 q+=quantum_info->pad; 966 } 967 break; 968 } 969 } 970 default: 971 { 972 range=GetQuantumRange(quantum_info->depth); 973 for (x=0; x < (ssize_t) number_pixels; x++) 974 { 975 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlack(image,p), 976 range),q); 977 p+=GetPixelChannels(image); 978 q+=quantum_info->pad; 979 } 980 break; 981 } 982 } 983} 984 985static void ExportBlueQuantum(const Image *image,QuantumInfo *quantum_info, 986 const MagickSizeType number_pixels,const Quantum *restrict p, 987 unsigned char *restrict q,ExceptionInfo *exception) 988{ 989 QuantumAny 990 range; 991 992 register ssize_t 993 x; 994 995 switch (quantum_info->depth) 996 { 997 case 8: 998 { 999 register unsigned char 1000 pixel; 1001 1002 for (x=0; x < (ssize_t) number_pixels; x++) 1003 { 1004 pixel=ScaleQuantumToChar(GetPixelBlue(image,p)); 1005 q=PopCharPixel(pixel,q); 1006 p+=GetPixelChannels(image); 1007 q+=quantum_info->pad; 1008 } 1009 break; 1010 } 1011 case 16: 1012 { 1013 register unsigned short 1014 pixel; 1015 1016 if (quantum_info->format == FloatingPointQuantumFormat) 1017 { 1018 for (x=0; x < (ssize_t) number_pixels; x++) 1019 { 1020 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlue(image,p)); 1021 q=PopShortPixel(quantum_info->endian,pixel,q); 1022 p+=GetPixelChannels(image); 1023 q+=quantum_info->pad; 1024 } 1025 break; 1026 } 1027 for (x=0; x < (ssize_t) number_pixels; x++) 1028 { 1029 pixel=ScaleQuantumToShort(GetPixelBlue(image,p)); 1030 q=PopShortPixel(quantum_info->endian,pixel,q); 1031 p+=GetPixelChannels(image); 1032 q+=quantum_info->pad; 1033 } 1034 break; 1035 } 1036 case 32: 1037 { 1038 register unsigned int 1039 pixel; 1040 1041 if (quantum_info->format == FloatingPointQuantumFormat) 1042 { 1043 for (x=0; x < (ssize_t) number_pixels; x++) 1044 { 1045 q=PopFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q); 1046 p+=GetPixelChannels(image); 1047 q+=quantum_info->pad; 1048 } 1049 break; 1050 } 1051 for (x=0; x < (ssize_t) number_pixels; x++) 1052 { 1053 pixel=ScaleQuantumToLong(GetPixelBlue(image,p)); 1054 q=PopLongPixel(quantum_info->endian,pixel,q); 1055 p+=GetPixelChannels(image); 1056 q+=quantum_info->pad; 1057 } 1058 break; 1059 } 1060 case 64: 1061 { 1062 if (quantum_info->format == FloatingPointQuantumFormat) 1063 { 1064 for (x=0; x < (ssize_t) number_pixels; x++) 1065 { 1066 q=PopDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q); 1067 p+=GetPixelChannels(image); 1068 q+=quantum_info->pad; 1069 } 1070 break; 1071 } 1072 } 1073 default: 1074 { 1075 range=GetQuantumRange(quantum_info->depth); 1076 for (x=0; x < (ssize_t) number_pixels; x++) 1077 { 1078 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p), 1079 range),q); 1080 p+=GetPixelChannels(image); 1081 q+=quantum_info->pad; 1082 } 1083 break; 1084 } 1085 } 1086} 1087 1088static void ExportCbYCrYQuantum(const Image *image,QuantumInfo *quantum_info, 1089 const MagickSizeType number_pixels,const Quantum *restrict p, 1090 unsigned char *restrict q,ExceptionInfo *exception) 1091{ 1092 Quantum 1093 cbcr[4]; 1094 1095 register ssize_t 1096 i, 1097 x; 1098 1099 register unsigned int 1100 pixel; 1101 1102 size_t 1103 quantum; 1104 1105 ssize_t 1106 n; 1107 1108 n=0; 1109 quantum=0; 1110 switch (quantum_info->depth) 1111 { 1112 case 10: 1113 { 1114 if (quantum_info->pack == MagickFalse) 1115 { 1116 for (x=0; x < (ssize_t) number_pixels; x+=2) 1117 { 1118 for (i=0; i < 4; i++) 1119 { 1120 switch (n % 3) 1121 { 1122 case 0: 1123 { 1124 quantum=GetPixelRed(image,p); 1125 break; 1126 } 1127 case 1: 1128 { 1129 quantum=GetPixelGreen(image,p); 1130 break; 1131 } 1132 case 2: 1133 { 1134 quantum=GetPixelBlue(image,p); 1135 break; 1136 } 1137 } 1138 cbcr[i]=(Quantum) quantum; 1139 n++; 1140 } 1141 pixel=(unsigned int) ((size_t) (cbcr[1]) << 22 | (size_t) 1142 (cbcr[0]) << 12 | (size_t) (cbcr[2]) << 2); 1143 q=PopLongPixel(quantum_info->endian,pixel,q); 1144 p+=GetPixelChannels(image); 1145 pixel=(unsigned int) ((size_t) (cbcr[3]) << 22 | (size_t) 1146 (cbcr[0]) << 12 | (size_t) (cbcr[2]) << 2); 1147 q=PopLongPixel(quantum_info->endian,pixel,q); 1148 p+=GetPixelChannels(image); 1149 q+=quantum_info->pad; 1150 } 1151 break; 1152 } 1153 break; 1154 } 1155 default: 1156 { 1157 QuantumAny 1158 range; 1159 1160 for (x=0; x < (ssize_t) number_pixels; x+=2) 1161 { 1162 for (i=0; i < 4; i++) 1163 { 1164 switch (n % 3) 1165 { 1166 case 0: 1167 { 1168 quantum=GetPixelRed(image,p); 1169 break; 1170 } 1171 case 1: 1172 { 1173 quantum=GetPixelGreen(image,p); 1174 break; 1175 } 1176 case 2: 1177 { 1178 quantum=GetPixelBlue(image,p); 1179 break; 1180 } 1181 } 1182 cbcr[i]=(Quantum) quantum; 1183 n++; 1184 } 1185 range=GetQuantumRange(quantum_info->depth); 1186 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[1],range),q); 1187 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[0],range),q); 1188 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[2],range),q); 1189 p+=GetPixelChannels(image); 1190 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[3],range),q); 1191 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[0],range),q); 1192 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[2],range),q); 1193 p+=GetPixelChannels(image); 1194 q+=quantum_info->pad; 1195 } 1196 break; 1197 } 1198 } 1199} 1200 1201static void ExportCMYKQuantum(const Image *image,QuantumInfo *quantum_info, 1202 const MagickSizeType number_pixels,const Quantum *restrict p, 1203 unsigned char *restrict q,ExceptionInfo *exception) 1204{ 1205 register ssize_t 1206 x; 1207 1208 if (image->colorspace != CMYKColorspace) 1209 { 1210 (void) ThrowMagickException(exception,GetMagickModule(),ImageError, 1211 "ColorSeparatedImageRequired","`%s'",image->filename); 1212 return; 1213 } 1214 switch (quantum_info->depth) 1215 { 1216 case 8: 1217 { 1218 register unsigned char 1219 pixel; 1220 1221 for (x=0; x < (ssize_t) number_pixels; x++) 1222 { 1223 pixel=ScaleQuantumToChar(GetPixelRed(image,p)); 1224 q=PopCharPixel(pixel,q); 1225 pixel=ScaleQuantumToChar(GetPixelGreen(image,p)); 1226 q=PopCharPixel(pixel,q); 1227 pixel=ScaleQuantumToChar(GetPixelBlue(image,p)); 1228 q=PopCharPixel(pixel,q); 1229 pixel=ScaleQuantumToChar(GetPixelBlack(image,p)); 1230 q=PopCharPixel(pixel,q); 1231 p+=GetPixelChannels(image); 1232 q+=quantum_info->pad; 1233 } 1234 break; 1235 } 1236 case 16: 1237 { 1238 register unsigned short 1239 pixel; 1240 1241 if (quantum_info->format == FloatingPointQuantumFormat) 1242 { 1243 for (x=0; x < (ssize_t) number_pixels; x++) 1244 { 1245 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelRed(image,p)); 1246 q=PopShortPixel(quantum_info->endian,pixel,q); 1247 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelGreen(image,p)); 1248 q=PopShortPixel(quantum_info->endian,pixel,q); 1249 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlue(image,p)); 1250 q=PopShortPixel(quantum_info->endian,pixel,q); 1251 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlack(image,p)); 1252 q=PopShortPixel(quantum_info->endian,pixel,q); 1253 p+=GetPixelChannels(image); 1254 q+=quantum_info->pad; 1255 } 1256 break; 1257 } 1258 for (x=0; x < (ssize_t) number_pixels; x++) 1259 { 1260 pixel=ScaleQuantumToShort(GetPixelRed(image,p)); 1261 q=PopShortPixel(quantum_info->endian,pixel,q); 1262 pixel=ScaleQuantumToShort(GetPixelGreen(image,p)); 1263 q=PopShortPixel(quantum_info->endian,pixel,q); 1264 pixel=ScaleQuantumToShort(GetPixelBlue(image,p)); 1265 q=PopShortPixel(quantum_info->endian,pixel,q); 1266 pixel=ScaleQuantumToShort(GetPixelBlack(image,p)); 1267 q=PopShortPixel(quantum_info->endian,pixel,q); 1268 p+=GetPixelChannels(image); 1269 q+=quantum_info->pad; 1270 } 1271 break; 1272 } 1273 case 32: 1274 { 1275 register unsigned int 1276 pixel; 1277 1278 if (quantum_info->format == FloatingPointQuantumFormat) 1279 { 1280 for (x=0; x < (ssize_t) number_pixels; x++) 1281 { 1282 q=PopFloatPixel(quantum_info,(float) GetPixelRed(image,p),q); 1283 q=PopFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q); 1284 q=PopFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q); 1285 q=PopFloatPixel(quantum_info,(float) GetPixelBlack(image,p),q); 1286 p+=GetPixelChannels(image); 1287 q+=quantum_info->pad; 1288 } 1289 break; 1290 } 1291 for (x=0; x < (ssize_t) number_pixels; x++) 1292 { 1293 pixel=ScaleQuantumToLong(GetPixelRed(image,p)); 1294 q=PopLongPixel(quantum_info->endian,pixel,q); 1295 pixel=ScaleQuantumToLong(GetPixelGreen(image,p)); 1296 q=PopLongPixel(quantum_info->endian,pixel,q); 1297 pixel=ScaleQuantumToLong(GetPixelBlue(image,p)); 1298 q=PopLongPixel(quantum_info->endian,pixel,q); 1299 pixel=ScaleQuantumToLong(GetPixelBlack(image,p)); 1300 q=PopLongPixel(quantum_info->endian,pixel,q); 1301 p+=GetPixelChannels(image); 1302 q+=quantum_info->pad; 1303 } 1304 break; 1305 } 1306 case 64: 1307 { 1308 if (quantum_info->format == FloatingPointQuantumFormat) 1309 { 1310 for (x=0; x < (ssize_t) number_pixels; x++) 1311 { 1312 q=PopDoublePixel(quantum_info,(double) GetPixelRed(image,p),q); 1313 q=PopDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q); 1314 q=PopDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q); 1315 q=PopDoublePixel(quantum_info,(double) GetPixelBlack(image,p),q); 1316 p+=GetPixelChannels(image); 1317 q+=quantum_info->pad; 1318 } 1319 break; 1320 } 1321 } 1322 default: 1323 { 1324 QuantumAny 1325 range; 1326 1327 range=GetQuantumRange(quantum_info->depth); 1328 for (x=0; x < (ssize_t) number_pixels; x++) 1329 { 1330 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p), 1331 range),q); 1332 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p), 1333 range),q); 1334 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p), 1335 range),q); 1336 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlack(image,p), 1337 range),q); 1338 p+=GetPixelChannels(image); 1339 q+=quantum_info->pad; 1340 } 1341 break; 1342 } 1343 } 1344} 1345 1346static void ExportCMYKAQuantum(const Image *image,QuantumInfo *quantum_info, 1347 const MagickSizeType number_pixels,const Quantum *restrict p, 1348 unsigned char *restrict q,ExceptionInfo *exception) 1349{ 1350 register ssize_t 1351 x; 1352 1353 if (image->colorspace != CMYKColorspace) 1354 { 1355 (void) ThrowMagickException(exception,GetMagickModule(),ImageError, 1356 "ColorSeparatedImageRequired","`%s'",image->filename); 1357 return; 1358 } 1359 switch (quantum_info->depth) 1360 { 1361 case 8: 1362 { 1363 register unsigned char 1364 pixel; 1365 1366 for (x=0; x < (ssize_t) number_pixels; x++) 1367 { 1368 pixel=ScaleQuantumToChar(GetPixelRed(image,p)); 1369 q=PopCharPixel(pixel,q); 1370 pixel=ScaleQuantumToChar(GetPixelGreen(image,p)); 1371 q=PopCharPixel(pixel,q); 1372 pixel=ScaleQuantumToChar(GetPixelBlue(image,p)); 1373 q=PopCharPixel(pixel,q); 1374 pixel=ScaleQuantumToChar(GetPixelBlack(image,p)); 1375 q=PopCharPixel(pixel,q); 1376 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p)); 1377 q=PopCharPixel(pixel,q); 1378 p+=GetPixelChannels(image); 1379 q+=quantum_info->pad; 1380 } 1381 break; 1382 } 1383 case 16: 1384 { 1385 register unsigned short 1386 pixel; 1387 1388 if (quantum_info->format == FloatingPointQuantumFormat) 1389 { 1390 for (x=0; x < (ssize_t) number_pixels; x++) 1391 { 1392 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelRed(image,p)); 1393 q=PopShortPixel(quantum_info->endian,pixel,q); 1394 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelGreen(image,p)); 1395 q=PopShortPixel(quantum_info->endian,pixel,q); 1396 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlue(image,p)); 1397 q=PopShortPixel(quantum_info->endian,pixel,q); 1398 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlack(image,p)); 1399 q=PopShortPixel(quantum_info->endian,pixel,q); 1400 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelAlpha(image,p)); 1401 q=PopShortPixel(quantum_info->endian,pixel,q); 1402 p+=GetPixelChannels(image); 1403 q+=quantum_info->pad; 1404 } 1405 break; 1406 } 1407 for (x=0; x < (ssize_t) number_pixels; x++) 1408 { 1409 pixel=ScaleQuantumToShort(GetPixelRed(image,p)); 1410 q=PopShortPixel(quantum_info->endian,pixel,q); 1411 pixel=ScaleQuantumToShort(GetPixelGreen(image,p)); 1412 q=PopShortPixel(quantum_info->endian,pixel,q); 1413 pixel=ScaleQuantumToShort(GetPixelBlue(image,p)); 1414 q=PopShortPixel(quantum_info->endian,pixel,q); 1415 pixel=ScaleQuantumToShort(GetPixelBlack(image,p)); 1416 q=PopShortPixel(quantum_info->endian,pixel,q); 1417 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p)); 1418 q=PopShortPixel(quantum_info->endian,pixel,q); 1419 p+=GetPixelChannels(image); 1420 q+=quantum_info->pad; 1421 } 1422 break; 1423 } 1424 case 32: 1425 { 1426 register unsigned int 1427 pixel; 1428 1429 if (quantum_info->format == FloatingPointQuantumFormat) 1430 { 1431 for (x=0; x < (ssize_t) number_pixels; x++) 1432 { 1433 float 1434 pixel; 1435 1436 q=PopFloatPixel(quantum_info,(float) GetPixelRed(image,p),q); 1437 q=PopFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q); 1438 q=PopFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q); 1439 q=PopFloatPixel(quantum_info,(float) GetPixelBlack(image,p),q); 1440 pixel=(float) (GetPixelAlpha(image,p)); 1441 q=PopFloatPixel(quantum_info,pixel,q); 1442 p+=GetPixelChannels(image); 1443 q+=quantum_info->pad; 1444 } 1445 break; 1446 } 1447 for (x=0; x < (ssize_t) number_pixels; x++) 1448 { 1449 pixel=ScaleQuantumToLong(GetPixelRed(image,p)); 1450 q=PopLongPixel(quantum_info->endian,pixel,q); 1451 pixel=ScaleQuantumToLong(GetPixelGreen(image,p)); 1452 q=PopLongPixel(quantum_info->endian,pixel,q); 1453 pixel=ScaleQuantumToLong(GetPixelBlue(image,p)); 1454 q=PopLongPixel(quantum_info->endian,pixel,q); 1455 pixel=ScaleQuantumToLong(GetPixelBlack(image,p)); 1456 q=PopLongPixel(quantum_info->endian,pixel,q); 1457 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p)); 1458 q=PopLongPixel(quantum_info->endian,pixel,q); 1459 p+=GetPixelChannels(image); 1460 q+=quantum_info->pad; 1461 } 1462 break; 1463 } 1464 case 64: 1465 { 1466 if (quantum_info->format == FloatingPointQuantumFormat) 1467 { 1468 double 1469 pixel; 1470 1471 for (x=0; x < (ssize_t) number_pixels; x++) 1472 { 1473 q=PopDoublePixel(quantum_info,(double) GetPixelRed(image,p),q); 1474 q=PopDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q); 1475 q=PopDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q); 1476 q=PopDoublePixel(quantum_info,(double) GetPixelBlack(image,p),q); 1477 pixel=(double) (GetPixelAlpha(image,p)); 1478 q=PopDoublePixel(quantum_info,pixel,q); 1479 p+=GetPixelChannels(image); 1480 q+=quantum_info->pad; 1481 } 1482 break; 1483 } 1484 } 1485 default: 1486 { 1487 QuantumAny 1488 range; 1489 1490 range=GetQuantumRange(quantum_info->depth); 1491 for (x=0; x < (ssize_t) number_pixels; x++) 1492 { 1493 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p), 1494 range),q); 1495 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p), 1496 range),q); 1497 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p), 1498 range),q); 1499 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlack(image,p), 1500 range),q); 1501 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p), 1502 range),q); 1503 p+=GetPixelChannels(image); 1504 q+=quantum_info->pad; 1505 } 1506 break; 1507 } 1508 } 1509} 1510 1511static void ExportGrayQuantum(const Image *image,QuantumInfo *quantum_info, 1512 const MagickSizeType number_pixels,const Quantum *restrict p, 1513 unsigned char *restrict q,ExceptionInfo *exception) 1514{ 1515 QuantumAny 1516 range; 1517 1518 register ssize_t 1519 x; 1520 1521 switch (quantum_info->depth) 1522 { 1523 case 1: 1524 { 1525 register Quantum 1526 threshold; 1527 1528 register unsigned char 1529 black, 1530 white; 1531 1532 ssize_t 1533 bit; 1534 1535 black=0x00; 1536 white=0x01; 1537 if (quantum_info->min_is_white != MagickFalse) 1538 { 1539 black=0x01; 1540 white=0x00; 1541 } 1542 threshold=(Quantum) (QuantumRange/2); 1543 for (x=((ssize_t) number_pixels-7); x > 0; x-=8) 1544 { 1545 *q='\0'; 1546 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) << 7; 1547 p+=GetPixelChannels(image); 1548 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) << 6; 1549 p+=GetPixelChannels(image); 1550 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) << 5; 1551 p+=GetPixelChannels(image); 1552 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) << 4; 1553 p+=GetPixelChannels(image); 1554 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) << 3; 1555 p+=GetPixelChannels(image); 1556 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) << 2; 1557 p+=GetPixelChannels(image); 1558 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) << 1; 1559 p+=GetPixelChannels(image); 1560 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) << 0; 1561 p+=GetPixelChannels(image); 1562 q++; 1563 } 1564 if ((number_pixels % 8) != 0) 1565 { 1566 *q='\0'; 1567 for (bit=7; bit >= (ssize_t) (8-(number_pixels % 8)); bit--) 1568 { 1569 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) << bit; 1570 p+=GetPixelChannels(image); 1571 } 1572 q++; 1573 } 1574 break; 1575 } 1576 case 4: 1577 { 1578 register unsigned char 1579 pixel; 1580 1581 for (x=0; x < (ssize_t) (number_pixels-1) ; x+=2) 1582 { 1583 pixel=ScaleQuantumToChar(GetPixelIntensity(image,p)); 1584 *q=(((pixel >> 4) & 0xf) << 4); 1585 p+=GetPixelChannels(image); 1586 pixel=ScaleQuantumToChar(GetPixelIntensity(image,p)); 1587 *q|=pixel >> 4; 1588 p+=GetPixelChannels(image); 1589 q++; 1590 } 1591 if ((number_pixels % 2) != 0) 1592 { 1593 pixel=ScaleQuantumToChar(GetPixelIntensity(image,p)); 1594 *q=(((pixel >> 4) & 0xf) << 4); 1595 p+=GetPixelChannels(image); 1596 q++; 1597 } 1598 break; 1599 } 1600 case 8: 1601 { 1602 register unsigned char 1603 pixel; 1604 1605 for (x=0; x < (ssize_t) number_pixels; x++) 1606 { 1607 pixel=ScaleQuantumToChar(GetPixelIntensity(image,p)); 1608 q=PopCharPixel(pixel,q); 1609 p+=GetPixelChannels(image); 1610 q+=quantum_info->pad; 1611 } 1612 break; 1613 } 1614 case 10: 1615 { 1616 range=GetQuantumRange(quantum_info->depth); 1617 if (quantum_info->pack == MagickFalse) 1618 { 1619 register unsigned int 1620 pixel; 1621 1622 for (x=0; x < (ssize_t) (number_pixels-2); x+=3) 1623 { 1624 pixel=(unsigned int) (ScaleQuantumToAny(GetPixelIntensity(image, 1625 p+2*GetPixelChannels(image)),range) << 22 | ScaleQuantumToAny( 1626 GetPixelIntensity(image,p+GetPixelChannels(image)),range) << 12 | 1627 ScaleQuantumToAny(GetPixelIntensity(image,p),range) << 2); 1628 q=PopLongPixel(quantum_info->endian,pixel,q); 1629 p+=3*GetPixelChannels(image); 1630 q+=quantum_info->pad; 1631 } 1632 if (x < (ssize_t) number_pixels) 1633 { 1634 pixel=0U; 1635 if (x++ < (ssize_t) (number_pixels-1)) 1636 pixel|=ScaleQuantumToAny(GetPixelIntensity(image,p+ 1637 GetPixelChannels(image)),range) << 12; 1638 if (x++ < (ssize_t) number_pixels) 1639 pixel|=ScaleQuantumToAny(GetPixelIntensity(image,p),range) << 2; 1640 q=PopLongPixel(quantum_info->endian,pixel,q); 1641 } 1642 break; 1643 } 1644 for (x=0; x < (ssize_t) number_pixels; x++) 1645 { 1646 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny( 1647 GetPixelIntensity(image,p),range),q); 1648 p+=GetPixelChannels(image); 1649 q+=quantum_info->pad; 1650 } 1651 break; 1652 } 1653 case 12: 1654 { 1655 register unsigned short 1656 pixel; 1657 1658 range=GetQuantumRange(quantum_info->depth); 1659 if (quantum_info->pack == MagickFalse) 1660 { 1661 for (x=0; x < (ssize_t) number_pixels; x++) 1662 { 1663 pixel=ScaleQuantumToShort(GetPixelIntensity(image,p)); 1664 q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel >> 4),q); 1665 p+=GetPixelChannels(image); 1666 q+=quantum_info->pad; 1667 } 1668 break; 1669 } 1670 for (x=0; x < (ssize_t) number_pixels; x++) 1671 { 1672 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny( 1673 GetPixelIntensity(image,p),range),q); 1674 p+=GetPixelChannels(image); 1675 q+=quantum_info->pad; 1676 } 1677 break; 1678 } 1679 case 16: 1680 { 1681 register unsigned short 1682 pixel; 1683 1684 if (quantum_info->format == FloatingPointQuantumFormat) 1685 { 1686 for (x=0; x < (ssize_t) number_pixels; x++) 1687 { 1688 pixel=SinglePrecisionToHalf(QuantumScale* 1689 GetPixelIntensity(image,p)); 1690 q=PopShortPixel(quantum_info->endian,pixel,q); 1691 p+=GetPixelChannels(image); 1692 q+=quantum_info->pad; 1693 } 1694 break; 1695 } 1696 for (x=0; x < (ssize_t) number_pixels; x++) 1697 { 1698 pixel=ScaleQuantumToShort(GetPixelIntensity(image,p)); 1699 q=PopShortPixel(quantum_info->endian,pixel,q); 1700 p+=GetPixelChannels(image); 1701 q+=quantum_info->pad; 1702 } 1703 break; 1704 } 1705 case 32: 1706 { 1707 register unsigned int 1708 pixel; 1709 1710 if (quantum_info->format == FloatingPointQuantumFormat) 1711 { 1712 for (x=0; x < (ssize_t) number_pixels; x++) 1713 { 1714 float 1715 pixel; 1716 1717 pixel=(float) GetPixelIntensity(image,p); 1718 q=PopFloatPixel(quantum_info,pixel,q); 1719 p+=GetPixelChannels(image); 1720 q+=quantum_info->pad; 1721 } 1722 break; 1723 } 1724 for (x=0; x < (ssize_t) number_pixels; x++) 1725 { 1726 pixel=ScaleQuantumToLong(GetPixelIntensity(image,p)); 1727 q=PopLongPixel(quantum_info->endian,pixel,q); 1728 p+=GetPixelChannels(image); 1729 q+=quantum_info->pad; 1730 } 1731 break; 1732 } 1733 case 64: 1734 { 1735 if (quantum_info->format == FloatingPointQuantumFormat) 1736 { 1737 for (x=0; x < (ssize_t) number_pixels; x++) 1738 { 1739 double 1740 pixel; 1741 1742 pixel=(double) GetPixelIntensity(image,p); 1743 q=PopDoublePixel(quantum_info,pixel,q); 1744 p+=GetPixelChannels(image); 1745 q+=quantum_info->pad; 1746 } 1747 break; 1748 } 1749 } 1750 default: 1751 { 1752 range=GetQuantumRange(quantum_info->depth); 1753 for (x=0; x < (ssize_t) number_pixels; x++) 1754 { 1755 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny( 1756 GetPixelIntensity(image,p),range),q); 1757 p+=GetPixelChannels(image); 1758 q+=quantum_info->pad; 1759 } 1760 break; 1761 } 1762 } 1763} 1764 1765static void ExportGrayAlphaQuantum(const Image *image,QuantumInfo *quantum_info, 1766 const MagickSizeType number_pixels,const Quantum *restrict p, 1767 unsigned char *restrict q,ExceptionInfo *exception) 1768{ 1769 QuantumAny 1770 range; 1771 1772 register ssize_t 1773 x; 1774 1775 switch (quantum_info->depth) 1776 { 1777 case 1: 1778 { 1779 register Quantum 1780 threshold; 1781 1782 register unsigned char 1783 black, 1784 pixel, 1785 white; 1786 1787 ssize_t 1788 bit; 1789 1790 black=0x00; 1791 white=0x01; 1792 if (quantum_info->min_is_white == MagickFalse) 1793 { 1794 black=0x01; 1795 white=0x00; 1796 } 1797 threshold=(Quantum) (QuantumRange/2); 1798 for (x=((ssize_t) number_pixels-3); x > 0; x-=4) 1799 { 1800 *q='\0'; 1801 *q|=(GetPixelIntensity(image,p) > threshold ? black : white) << 7; 1802 pixel=(unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ? 1803 0x00 : 0x01); 1804 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 6); 1805 p+=GetPixelChannels(image); 1806 *q|=(GetPixelIntensity(image,p) > threshold ? black : white) << 5; 1807 pixel=(unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ? 1808 0x00 : 0x01); 1809 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 4); 1810 p+=GetPixelChannels(image); 1811 *q|=(GetPixelIntensity(image,p) > threshold ? black : white) << 3; 1812 pixel=(unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ? 1813 0x00 : 0x01); 1814 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 2); 1815 p+=GetPixelChannels(image); 1816 *q|=(GetPixelIntensity(image,p) > threshold ? black : white) << 1; 1817 pixel=(unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ? 1818 0x00 : 0x01); 1819 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 0); 1820 p+=GetPixelChannels(image); 1821 q++; 1822 } 1823 if ((number_pixels % 4) != 0) 1824 { 1825 *q='\0'; 1826 for (bit=0; bit <= (ssize_t) (number_pixels % 4); bit+=2) 1827 { 1828 *q|=(GetPixelIntensity(image,p) > threshold ? black : white) << 1829 (7-bit); 1830 pixel=(unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ? 1831 0x00 : 0x01); 1832 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << (unsigned char) 1833 (7-bit-1)); 1834 p+=GetPixelChannels(image); 1835 } 1836 q++; 1837 } 1838 break; 1839 } 1840 case 4: 1841 { 1842 register unsigned char 1843 pixel; 1844 1845 for (x=0; x < (ssize_t) number_pixels ; x++) 1846 { 1847 pixel=ScaleQuantumToChar(GetPixelIntensity(image,p)); 1848 *q=(((pixel >> 4) & 0xf) << 4); 1849 pixel=(unsigned char) (16*QuantumScale*GetPixelAlpha(image,p)+0.5); 1850 *q|=pixel & 0xf; 1851 p+=GetPixelChannels(image); 1852 q++; 1853 } 1854 break; 1855 } 1856 case 8: 1857 { 1858 register unsigned char 1859 pixel; 1860 1861 for (x=0; x < (ssize_t) number_pixels; x++) 1862 { 1863 pixel=ScaleQuantumToChar(GetPixelIntensity(image,p)); 1864 q=PopCharPixel(pixel,q); 1865 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p)); 1866 q=PopCharPixel(pixel,q); 1867 p+=GetPixelChannels(image); 1868 q+=quantum_info->pad; 1869 } 1870 break; 1871 } 1872 case 16: 1873 { 1874 register unsigned short 1875 pixel; 1876 1877 if (quantum_info->format == FloatingPointQuantumFormat) 1878 { 1879 for (x=0; x < (ssize_t) number_pixels; x++) 1880 { 1881 pixel=SinglePrecisionToHalf(QuantumScale* 1882 GetPixelIntensity(image,p)); 1883 q=PopShortPixel(quantum_info->endian,pixel,q); 1884 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelAlpha(image,p)); 1885 q=PopShortPixel(quantum_info->endian,pixel,q); 1886 p+=GetPixelChannels(image); 1887 q+=quantum_info->pad; 1888 } 1889 break; 1890 } 1891 for (x=0; x < (ssize_t) number_pixels; x++) 1892 { 1893 pixel=ScaleQuantumToShort(GetPixelIntensity(image,p)); 1894 q=PopShortPixel(quantum_info->endian,pixel,q); 1895 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p)); 1896 q=PopShortPixel(quantum_info->endian,pixel,q); 1897 p+=GetPixelChannels(image); 1898 q+=quantum_info->pad; 1899 } 1900 break; 1901 } 1902 case 32: 1903 { 1904 register unsigned int 1905 pixel; 1906 1907 if (quantum_info->format == FloatingPointQuantumFormat) 1908 { 1909 for (x=0; x < (ssize_t) number_pixels; x++) 1910 { 1911 float 1912 pixel; 1913 1914 pixel=(float) GetPixelIntensity(image,p); 1915 q=PopFloatPixel(quantum_info,pixel,q); 1916 pixel=(float) (GetPixelAlpha(image,p)); 1917 q=PopFloatPixel(quantum_info,pixel,q); 1918 p+=GetPixelChannels(image); 1919 q+=quantum_info->pad; 1920 } 1921 break; 1922 } 1923 for (x=0; x < (ssize_t) number_pixels; x++) 1924 { 1925 pixel=ScaleQuantumToLong(GetPixelIntensity(image,p)); 1926 q=PopLongPixel(quantum_info->endian,pixel,q); 1927 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p)); 1928 q=PopLongPixel(quantum_info->endian,pixel,q); 1929 p+=GetPixelChannels(image); 1930 q+=quantum_info->pad; 1931 } 1932 break; 1933 } 1934 case 64: 1935 { 1936 if (quantum_info->format == FloatingPointQuantumFormat) 1937 { 1938 for (x=0; x < (ssize_t) number_pixels; x++) 1939 { 1940 double 1941 pixel; 1942 1943 pixel=(double) GetPixelIntensity(image,p); 1944 q=PopDoublePixel(quantum_info,pixel,q); 1945 pixel=(double) (GetPixelAlpha(image,p)); 1946 q=PopDoublePixel(quantum_info,pixel,q); 1947 p+=GetPixelChannels(image); 1948 q+=quantum_info->pad; 1949 } 1950 break; 1951 } 1952 } 1953 default: 1954 { 1955 range=GetQuantumRange(quantum_info->depth); 1956 for (x=0; x < (ssize_t) number_pixels; x++) 1957 { 1958 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny( 1959 GetPixelIntensity(image,p),range),q); 1960 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p), 1961 range),q); 1962 p+=GetPixelChannels(image); 1963 q+=quantum_info->pad; 1964 } 1965 break; 1966 } 1967 } 1968} 1969 1970static void ExportGreenQuantum(const Image *image,QuantumInfo *quantum_info, 1971 const MagickSizeType number_pixels,const Quantum *restrict p, 1972 unsigned char *restrict q,ExceptionInfo *exception) 1973{ 1974 QuantumAny 1975 range; 1976 1977 register ssize_t 1978 x; 1979 1980 switch (quantum_info->depth) 1981 { 1982 case 8: 1983 { 1984 register unsigned char 1985 pixel; 1986 1987 for (x=0; x < (ssize_t) number_pixels; x++) 1988 { 1989 pixel=ScaleQuantumToChar(GetPixelGreen(image,p)); 1990 q=PopCharPixel(pixel,q); 1991 p+=GetPixelChannels(image); 1992 q+=quantum_info->pad; 1993 } 1994 break; 1995 } 1996 case 16: 1997 { 1998 register unsigned short 1999 pixel; 2000 2001 if (quantum_info->format == FloatingPointQuantumFormat) 2002 { 2003 for (x=0; x < (ssize_t) number_pixels; x++) 2004 { 2005 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelGreen(image,p)); 2006 q=PopShortPixel(quantum_info->endian,pixel,q); 2007 p+=GetPixelChannels(image); 2008 q+=quantum_info->pad; 2009 } 2010 break; 2011 } 2012 for (x=0; x < (ssize_t) number_pixels; x++) 2013 { 2014 pixel=ScaleQuantumToShort(GetPixelGreen(image,p)); 2015 q=PopShortPixel(quantum_info->endian,pixel,q); 2016 p+=GetPixelChannels(image); 2017 q+=quantum_info->pad; 2018 } 2019 break; 2020 } 2021 case 32: 2022 { 2023 register unsigned int 2024 pixel; 2025 2026 if (quantum_info->format == FloatingPointQuantumFormat) 2027 { 2028 for (x=0; x < (ssize_t) number_pixels; x++) 2029 { 2030 q=PopFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q); 2031 p+=GetPixelChannels(image); 2032 q+=quantum_info->pad; 2033 } 2034 break; 2035 } 2036 for (x=0; x < (ssize_t) number_pixels; x++) 2037 { 2038 pixel=ScaleQuantumToLong(GetPixelGreen(image,p)); 2039 q=PopLongPixel(quantum_info->endian,pixel,q); 2040 p+=GetPixelChannels(image); 2041 q+=quantum_info->pad; 2042 } 2043 break; 2044 } 2045 case 64: 2046 { 2047 if (quantum_info->format == FloatingPointQuantumFormat) 2048 { 2049 for (x=0; x < (ssize_t) number_pixels; x++) 2050 { 2051 q=PopDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q); 2052 p+=GetPixelChannels(image); 2053 q+=quantum_info->pad; 2054 } 2055 break; 2056 } 2057 } 2058 default: 2059 { 2060 range=GetQuantumRange(quantum_info->depth); 2061 for (x=0; x < (ssize_t) number_pixels; x++) 2062 { 2063 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p), 2064 range),q); 2065 p+=GetPixelChannels(image); 2066 q+=quantum_info->pad; 2067 } 2068 break; 2069 } 2070 } 2071} 2072 2073static void ExportIndexQuantum(const Image *image,QuantumInfo *quantum_info, 2074 const MagickSizeType number_pixels,const Quantum *restrict p, 2075 unsigned char *restrict q,ExceptionInfo *exception) 2076{ 2077 register ssize_t 2078 x; 2079 2080 ssize_t 2081 bit; 2082 2083 if (image->storage_class != PseudoClass) 2084 { 2085 (void) ThrowMagickException(exception,GetMagickModule(),ImageError, 2086 "ColormappedImageRequired","`%s'",image->filename); 2087 return; 2088 } 2089 switch (quantum_info->depth) 2090 { 2091 case 1: 2092 { 2093 register unsigned char 2094 pixel; 2095 2096 for (x=((ssize_t) number_pixels-7); x > 0; x-=8) 2097 { 2098 pixel=(unsigned char) GetPixelIndex(image,p); 2099 *q=((pixel & 0x01) << 7); 2100 p+=GetPixelChannels(image); 2101 pixel=(unsigned char) GetPixelIndex(image,p); 2102 *q|=((pixel & 0x01) << 6); 2103 p+=GetPixelChannels(image); 2104 pixel=(unsigned char) GetPixelIndex(image,p); 2105 *q|=((pixel & 0x01) << 5); 2106 p+=GetPixelChannels(image); 2107 pixel=(unsigned char) GetPixelIndex(image,p); 2108 *q|=((pixel & 0x01) << 4); 2109 p+=GetPixelChannels(image); 2110 pixel=(unsigned char) GetPixelIndex(image,p); 2111 *q|=((pixel & 0x01) << 3); 2112 p+=GetPixelChannels(image); 2113 pixel=(unsigned char) GetPixelIndex(image,p); 2114 *q|=((pixel & 0x01) << 2); 2115 p+=GetPixelChannels(image); 2116 pixel=(unsigned char) GetPixelIndex(image,p); 2117 *q|=((pixel & 0x01) << 1); 2118 p+=GetPixelChannels(image); 2119 pixel=(unsigned char) GetPixelIndex(image,p); 2120 *q|=((pixel & 0x01) << 0); 2121 p+=GetPixelChannels(image); 2122 q++; 2123 } 2124 if ((number_pixels % 8) != 0) 2125 { 2126 *q='\0'; 2127 for (bit=7; bit >= (ssize_t) (8-(number_pixels % 8)); bit--) 2128 { 2129 pixel=(unsigned char) GetPixelIndex(image,p); 2130 *q|=((pixel & 0x01) << (unsigned char) bit); 2131 p+=GetPixelChannels(image); 2132 } 2133 q++; 2134 } 2135 break; 2136 } 2137 case 4: 2138 { 2139 register unsigned char 2140 pixel; 2141 2142 for (x=0; x < (ssize_t) (number_pixels-1) ; x+=2) 2143 { 2144 pixel=(unsigned char) GetPixelIndex(image,p); 2145 *q=((pixel & 0xf) << 4); 2146 p+=GetPixelChannels(image); 2147 pixel=(unsigned char) GetPixelIndex(image,p); 2148 *q|=((pixel & 0xf) << 0); 2149 p+=GetPixelChannels(image); 2150 q++; 2151 } 2152 if ((number_pixels % 2) != 0) 2153 { 2154 pixel=(unsigned char) GetPixelIndex(image,p); 2155 *q=((pixel & 0xf) << 4); 2156 p+=GetPixelChannels(image); 2157 q++; 2158 } 2159 break; 2160 } 2161 case 8: 2162 { 2163 for (x=0; x < (ssize_t) number_pixels; x++) 2164 { 2165 q=PopCharPixel((unsigned char) GetPixelIndex(image,p),q); 2166 p+=GetPixelChannels(image); 2167 q+=quantum_info->pad; 2168 } 2169 break; 2170 } 2171 case 16: 2172 { 2173 if (quantum_info->format == FloatingPointQuantumFormat) 2174 { 2175 for (x=0; x < (ssize_t) number_pixels; x++) 2176 { 2177 q=PopShortPixel(quantum_info->endian,SinglePrecisionToHalf(QuantumScale* 2178 GetPixelIndex(image,p)),q); 2179 p+=GetPixelChannels(image); 2180 q+=quantum_info->pad; 2181 } 2182 break; 2183 } 2184 for (x=0; x < (ssize_t) number_pixels; x++) 2185 { 2186 q=PopShortPixel(quantum_info->endian,(unsigned short) GetPixelIndex(image,p),q); 2187 p+=GetPixelChannels(image); 2188 q+=quantum_info->pad; 2189 } 2190 break; 2191 } 2192 case 32: 2193 { 2194 if (quantum_info->format == FloatingPointQuantumFormat) 2195 { 2196 for (x=0; x < (ssize_t) number_pixels; x++) 2197 { 2198 q=PopFloatPixel(quantum_info,(float) GetPixelIndex(image,p),q); 2199 p+=GetPixelChannels(image); 2200 q+=quantum_info->pad; 2201 } 2202 break; 2203 } 2204 for (x=0; x < (ssize_t) number_pixels; x++) 2205 { 2206 q=PopLongPixel(quantum_info->endian,(unsigned int) GetPixelIndex(image,p),q); 2207 p+=GetPixelChannels(image); 2208 q+=quantum_info->pad; 2209 } 2210 break; 2211 } 2212 case 64: 2213 { 2214 if (quantum_info->format == FloatingPointQuantumFormat) 2215 { 2216 for (x=0; x < (ssize_t) number_pixels; x++) 2217 { 2218 q=PopDoublePixel(quantum_info,(double) GetPixelIndex(image,p),q); 2219 p+=GetPixelChannels(image); 2220 q+=quantum_info->pad; 2221 } 2222 break; 2223 } 2224 } 2225 default: 2226 { 2227 for (x=0; x < (ssize_t) number_pixels; x++) 2228 { 2229 q=PopQuantumPixel(quantum_info,GetPixelIndex(image,p),q); 2230 p+=GetPixelChannels(image); 2231 q+=quantum_info->pad; 2232 } 2233 break; 2234 } 2235 } 2236} 2237 2238static void ExportIndexAlphaQuantum(const Image *image, 2239 QuantumInfo *quantum_info,const MagickSizeType number_pixels, 2240 const Quantum *restrict p,unsigned char *restrict q,ExceptionInfo *exception) 2241{ 2242 register ssize_t 2243 x; 2244 2245 ssize_t 2246 bit; 2247 2248 if (image->storage_class != PseudoClass) 2249 { 2250 (void) ThrowMagickException(exception,GetMagickModule(),ImageError, 2251 "ColormappedImageRequired","`%s'",image->filename); 2252 return; 2253 } 2254 switch (quantum_info->depth) 2255 { 2256 case 1: 2257 { 2258 register unsigned char 2259 pixel; 2260 2261 for (x=((ssize_t) number_pixels-3); x > 0; x-=4) 2262 { 2263 pixel=(unsigned char) GetPixelIndex(image,p); 2264 *q=((pixel & 0x01) << 7); 2265 pixel=(unsigned char) (GetPixelAlpha(image,p) == (Quantum) 2266 TransparentAlpha ? 1 : 0); 2267 *q|=((pixel & 0x01) << 6); 2268 p+=GetPixelChannels(image); 2269 pixel=(unsigned char) GetPixelIndex(image,p); 2270 *q|=((pixel & 0x01) << 5); 2271 pixel=(unsigned char) (GetPixelAlpha(image,p) == (Quantum) 2272 TransparentAlpha ? 1 : 0); 2273 *q|=((pixel & 0x01) << 4); 2274 p+=GetPixelChannels(image); 2275 pixel=(unsigned char) GetPixelIndex(image,p); 2276 *q|=((pixel & 0x01) << 3); 2277 pixel=(unsigned char) (GetPixelAlpha(image,p) == (Quantum) 2278 TransparentAlpha ? 1 : 0); 2279 *q|=((pixel & 0x01) << 2); 2280 p+=GetPixelChannels(image); 2281 pixel=(unsigned char) GetPixelIndex(image,p); 2282 *q|=((pixel & 0x01) << 1); 2283 pixel=(unsigned char) (GetPixelAlpha(image,p) == (Quantum) 2284 TransparentAlpha ? 1 : 0); 2285 *q|=((pixel & 0x01) << 0); 2286 p+=GetPixelChannels(image); 2287 q++; 2288 } 2289 if ((number_pixels % 4) != 0) 2290 { 2291 *q='\0'; 2292 for (bit=3; bit >= (ssize_t) (4-(number_pixels % 4)); bit-=2) 2293 { 2294 pixel=(unsigned char) GetPixelIndex(image,p); 2295 *q|=((pixel & 0x01) << (unsigned char) (bit+4)); 2296 pixel=(unsigned char) (GetPixelAlpha(image,p) == (Quantum) 2297 TransparentAlpha ? 1 : 0); 2298 *q|=((pixel & 0x01) << (unsigned char) (bit+4-1)); 2299 p+=GetPixelChannels(image); 2300 } 2301 q++; 2302 } 2303 break; 2304 } 2305 case 4: 2306 { 2307 register unsigned char 2308 pixel; 2309 2310 for (x=0; x < (ssize_t) number_pixels ; x++) 2311 { 2312 pixel=(unsigned char) GetPixelIndex(image,p); 2313 *q=((pixel & 0xf) << 4); 2314 pixel=(unsigned char) (16*QuantumScale*GetPixelAlpha(image,p)+0.5); 2315 *q|=((pixel & 0xf) << 0); 2316 p+=GetPixelChannels(image); 2317 q++; 2318 } 2319 break; 2320 } 2321 case 8: 2322 { 2323 register unsigned char 2324 pixel; 2325 2326 for (x=0; x < (ssize_t) number_pixels; x++) 2327 { 2328 q=PopCharPixel((unsigned char) GetPixelIndex(image,p),q); 2329 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p)); 2330 q=PopCharPixel(pixel,q); 2331 p+=GetPixelChannels(image); 2332 q+=quantum_info->pad; 2333 } 2334 break; 2335 } 2336 case 16: 2337 { 2338 register unsigned short 2339 pixel; 2340 2341 if (quantum_info->format == FloatingPointQuantumFormat) 2342 { 2343 for (x=0; x < (ssize_t) number_pixels; x++) 2344 { 2345 q=PopShortPixel(quantum_info->endian,(unsigned short) GetPixelIndex(image,p),q); 2346 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelAlpha(image,p)); 2347 q=PopShortPixel(quantum_info->endian,pixel,q); 2348 p+=GetPixelChannels(image); 2349 q+=quantum_info->pad; 2350 } 2351 break; 2352 } 2353 for (x=0; x < (ssize_t) number_pixels; x++) 2354 { 2355 q=PopShortPixel(quantum_info->endian,(unsigned short) GetPixelIndex(image,p),q); 2356 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p)); 2357 q=PopShortPixel(quantum_info->endian,pixel,q); 2358 p+=GetPixelChannels(image); 2359 q+=quantum_info->pad; 2360 } 2361 break; 2362 } 2363 case 32: 2364 { 2365 register unsigned int 2366 pixel; 2367 2368 if (quantum_info->format == FloatingPointQuantumFormat) 2369 { 2370 for (x=0; x < (ssize_t) number_pixels; x++) 2371 { 2372 float 2373 pixel; 2374 2375 q=PopFloatPixel(quantum_info,(float) GetPixelIndex(image,p),q); 2376 pixel=(float) GetPixelAlpha(image,p); 2377 q=PopFloatPixel(quantum_info,pixel,q); 2378 p+=GetPixelChannels(image); 2379 q+=quantum_info->pad; 2380 } 2381 break; 2382 } 2383 for (x=0; x < (ssize_t) number_pixels; x++) 2384 { 2385 q=PopLongPixel(quantum_info->endian,(unsigned int) GetPixelIndex(image,p),q); 2386 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p)); 2387 q=PopLongPixel(quantum_info->endian,pixel,q); 2388 p+=GetPixelChannels(image); 2389 q+=quantum_info->pad; 2390 } 2391 break; 2392 } 2393 case 64: 2394 { 2395 if (quantum_info->format == FloatingPointQuantumFormat) 2396 { 2397 for (x=0; x < (ssize_t) number_pixels; x++) 2398 { 2399 double 2400 pixel; 2401 2402 q=PopDoublePixel(quantum_info,(double) GetPixelIndex(image,p),q); 2403 pixel=(double) GetPixelAlpha(image,p); 2404 q=PopDoublePixel(quantum_info,pixel,q); 2405 p+=GetPixelChannels(image); 2406 q+=quantum_info->pad; 2407 } 2408 break; 2409 } 2410 } 2411 default: 2412 { 2413 QuantumAny 2414 range; 2415 2416 range=GetQuantumRange(quantum_info->depth); 2417 for (x=0; x < (ssize_t) number_pixels; x++) 2418 { 2419 q=PopQuantumPixel(quantum_info,GetPixelIndex(image,p),q); 2420 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p), 2421 range),q); 2422 p+=GetPixelChannels(image); 2423 q+=quantum_info->pad; 2424 } 2425 break; 2426 } 2427 } 2428} 2429 2430static void ExportOpacityQuantum(const Image *image,QuantumInfo *quantum_info, 2431 const MagickSizeType number_pixels,const Quantum *restrict p, 2432 unsigned char *restrict q,ExceptionInfo *exception) 2433{ 2434 QuantumAny 2435 range; 2436 2437 register ssize_t 2438 x; 2439 2440 switch (quantum_info->depth) 2441 { 2442 case 8: 2443 { 2444 register unsigned char 2445 pixel; 2446 2447 for (x=0; x < (ssize_t) number_pixels; x++) 2448 { 2449 pixel=ScaleQuantumToChar(GetPixelOpacity(image,p)); 2450 q=PopCharPixel(pixel,q); 2451 p+=GetPixelChannels(image); 2452 q+=quantum_info->pad; 2453 } 2454 break; 2455 } 2456 case 16: 2457 { 2458 register unsigned short 2459 pixel; 2460 2461 if (quantum_info->format == FloatingPointQuantumFormat) 2462 { 2463 for (x=0; x < (ssize_t) number_pixels; x++) 2464 { 2465 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelOpacity(image,p)); 2466 q=PopShortPixel(quantum_info->endian,pixel,q); 2467 p+=GetPixelChannels(image); 2468 q+=quantum_info->pad; 2469 } 2470 break; 2471 } 2472 for (x=0; x < (ssize_t) number_pixels; x++) 2473 { 2474 pixel=ScaleQuantumToShort(GetPixelOpacity(image,p)); 2475 q=PopShortPixel(quantum_info->endian,pixel,q); 2476 p+=GetPixelChannels(image); 2477 q+=quantum_info->pad; 2478 } 2479 break; 2480 } 2481 case 32: 2482 { 2483 register unsigned int 2484 pixel; 2485 2486 if (quantum_info->format == FloatingPointQuantumFormat) 2487 { 2488 for (x=0; x < (ssize_t) number_pixels; x++) 2489 { 2490 q=PopFloatPixel(quantum_info,(float) GetPixelOpacity(image,p),q); 2491 p+=GetPixelChannels(image); 2492 q+=quantum_info->pad; 2493 } 2494 break; 2495 } 2496 for (x=0; x < (ssize_t) number_pixels; x++) 2497 { 2498 pixel=ScaleQuantumToLong(GetPixelOpacity(image,p)); 2499 q=PopLongPixel(quantum_info->endian,pixel,q); 2500 p+=GetPixelChannels(image); 2501 q+=quantum_info->pad; 2502 } 2503 break; 2504 } 2505 case 64: 2506 { 2507 if (quantum_info->format == FloatingPointQuantumFormat) 2508 { 2509 for (x=0; x < (ssize_t) number_pixels; x++) 2510 { 2511 q=PopDoublePixel(quantum_info,(double) GetPixelOpacity(image,p),q); 2512 p+=GetPixelChannels(image); 2513 q+=quantum_info->pad; 2514 } 2515 break; 2516 } 2517 } 2518 default: 2519 { 2520 range=GetQuantumRange(quantum_info->depth); 2521 for (x=0; x < (ssize_t) number_pixels; x++) 2522 { 2523 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny( 2524 GetPixelOpacity(image,p),range),q); 2525 p+=GetPixelChannels(image); 2526 q+=quantum_info->pad; 2527 } 2528 break; 2529 } 2530 } 2531} 2532 2533static void ExportRedQuantum(const Image *image,QuantumInfo *quantum_info, 2534 const MagickSizeType number_pixels,const Quantum *restrict p, 2535 unsigned char *restrict q,ExceptionInfo *exception) 2536{ 2537 QuantumAny 2538 range; 2539 2540 register ssize_t 2541 x; 2542 2543 switch (quantum_info->depth) 2544 { 2545 case 8: 2546 { 2547 register unsigned char 2548 pixel; 2549 2550 for (x=0; x < (ssize_t) number_pixels; x++) 2551 { 2552 pixel=ScaleQuantumToChar(GetPixelRed(image,p)); 2553 q=PopCharPixel(pixel,q); 2554 p+=GetPixelChannels(image); 2555 q+=quantum_info->pad; 2556 } 2557 break; 2558 } 2559 case 16: 2560 { 2561 register unsigned short 2562 pixel; 2563 2564 if (quantum_info->format == FloatingPointQuantumFormat) 2565 { 2566 for (x=0; x < (ssize_t) number_pixels; x++) 2567 { 2568 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelRed(image,p)); 2569 q=PopShortPixel(quantum_info->endian,pixel,q); 2570 p+=GetPixelChannels(image); 2571 q+=quantum_info->pad; 2572 } 2573 break; 2574 } 2575 for (x=0; x < (ssize_t) number_pixels; x++) 2576 { 2577 pixel=ScaleQuantumToShort(GetPixelRed(image,p)); 2578 q=PopShortPixel(quantum_info->endian,pixel,q); 2579 p+=GetPixelChannels(image); 2580 q+=quantum_info->pad; 2581 } 2582 break; 2583 } 2584 case 32: 2585 { 2586 register unsigned int 2587 pixel; 2588 2589 if (quantum_info->format == FloatingPointQuantumFormat) 2590 { 2591 for (x=0; x < (ssize_t) number_pixels; x++) 2592 { 2593 q=PopFloatPixel(quantum_info,(float) GetPixelRed(image,p),q); 2594 p+=GetPixelChannels(image); 2595 q+=quantum_info->pad; 2596 } 2597 break; 2598 } 2599 for (x=0; x < (ssize_t) number_pixels; x++) 2600 { 2601 pixel=ScaleQuantumToLong(GetPixelRed(image,p)); 2602 q=PopLongPixel(quantum_info->endian,pixel,q); 2603 p+=GetPixelChannels(image); 2604 q+=quantum_info->pad; 2605 } 2606 break; 2607 } 2608 case 64: 2609 { 2610 if (quantum_info->format == FloatingPointQuantumFormat) 2611 { 2612 for (x=0; x < (ssize_t) number_pixels; x++) 2613 { 2614 q=PopDoublePixel(quantum_info,(double) GetPixelRed(image,p),q); 2615 p+=GetPixelChannels(image); 2616 q+=quantum_info->pad; 2617 } 2618 break; 2619 } 2620 } 2621 default: 2622 { 2623 range=GetQuantumRange(quantum_info->depth); 2624 for (x=0; x < (ssize_t) number_pixels; x++) 2625 { 2626 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p), 2627 range),q); 2628 p+=GetPixelChannels(image); 2629 q+=quantum_info->pad; 2630 } 2631 break; 2632 } 2633 } 2634} 2635 2636static void ExportRGBQuantum(const Image *image,QuantumInfo *quantum_info, 2637 const MagickSizeType number_pixels,const Quantum *restrict p, 2638 unsigned char *restrict q,ExceptionInfo *exception) 2639{ 2640 QuantumAny 2641 range; 2642 2643 register ssize_t 2644 x; 2645 2646 ssize_t 2647 bit; 2648 2649 switch (quantum_info->depth) 2650 { 2651 case 8: 2652 { 2653 for (x=0; x < (ssize_t) number_pixels; x++) 2654 { 2655 q=PopCharPixel(ScaleQuantumToChar(GetPixelRed(image,p)),q); 2656 q=PopCharPixel(ScaleQuantumToChar(GetPixelGreen(image,p)),q); 2657 q=PopCharPixel(ScaleQuantumToChar(GetPixelBlue(image,p)),q); 2658 p+=GetPixelChannels(image); 2659 q+=quantum_info->pad; 2660 } 2661 break; 2662 } 2663 case 10: 2664 { 2665 register unsigned int 2666 pixel; 2667 2668 range=GetQuantumRange(quantum_info->depth); 2669 if (quantum_info->pack == MagickFalse) 2670 { 2671 for (x=0; x < (ssize_t) number_pixels; x++) 2672 { 2673 pixel=(unsigned int) ( 2674 ScaleQuantumToAny(GetPixelRed(image,p),range) << 22 | 2675 ScaleQuantumToAny(GetPixelGreen(image,p),range) << 12 | 2676 ScaleQuantumToAny(GetPixelBlue(image,p),range) << 2); 2677 q=PopLongPixel(quantum_info->endian,pixel,q); 2678 p+=GetPixelChannels(image); 2679 q+=quantum_info->pad; 2680 } 2681 break; 2682 } 2683 if (quantum_info->quantum == 32UL) 2684 { 2685 for (x=0; x < (ssize_t) number_pixels; x++) 2686 { 2687 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); 2688 q=PopQuantumLongPixel(quantum_info,pixel,q); 2689 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), 2690 range); 2691 q=PopQuantumLongPixel(quantum_info,pixel,q); 2692 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); 2693 q=PopQuantumLongPixel(quantum_info,pixel,q); 2694 p+=GetPixelChannels(image); 2695 q+=quantum_info->pad; 2696 } 2697 break; 2698 } 2699 for (x=0; x < (ssize_t) number_pixels; x++) 2700 { 2701 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); 2702 q=PopQuantumPixel(quantum_info,pixel,q); 2703 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range); 2704 q=PopQuantumPixel(quantum_info,pixel,q); 2705 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); 2706 q=PopQuantumPixel(quantum_info,pixel,q); 2707 p+=GetPixelChannels(image); 2708 q+=quantum_info->pad; 2709 } 2710 break; 2711 } 2712 case 12: 2713 { 2714 register unsigned int 2715 pixel; 2716 2717 range=GetQuantumRange(quantum_info->depth); 2718 if (quantum_info->pack == MagickFalse) 2719 { 2720 for (x=0; x < (ssize_t) (3*number_pixels-1); x+=2) 2721 { 2722 switch (x % 3) 2723 { 2724 default: 2725 case 0: 2726 { 2727 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p), 2728 range); 2729 break; 2730 } 2731 case 1: 2732 { 2733 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), 2734 range); 2735 break; 2736 } 2737 case 2: 2738 { 2739 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p), 2740 range); 2741 p+=GetPixelChannels(image); 2742 break; 2743 } 2744 } 2745 q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel << 4),q); 2746 switch ((x+1) % 3) 2747 { 2748 default: 2749 case 0: 2750 { 2751 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p), 2752 range); 2753 break; 2754 } 2755 case 1: 2756 { 2757 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), 2758 range); 2759 break; 2760 } 2761 case 2: 2762 { 2763 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p), 2764 range); 2765 p+=GetPixelChannels(image); 2766 break; 2767 } 2768 } 2769 q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel << 4),q); 2770 q+=quantum_info->pad; 2771 } 2772 for (bit=0; bit < (ssize_t) (3*number_pixels % 2); bit++) 2773 { 2774 switch ((x+bit) % 3) 2775 { 2776 default: 2777 case 0: 2778 { 2779 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p), 2780 range); 2781 break; 2782 } 2783 case 1: 2784 { 2785 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), 2786 range); 2787 break; 2788 } 2789 case 2: 2790 { 2791 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p), 2792 range); 2793 p+=GetPixelChannels(image); 2794 break; 2795 } 2796 } 2797 q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel << 4),q); 2798 q+=quantum_info->pad; 2799 } 2800 if (bit != 0) 2801 p+=GetPixelChannels(image); 2802 break; 2803 } 2804 if (quantum_info->quantum == 32UL) 2805 { 2806 for (x=0; x < (ssize_t) number_pixels; x++) 2807 { 2808 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); 2809 q=PopQuantumLongPixel(quantum_info,pixel,q); 2810 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), 2811 range); 2812 q=PopQuantumLongPixel(quantum_info,pixel,q); 2813 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); 2814 q=PopQuantumLongPixel(quantum_info,pixel,q); 2815 p+=GetPixelChannels(image); 2816 q+=quantum_info->pad; 2817 } 2818 break; 2819 } 2820 for (x=0; x < (ssize_t) number_pixels; x++) 2821 { 2822 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); 2823 q=PopQuantumPixel(quantum_info,pixel,q); 2824 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range); 2825 q=PopQuantumPixel(quantum_info,pixel,q); 2826 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); 2827 q=PopQuantumPixel(quantum_info,pixel,q); 2828 p+=GetPixelChannels(image); 2829 q+=quantum_info->pad; 2830 } 2831 break; 2832 } 2833 case 16: 2834 { 2835 register unsigned short 2836 pixel; 2837 2838 if (quantum_info->format == FloatingPointQuantumFormat) 2839 { 2840 for (x=0; x < (ssize_t) number_pixels; x++) 2841 { 2842 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelRed(image,p)); 2843 q=PopShortPixel(quantum_info->endian,pixel,q); 2844 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelGreen(image,p)); 2845 q=PopShortPixel(quantum_info->endian,pixel,q); 2846 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlue(image,p)); 2847 q=PopShortPixel(quantum_info->endian,pixel,q); 2848 p+=GetPixelChannels(image); 2849 q+=quantum_info->pad; 2850 } 2851 break; 2852 } 2853 for (x=0; x < (ssize_t) number_pixels; x++) 2854 { 2855 pixel=ScaleQuantumToShort(GetPixelRed(image,p)); 2856 q=PopShortPixel(quantum_info->endian,pixel,q); 2857 pixel=ScaleQuantumToShort(GetPixelGreen(image,p)); 2858 q=PopShortPixel(quantum_info->endian,pixel,q); 2859 pixel=ScaleQuantumToShort(GetPixelBlue(image,p)); 2860 q=PopShortPixel(quantum_info->endian,pixel,q); 2861 p+=GetPixelChannels(image); 2862 q+=quantum_info->pad; 2863 } 2864 break; 2865 } 2866 case 32: 2867 { 2868 register unsigned int 2869 pixel; 2870 2871 if (quantum_info->format == FloatingPointQuantumFormat) 2872 { 2873 for (x=0; x < (ssize_t) number_pixels; x++) 2874 { 2875 q=PopFloatPixel(quantum_info,(float) GetPixelRed(image,p),q); 2876 q=PopFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q); 2877 q=PopFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q); 2878 p+=GetPixelChannels(image); 2879 q+=quantum_info->pad; 2880 } 2881 break; 2882 } 2883 for (x=0; x < (ssize_t) number_pixels; x++) 2884 { 2885 pixel=ScaleQuantumToLong(GetPixelRed(image,p)); 2886 q=PopLongPixel(quantum_info->endian,pixel,q); 2887 pixel=ScaleQuantumToLong(GetPixelGreen(image,p)); 2888 q=PopLongPixel(quantum_info->endian,pixel,q); 2889 pixel=ScaleQuantumToLong(GetPixelBlue(image,p)); 2890 q=PopLongPixel(quantum_info->endian,pixel,q); 2891 p+=GetPixelChannels(image); 2892 q+=quantum_info->pad; 2893 } 2894 break; 2895 } 2896 case 64: 2897 { 2898 if (quantum_info->format == FloatingPointQuantumFormat) 2899 { 2900 for (x=0; x < (ssize_t) number_pixels; x++) 2901 { 2902 q=PopDoublePixel(quantum_info,(double) GetPixelRed(image,p),q); 2903 q=PopDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q); 2904 q=PopDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q); 2905 p+=GetPixelChannels(image); 2906 q+=quantum_info->pad; 2907 } 2908 break; 2909 } 2910 } 2911 default: 2912 { 2913 range=GetQuantumRange(quantum_info->depth); 2914 for (x=0; x < (ssize_t) number_pixels; x++) 2915 { 2916 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p), 2917 range),q); 2918 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p), 2919 range),q); 2920 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p), 2921 range),q); 2922 p+=GetPixelChannels(image); 2923 q+=quantum_info->pad; 2924 } 2925 break; 2926 } 2927 } 2928} 2929 2930static void ExportRGBAQuantum(const Image *image,QuantumInfo *quantum_info, 2931 const MagickSizeType number_pixels,const Quantum *restrict p, 2932 unsigned char *restrict q,ExceptionInfo *exception) 2933{ 2934 QuantumAny 2935 range; 2936 2937 register ssize_t 2938 x; 2939 2940 switch (quantum_info->depth) 2941 { 2942 case 8: 2943 { 2944 register unsigned char 2945 pixel; 2946 2947 for (x=0; x < (ssize_t) number_pixels; x++) 2948 { 2949 pixel=ScaleQuantumToChar(GetPixelRed(image,p)); 2950 q=PopCharPixel(pixel,q); 2951 pixel=ScaleQuantumToChar(GetPixelGreen(image,p)); 2952 q=PopCharPixel(pixel,q); 2953 pixel=ScaleQuantumToChar(GetPixelBlue(image,p)); 2954 q=PopCharPixel(pixel,q); 2955 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p)); 2956 q=PopCharPixel(pixel,q); 2957 p+=GetPixelChannels(image); 2958 q+=quantum_info->pad; 2959 } 2960 break; 2961 } 2962 case 10: 2963 { 2964 register unsigned int 2965 pixel; 2966 2967 range=GetQuantumRange(quantum_info->depth); 2968 if (quantum_info->pack == MagickFalse) 2969 { 2970 register ssize_t 2971 i; 2972 2973 size_t 2974 quantum; 2975 2976 ssize_t 2977 n; 2978 2979 n=0; 2980 quantum=0; 2981 pixel=0; 2982 for (x=0; x < (ssize_t) number_pixels; x++) 2983 { 2984 for (i=0; i < 4; i++) 2985 { 2986 switch (i) 2987 { 2988 case 0: quantum=GetPixelRed(image,p); break; 2989 case 1: quantum=GetPixelGreen(image,p); break; 2990 case 2: quantum=GetPixelBlue(image,p); break; 2991 case 3: quantum=GetPixelAlpha(image,p); break; 2992 } 2993 switch (n % 3) 2994 { 2995 case 0: 2996 { 2997 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum, 2998 range) << 22); 2999 break; 3000 } 3001 case 1: 3002 { 3003 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum, 3004 range) << 12); 3005 break; 3006 } 3007 case 2: 3008 { 3009 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum, 3010 range) << 2); 3011 q=PopLongPixel(quantum_info->endian,pixel,q); 3012 pixel=0; 3013 break; 3014 } 3015 } 3016 n++; 3017 } 3018 p+=GetPixelChannels(image); 3019 q+=quantum_info->pad; 3020 } 3021 break; 3022 } 3023 if (quantum_info->quantum == 32UL) 3024 { 3025 for (x=0; x < (ssize_t) number_pixels; x++) 3026 { 3027 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); 3028 q=PopQuantumLongPixel(quantum_info,pixel,q); 3029 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p), 3030 range); 3031 q=PopQuantumLongPixel(quantum_info,pixel,q); 3032 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); 3033 q=PopQuantumLongPixel(quantum_info,pixel,q); 3034 pixel=(unsigned int) ScaleQuantumToAny(GetPixelAlpha(image,p), 3035 range); 3036 q=PopQuantumLongPixel(quantum_info,pixel,q); 3037 p+=GetPixelChannels(image); 3038 q+=quantum_info->pad; 3039 } 3040 break; 3041 } 3042 for (x=0; x < (ssize_t) number_pixels; x++) 3043 { 3044 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range); 3045 q=PopQuantumPixel(quantum_info,pixel,q); 3046 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range); 3047 q=PopQuantumPixel(quantum_info,pixel,q); 3048 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range); 3049 q=PopQuantumPixel(quantum_info,pixel,q); 3050 pixel=(unsigned int) ScaleQuantumToAny(GetPixelAlpha(image,p),range); 3051 q=PopQuantumPixel(quantum_info,pixel,q); 3052 p+=GetPixelChannels(image); 3053 q+=quantum_info->pad; 3054 } 3055 break; 3056 } 3057 case 16: 3058 { 3059 register unsigned short 3060 pixel; 3061 3062 if (quantum_info->format == FloatingPointQuantumFormat) 3063 { 3064 for (x=0; x < (ssize_t) number_pixels; x++) 3065 { 3066 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelRed(image,p)); 3067 q=PopShortPixel(quantum_info->endian,pixel,q); 3068 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelGreen(image,p)); 3069 q=PopShortPixel(quantum_info->endian,pixel,q); 3070 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlue(image,p)); 3071 q=PopShortPixel(quantum_info->endian,pixel,q); 3072 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelAlpha(image,p)); 3073 q=PopShortPixel(quantum_info->endian,pixel,q); 3074 p+=GetPixelChannels(image); 3075 q+=quantum_info->pad; 3076 } 3077 break; 3078 } 3079 for (x=0; x < (ssize_t) number_pixels; x++) 3080 { 3081 pixel=ScaleQuantumToShort(GetPixelRed(image,p)); 3082 q=PopShortPixel(quantum_info->endian,pixel,q); 3083 pixel=ScaleQuantumToShort(GetPixelGreen(image,p)); 3084 q=PopShortPixel(quantum_info->endian,pixel,q); 3085 pixel=ScaleQuantumToShort(GetPixelBlue(image,p)); 3086 q=PopShortPixel(quantum_info->endian,pixel,q); 3087 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p)); 3088 q=PopShortPixel(quantum_info->endian,pixel,q); 3089 p+=GetPixelChannels(image); 3090 q+=quantum_info->pad; 3091 } 3092 break; 3093 } 3094 case 32: 3095 { 3096 register unsigned int 3097 pixel; 3098 3099 if (quantum_info->format == FloatingPointQuantumFormat) 3100 { 3101 for (x=0; x < (ssize_t) number_pixels; x++) 3102 { 3103 float 3104 pixel; 3105 3106 q=PopFloatPixel(quantum_info,(float) GetPixelRed(image,p),q); 3107 q=PopFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q); 3108 q=PopFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q); 3109 pixel=(float) GetPixelAlpha(image,p); 3110 q=PopFloatPixel(quantum_info,pixel,q); 3111 p+=GetPixelChannels(image); 3112 q+=quantum_info->pad; 3113 } 3114 break; 3115 } 3116 for (x=0; x < (ssize_t) number_pixels; x++) 3117 { 3118 pixel=ScaleQuantumToLong(GetPixelRed(image,p)); 3119 q=PopLongPixel(quantum_info->endian,pixel,q); 3120 pixel=ScaleQuantumToLong(GetPixelGreen(image,p)); 3121 q=PopLongPixel(quantum_info->endian,pixel,q); 3122 pixel=ScaleQuantumToLong(GetPixelBlue(image,p)); 3123 q=PopLongPixel(quantum_info->endian,pixel,q); 3124 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p)); 3125 q=PopLongPixel(quantum_info->endian,pixel,q); 3126 p+=GetPixelChannels(image); 3127 q+=quantum_info->pad; 3128 } 3129 break; 3130 } 3131 case 64: 3132 { 3133 if (quantum_info->format == FloatingPointQuantumFormat) 3134 { 3135 double 3136 pixel; 3137 3138 for (x=0; x < (ssize_t) number_pixels; x++) 3139 { 3140 q=PopDoublePixel(quantum_info,(double) GetPixelRed(image,p),q); 3141 q=PopDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q); 3142 q=PopDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q); 3143 pixel=(double) GetPixelAlpha(image,p); 3144 q=PopDoublePixel(quantum_info,pixel,q); 3145 p+=GetPixelChannels(image); 3146 q+=quantum_info->pad; 3147 } 3148 break; 3149 } 3150 } 3151 default: 3152 { 3153 range=GetQuantumRange(quantum_info->depth); 3154 for (x=0; x < (ssize_t) number_pixels; x++) 3155 { 3156 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p), 3157 range),q); 3158 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p), 3159 range),q); 3160 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p), 3161 range),q); 3162 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p), 3163 range),q); 3164 p+=GetPixelChannels(image); 3165 q+=quantum_info->pad; 3166 } 3167 break; 3168 } 3169 } 3170} 3171 3172MagickExport size_t ExportQuantumPixels(Image *image,CacheView *image_view, 3173 QuantumInfo *quantum_info,const QuantumType quantum_type, 3174 unsigned char *pixels,ExceptionInfo *exception) 3175{ 3176 MagickSizeType 3177 number_pixels; 3178 3179 register const Quantum 3180 *restrict p; 3181 3182 register ssize_t 3183 x; 3184 3185 register unsigned char 3186 *restrict q; 3187 3188 size_t 3189 extent; 3190 3191 assert(image != (Image *) NULL); 3192 assert(image->signature == MagickSignature); 3193 if (image->debug != MagickFalse) 3194 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); 3195 assert(quantum_info != (QuantumInfo *) NULL); 3196 assert(quantum_info->signature == MagickSignature); 3197 if (pixels == (unsigned char *) NULL) 3198 pixels=GetQuantumPixels(quantum_info); 3199 if (image_view == (CacheView *) NULL) 3200 { 3201 number_pixels=GetImageExtent(image); 3202 p=GetVirtualPixelQueue(image); 3203 } 3204 else 3205 { 3206 number_pixels=GetCacheViewExtent(image_view); 3207 p=GetCacheViewVirtualPixelQueue(image_view); 3208 } 3209 if (quantum_info->alpha_type == AssociatedQuantumAlpha) 3210 { 3211 MagickRealType 3212 Sa; 3213 3214 register Quantum 3215 *restrict q; 3216 3217 /* 3218 Associate alpha. 3219 */ 3220 q=GetAuthenticPixelQueue(image); 3221 if (image_view != (CacheView *) NULL) 3222 q=GetCacheViewAuthenticPixelQueue(image_view); 3223 for (x=0; x < (ssize_t) image->columns; x++) 3224 { 3225 register ssize_t 3226 i; 3227 3228 Sa=QuantumScale*GetPixelAlpha(image,q); 3229 for (i=0; i < (ssize_t) GetPixelChannels(image); i++) 3230 { 3231 PixelChannel 3232 channel; 3233 3234 PixelTrait 3235 traits; 3236 3237 channel=GetPixelChannelMapChannel(image,i); 3238 traits=GetPixelChannelMapTraits(image,channel); 3239 if ((traits & UpdatePixelTrait) != 0) 3240 q[i]=ClampToQuantum(Sa*q[i]); 3241 } 3242 q+=GetPixelChannels(image); 3243 } 3244 } 3245 if ((quantum_type == RGBOQuantum) || (quantum_type == CMYKOQuantum) || 3246 (quantum_type == BGROQuantum)) 3247 { 3248 register Quantum 3249 *restrict q; 3250 3251 q=GetAuthenticPixelQueue(image); 3252 if (image_view != (CacheView *) NULL) 3253 q=GetCacheViewAuthenticPixelQueue(image_view); 3254 for (x=0; x < (ssize_t) number_pixels; x++) 3255 { 3256 SetPixelAlpha(image,GetPixelAlpha(image,q),q); 3257 q+=GetPixelChannels(image); 3258 } 3259 } 3260 if ((quantum_type == CbYCrQuantum) || (quantum_type == CbYCrAQuantum)) 3261 { 3262 Quantum 3263 quantum; 3264 3265 register Quantum 3266 *restrict q; 3267 3268 q=GetAuthenticPixelQueue(image); 3269 if (image_view != (CacheView *) NULL) 3270 q=GetAuthenticPixelQueue(image); 3271 for (x=0; x < (ssize_t) number_pixels; x++) 3272 { 3273 quantum=GetPixelRed(image,q); 3274 SetPixelRed(image,GetPixelGreen(image,q),q); 3275 SetPixelGreen(image,quantum,q); 3276 q+=GetPixelChannels(image); 3277 } 3278 } 3279 x=0; 3280 q=pixels; 3281 ResetQuantumState(quantum_info); 3282 extent=GetQuantumExtent(image,quantum_info,quantum_type); 3283 switch (quantum_type) 3284 { 3285 case AlphaQuantum: 3286 { 3287 ExportAlphaQuantum(image,quantum_info,number_pixels,p,q,exception); 3288 break; 3289 } 3290 case BGRQuantum: 3291 { 3292 ExportBGRQuantum(image,quantum_info,number_pixels,p,q,exception); 3293 break; 3294 } 3295 case BGRAQuantum: 3296 case BGROQuantum: 3297 { 3298 ExportBGRAQuantum(image,quantum_info,number_pixels,p,q,exception); 3299 break; 3300 } 3301 case BlackQuantum: 3302 { 3303 ExportBlackQuantum(image,quantum_info,number_pixels,p,q,exception); 3304 break; 3305 } 3306 case BlueQuantum: 3307 case YellowQuantum: 3308 { 3309 ExportBlueQuantum(image,quantum_info,number_pixels,p,q,exception); 3310 break; 3311 } 3312 case CMYKQuantum: 3313 { 3314 ExportCMYKQuantum(image,quantum_info,number_pixels,p,q,exception); 3315 break; 3316 } 3317 case CMYKAQuantum: 3318 case CMYKOQuantum: 3319 { 3320 ExportCMYKAQuantum(image,quantum_info,number_pixels,p,q,exception); 3321 break; 3322 } 3323 case CbYCrYQuantum: 3324 { 3325 ExportCbYCrYQuantum(image,quantum_info,number_pixels,p,q,exception); 3326 break; 3327 } 3328 case GrayQuantum: 3329 { 3330 ExportGrayQuantum(image,quantum_info,number_pixels,p,q,exception); 3331 break; 3332 } 3333 case GrayAlphaQuantum: 3334 { 3335 ExportGrayAlphaQuantum(image,quantum_info,number_pixels,p,q,exception); 3336 break; 3337 } 3338 case GreenQuantum: 3339 case MagentaQuantum: 3340 { 3341 ExportGreenQuantum(image,quantum_info,number_pixels,p,q,exception); 3342 break; 3343 } 3344 case IndexQuantum: 3345 { 3346 ExportIndexQuantum(image,quantum_info,number_pixels,p,q,exception); 3347 break; 3348 } 3349 case IndexAlphaQuantum: 3350 { 3351 ExportIndexAlphaQuantum(image,quantum_info,number_pixels,p,q,exception); 3352 break; 3353 } 3354 case RedQuantum: 3355 case CyanQuantum: 3356 { 3357 ExportRedQuantum(image,quantum_info,number_pixels,p,q,exception); 3358 break; 3359 } 3360 case OpacityQuantum: 3361 { 3362 ExportOpacityQuantum(image,quantum_info,number_pixels,p,q,exception); 3363 break; 3364 } 3365 case RGBQuantum: 3366 case CbYCrQuantum: 3367 { 3368 ExportRGBQuantum(image,quantum_info,number_pixels,p,q,exception); 3369 break; 3370 } 3371 case RGBAQuantum: 3372 case RGBOQuantum: 3373 case CbYCrAQuantum: 3374 { 3375 ExportRGBAQuantum(image,quantum_info,number_pixels,p,q,exception); 3376 break; 3377 } 3378 default: 3379 break; 3380 } 3381 if ((quantum_type == CbYCrQuantum) || (quantum_type == CbYCrAQuantum)) 3382 { 3383 Quantum 3384 quantum; 3385 3386 register Quantum 3387 *restrict q; 3388 3389 q=GetAuthenticPixelQueue(image); 3390 if (image_view != (CacheView *) NULL) 3391 q=GetCacheViewAuthenticPixelQueue(image_view); 3392 for (x=0; x < (ssize_t) number_pixels; x++) 3393 { 3394 quantum=GetPixelRed(image,q); 3395 SetPixelRed(image,GetPixelGreen(image,q),q); 3396 SetPixelGreen(image,quantum,q); 3397 q+=GetPixelChannels(image); 3398 } 3399 } 3400 if ((quantum_type == RGBOQuantum) || (quantum_type == CMYKOQuantum) || 3401 (quantum_type == BGROQuantum)) 3402 { 3403 register Quantum 3404 *restrict q; 3405 3406 q=GetAuthenticPixelQueue(image); 3407 if (image_view != (CacheView *) NULL) 3408 q=GetCacheViewAuthenticPixelQueue(image_view); 3409 for (x=0; x < (ssize_t) number_pixels; x++) 3410 { 3411 SetPixelAlpha(image,GetPixelAlpha(image,q),q); 3412 q+=GetPixelChannels(image); 3413 } 3414 } 3415 return(extent); 3416} 3417