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