2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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 %
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 %
16 % EEEEE X X P OOO R R T %
18 % MagickCore Methods to Export Quantum Pixels %
25 % Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization %
26 % dedicated to making software imaging solutions freely available. %
28 % You may not use this file except in compliance with the License. You may %
29 % obtain a copy of the License at %
31 % http://www.imagemagick.org/script/license.php %
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. %
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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"
75 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
79 + E x p o r t Q u a n t u m P i x e l s %
83 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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.
90 % The format of the ExportQuantumPixels method is:
92 % size_t ExportQuantumPixels(const Image *image,CacheView *image_view,
93 % QuantumInfo *quantum_info,const QuantumType quantum_type,
94 % unsigned char *restrict pixels,ExceptionInfo *exception)
96 % A description of each parameter follows:
100 % o image_view: the image cache view.
102 % o quantum_info: the quantum info.
104 % o quantum_type: Declare which pixel components to transfer (RGB, RGBA,
107 % o pixels: The components are transferred to this buffer.
109 % o exception: return any errors or warnings in this structure.
113 static inline unsigned char *PopDoublePixel(QuantumInfo *quantum_info,
114 const double pixel,unsigned char *restrict pixels)
122 (void) ResetMagickMemory(quantum,0,sizeof(quantum));
123 p=(double *) quantum;
124 *p=(double) (pixel*quantum_info->state.inverse_scale+quantum_info->minimum);
125 if (quantum_info->endian == LSBEndian)
127 *pixels++=quantum[0];
128 *pixels++=quantum[1];
129 *pixels++=quantum[2];
130 *pixels++=quantum[3];
131 *pixels++=quantum[4];
132 *pixels++=quantum[5];
133 *pixels++=quantum[6];
134 *pixels++=quantum[7];
137 *pixels++=quantum[7];
138 *pixels++=quantum[6];
139 *pixels++=quantum[5];
140 *pixels++=quantum[4];
141 *pixels++=quantum[3];
142 *pixels++=quantum[2];
143 *pixels++=quantum[1];
144 *pixels++=quantum[0];
148 static inline unsigned char *PopFloatPixel(QuantumInfo *quantum_info,
149 const float pixel,unsigned char *restrict pixels)
157 (void) ResetMagickMemory(quantum,0,sizeof(quantum));
159 *p=(float) ((double) pixel*quantum_info->state.inverse_scale+
160 quantum_info->minimum);
161 if (quantum_info->endian == LSBEndian)
163 *pixels++=quantum[0];
164 *pixels++=quantum[1];
165 *pixels++=quantum[2];
166 *pixels++=quantum[3];
169 *pixels++=quantum[3];
170 *pixels++=quantum[2];
171 *pixels++=quantum[1];
172 *pixels++=quantum[0];
176 static inline unsigned char *PopQuantumPixel(QuantumInfo *quantum_info,
177 const QuantumAny pixel,unsigned char *restrict pixels)
185 if (quantum_info->state.bits == 0UL)
186 quantum_info->state.bits=8U;
187 for (i=(ssize_t) quantum_info->depth; i > 0L; )
189 quantum_bits=(size_t) i;
190 if (quantum_bits > quantum_info->state.bits)
191 quantum_bits=quantum_info->state.bits;
192 i-=(ssize_t) quantum_bits;
193 if (quantum_info->state.bits == 8UL)
195 quantum_info->state.bits-=quantum_bits;
196 *pixels|=(((pixel >> i) &~ ((~0UL) << quantum_bits)) <<
197 quantum_info->state.bits);
198 if (quantum_info->state.bits == 0UL)
201 quantum_info->state.bits=8UL;
207 static inline unsigned char *PopQuantumLongPixel(QuantumInfo *quantum_info,
208 const size_t pixel,unsigned char *restrict pixels)
216 if (quantum_info->state.bits == 0U)
217 quantum_info->state.bits=32UL;
218 for (i=(ssize_t) quantum_info->depth; i > 0; )
220 quantum_bits=(size_t) i;
221 if (quantum_bits > quantum_info->state.bits)
222 quantum_bits=quantum_info->state.bits;
223 quantum_info->state.pixel|=(((pixel >> (quantum_info->depth-i)) &
224 quantum_info->state.mask[quantum_bits]) << (32U-
225 quantum_info->state.bits));
226 i-=(ssize_t) quantum_bits;
227 quantum_info->state.bits-=quantum_bits;
228 if (quantum_info->state.bits == 0U)
230 pixels=PopLongPixel(quantum_info->endian,quantum_info->state.pixel,
232 quantum_info->state.pixel=0U;
233 quantum_info->state.bits=32U;
239 static void ExportAlphaQuantum(const Image *image,QuantumInfo *quantum_info,
240 const MagickSizeType number_pixels,const Quantum *restrict p,
241 unsigned char *restrict q,ExceptionInfo *exception)
249 assert(exception != (ExceptionInfo *) NULL);
250 assert(exception->signature == MagickSignature);
251 switch (quantum_info->depth)
255 register unsigned char
258 for (x=0; x < (ssize_t) number_pixels; x++)
260 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p));
261 q=PopCharPixel(pixel,q);
262 p+=GetPixelChannels(image);
263 q+=quantum_info->pad;
269 register unsigned short
272 if (quantum_info->format == FloatingPointQuantumFormat)
274 for (x=0; x < (ssize_t) number_pixels; x++)
276 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelAlpha(image,p));
277 q=PopShortPixel(quantum_info->endian,pixel,q);
278 p+=GetPixelChannels(image);
279 q+=quantum_info->pad;
283 for (x=0; x < (ssize_t) number_pixels; x++)
285 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p));
286 q=PopShortPixel(quantum_info->endian,pixel,q);
287 p+=GetPixelChannels(image);
288 q+=quantum_info->pad;
294 register unsigned int
297 if (quantum_info->format == FloatingPointQuantumFormat)
299 for (x=0; x < (ssize_t) number_pixels; x++)
301 q=PopFloatPixel(quantum_info,(float) GetPixelAlpha(image,p),q);
302 p+=GetPixelChannels(image);
303 q+=quantum_info->pad;
307 for (x=0; x < (ssize_t) number_pixels; x++)
309 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p));
310 q=PopLongPixel(quantum_info->endian,pixel,q);
311 p+=GetPixelChannels(image);
312 q+=quantum_info->pad;
318 if (quantum_info->format == FloatingPointQuantumFormat)
320 for (x=0; x < (ssize_t) number_pixels; x++)
322 q=PopDoublePixel(quantum_info,(double) GetPixelAlpha(image,p),q);
323 p+=GetPixelChannels(image);
324 q+=quantum_info->pad;
331 range=GetQuantumRange(quantum_info->depth);
332 for (x=0; x < (ssize_t) number_pixels; x++)
334 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p),
336 p+=GetPixelChannels(image);
337 q+=quantum_info->pad;
344 static void ExportBGRQuantum(const Image *image,QuantumInfo *quantum_info,
345 const MagickSizeType number_pixels,const Quantum *restrict p,
346 unsigned char *restrict q,ExceptionInfo *exception)
357 assert(exception != (ExceptionInfo *) NULL);
358 assert(exception->signature == MagickSignature);
359 switch (quantum_info->depth)
363 for (x=0; x < (ssize_t) number_pixels; x++)
365 q=PopCharPixel(ScaleQuantumToChar(GetPixelBlue(image,p)),q);
366 q=PopCharPixel(ScaleQuantumToChar(GetPixelGreen(image,p)),q);
367 q=PopCharPixel(ScaleQuantumToChar(GetPixelRed(image,p)),q);
368 p+=GetPixelChannels(image);
369 q+=quantum_info->pad;
375 register unsigned int
378 range=GetQuantumRange(quantum_info->depth);
379 if (quantum_info->pack == MagickFalse)
381 for (x=0; x < (ssize_t) number_pixels; x++)
383 pixel=(unsigned int) (
384 ScaleQuantumToAny(GetPixelRed(image,p),range) << 22 |
385 ScaleQuantumToAny(GetPixelGreen(image,p),range) << 12 |
386 ScaleQuantumToAny(GetPixelBlue(image,p),range) << 2);
387 q=PopLongPixel(quantum_info->endian,pixel,q);
388 p+=GetPixelChannels(image);
389 q+=quantum_info->pad;
393 if (quantum_info->quantum == 32UL)
395 for (x=0; x < (ssize_t) number_pixels; x++)
397 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
398 q=PopQuantumLongPixel(quantum_info,pixel,q);
399 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
401 q=PopQuantumLongPixel(quantum_info,pixel,q);
402 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
403 q=PopQuantumLongPixel(quantum_info,pixel,q);
404 p+=GetPixelChannels(image);
405 q+=quantum_info->pad;
409 for (x=0; x < (ssize_t) number_pixels; x++)
411 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
412 q=PopQuantumPixel(quantum_info,pixel,q);
413 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range);
414 q=PopQuantumPixel(quantum_info,pixel,q);
415 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
416 q=PopQuantumPixel(quantum_info,pixel,q);
417 p+=GetPixelChannels(image);
418 q+=quantum_info->pad;
424 register unsigned int
427 range=GetQuantumRange(quantum_info->depth);
428 if (quantum_info->pack == MagickFalse)
430 for (x=0; x < (ssize_t) (3*number_pixels-1); x+=2)
437 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),
443 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
449 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),
451 p+=GetPixelChannels(image);
455 q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel << 4),
462 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),
468 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
474 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),
476 p+=GetPixelChannels(image);
480 q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel << 4),
482 q+=quantum_info->pad;
484 for (bit=0; bit < (ssize_t) (3*number_pixels % 2); bit++)
491 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),
497 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
503 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),
505 p+=GetPixelChannels(image);
509 q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel << 4),
511 q+=quantum_info->pad;
514 p+=GetPixelChannels(image);
517 if (quantum_info->quantum == 32UL)
519 for (x=0; x < (ssize_t) number_pixels; x++)
521 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
522 q=PopQuantumLongPixel(quantum_info,pixel,q);
523 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
525 q=PopQuantumLongPixel(quantum_info,pixel,q);
526 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
527 q=PopQuantumLongPixel(quantum_info,pixel,q);
528 p+=GetPixelChannels(image);
529 q+=quantum_info->pad;
533 for (x=0; x < (ssize_t) number_pixels; x++)
535 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
536 q=PopQuantumPixel(quantum_info,pixel,q);
537 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range);
538 q=PopQuantumPixel(quantum_info,pixel,q);
539 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
540 q=PopQuantumPixel(quantum_info,pixel,q);
541 p+=GetPixelChannels(image);
542 q+=quantum_info->pad;
548 register unsigned short
551 if (quantum_info->format == FloatingPointQuantumFormat)
553 for (x=0; x < (ssize_t) number_pixels; x++)
555 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlue(image,p));
556 q=PopShortPixel(quantum_info->endian,pixel,q);
557 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelGreen(image,p));
558 q=PopShortPixel(quantum_info->endian,pixel,q);
559 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelRed(image,p));
560 q=PopShortPixel(quantum_info->endian,pixel,q);
561 p+=GetPixelChannels(image);
562 q+=quantum_info->pad;
566 for (x=0; x < (ssize_t) number_pixels; x++)
568 pixel=ScaleQuantumToShort(GetPixelBlue(image,p));
569 q=PopShortPixel(quantum_info->endian,pixel,q);
570 pixel=ScaleQuantumToShort(GetPixelGreen(image,p));
571 q=PopShortPixel(quantum_info->endian,pixel,q);
572 pixel=ScaleQuantumToShort(GetPixelRed(image,p));
573 q=PopShortPixel(quantum_info->endian,pixel,q);
574 p+=GetPixelChannels(image);
575 q+=quantum_info->pad;
581 register unsigned int
584 if (quantum_info->format == FloatingPointQuantumFormat)
586 for (x=0; x < (ssize_t) number_pixels; x++)
588 q=PopFloatPixel(quantum_info,(float) GetPixelRed(image,p),q);
589 q=PopFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q);
590 q=PopFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q);
591 p+=GetPixelChannels(image);
592 q+=quantum_info->pad;
596 for (x=0; x < (ssize_t) number_pixels; x++)
598 pixel=ScaleQuantumToLong(GetPixelBlue(image,p));
599 q=PopLongPixel(quantum_info->endian,pixel,q);
600 pixel=ScaleQuantumToLong(GetPixelGreen(image,p));
601 q=PopLongPixel(quantum_info->endian,pixel,q);
602 pixel=ScaleQuantumToLong(GetPixelRed(image,p));
603 q=PopLongPixel(quantum_info->endian,pixel,q);
604 p+=GetPixelChannels(image);
605 q+=quantum_info->pad;
611 if (quantum_info->format == FloatingPointQuantumFormat)
613 for (x=0; x < (ssize_t) number_pixels; x++)
615 q=PopDoublePixel(quantum_info,(double) GetPixelRed(image,p),q);
616 q=PopDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q);
617 q=PopDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q);
618 p+=GetPixelChannels(image);
619 q+=quantum_info->pad;
626 range=GetQuantumRange(quantum_info->depth);
627 for (x=0; x < (ssize_t) number_pixels; x++)
629 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p),
631 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p),
633 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p),
635 p+=GetPixelChannels(image);
636 q+=quantum_info->pad;
643 static void ExportBGRAQuantum(const Image *image,QuantumInfo *quantum_info,
644 const MagickSizeType number_pixels,const Quantum *restrict p,
645 unsigned char *restrict q,ExceptionInfo *exception)
653 assert(exception != (ExceptionInfo *) NULL);
654 assert(exception->signature == MagickSignature);
655 switch (quantum_info->depth)
659 register unsigned char
662 for (x=0; x < (ssize_t) number_pixels; x++)
664 pixel=ScaleQuantumToChar(GetPixelBlue(image,p));
665 q=PopCharPixel(pixel,q);
666 pixel=ScaleQuantumToChar(GetPixelGreen(image,p));
667 q=PopCharPixel(pixel,q);
668 pixel=ScaleQuantumToChar(GetPixelRed(image,p));
669 q=PopCharPixel(pixel,q);
670 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p));
671 q=PopCharPixel(pixel,q);
672 p+=GetPixelChannels(image);
673 q+=quantum_info->pad;
679 register unsigned int
682 range=GetQuantumRange(quantum_info->depth);
683 if (quantum_info->pack == MagickFalse)
697 for (x=0; x < (ssize_t) number_pixels; x++)
699 for (i=0; i < 4; i++)
703 case 0: quantum=GetPixelRed(image,p); break;
704 case 1: quantum=GetPixelGreen(image,p); break;
705 case 2: quantum=GetPixelBlue(image,p); break;
706 case 3: quantum=GetPixelAlpha(image,p); break;
712 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum,
718 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum,
724 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum,
726 q=PopLongPixel(quantum_info->endian,pixel,q);
733 p+=GetPixelChannels(image);
734 q+=quantum_info->pad;
738 if (quantum_info->quantum == 32UL)
740 for (x=0; x < (ssize_t) number_pixels; x++)
742 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
743 q=PopQuantumLongPixel(quantum_info,pixel,q);
744 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
746 q=PopQuantumLongPixel(quantum_info,pixel,q);
747 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
748 q=PopQuantumLongPixel(quantum_info,pixel,q);
749 pixel=(unsigned int) ScaleQuantumToAny(GetPixelAlpha(image,p),
751 q=PopQuantumLongPixel(quantum_info,pixel,q);
752 p+=GetPixelChannels(image);
753 q+=quantum_info->pad;
757 for (x=0; x < (ssize_t) number_pixels; x++)
759 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
760 q=PopQuantumPixel(quantum_info,pixel,q);
761 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range);
762 q=PopQuantumPixel(quantum_info,pixel,q);
763 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
764 q=PopQuantumPixel(quantum_info,pixel,q);
765 pixel=(unsigned int) ScaleQuantumToAny(GetPixelAlpha(image,p),range);
766 q=PopQuantumPixel(quantum_info,pixel,q);
767 p+=GetPixelChannels(image);
768 q+=quantum_info->pad;
774 register unsigned short
777 if (quantum_info->format == FloatingPointQuantumFormat)
779 for (x=0; x < (ssize_t) number_pixels; x++)
781 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlue(image,p));
782 q=PopShortPixel(quantum_info->endian,pixel,q);
783 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelGreen(image,p));
784 q=PopShortPixel(quantum_info->endian,pixel,q);
785 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelRed(image,p));
786 q=PopShortPixel(quantum_info->endian,pixel,q);
787 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelAlpha(image,p));
788 q=PopShortPixel(quantum_info->endian,pixel,q);
789 p+=GetPixelChannels(image);
790 q+=quantum_info->pad;
794 for (x=0; x < (ssize_t) number_pixels; x++)
796 pixel=ScaleQuantumToShort(GetPixelBlue(image,p));
797 q=PopShortPixel(quantum_info->endian,pixel,q);
798 pixel=ScaleQuantumToShort(GetPixelGreen(image,p));
799 q=PopShortPixel(quantum_info->endian,pixel,q);
800 pixel=ScaleQuantumToShort(GetPixelRed(image,p));
801 q=PopShortPixel(quantum_info->endian,pixel,q);
802 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p));
803 q=PopShortPixel(quantum_info->endian,pixel,q);
804 p+=GetPixelChannels(image);
805 q+=quantum_info->pad;
811 register unsigned int
814 if (quantum_info->format == FloatingPointQuantumFormat)
816 for (x=0; x < (ssize_t) number_pixels; x++)
821 q=PopFloatPixel(quantum_info,(float) GetPixelRed(image,p),q);
822 q=PopFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q);
823 q=PopFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q);
824 pixel=(float) GetPixelAlpha(image,p);
825 q=PopFloatPixel(quantum_info,pixel,q);
826 p+=GetPixelChannels(image);
827 q+=quantum_info->pad;
831 for (x=0; x < (ssize_t) number_pixels; x++)
833 pixel=ScaleQuantumToLong(GetPixelBlue(image,p));
834 q=PopLongPixel(quantum_info->endian,pixel,q);
835 pixel=ScaleQuantumToLong(GetPixelGreen(image,p));
836 q=PopLongPixel(quantum_info->endian,pixel,q);
837 pixel=ScaleQuantumToLong(GetPixelRed(image,p));
838 q=PopLongPixel(quantum_info->endian,pixel,q);
839 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p));
840 q=PopLongPixel(quantum_info->endian,pixel,q);
841 p+=GetPixelChannels(image);
842 q+=quantum_info->pad;
848 if (quantum_info->format == FloatingPointQuantumFormat)
853 for (x=0; x < (ssize_t) number_pixels; x++)
855 q=PopDoublePixel(quantum_info,(double) GetPixelRed(image,p),q);
856 q=PopDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q);
857 q=PopDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q);
858 pixel=(double) GetPixelAlpha(image,p);
859 q=PopDoublePixel(quantum_info,pixel,q);
860 p+=GetPixelChannels(image);
861 q+=quantum_info->pad;
868 range=GetQuantumRange(quantum_info->depth);
869 for (x=0; x < (ssize_t) number_pixels; x++)
871 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p),
873 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p),
875 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p),
877 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p),
879 p+=GetPixelChannels(image);
880 q+=quantum_info->pad;
887 static void ExportBlackQuantum(const Image *image,QuantumInfo *quantum_info,
888 const MagickSizeType number_pixels,const Quantum *restrict p,
889 unsigned char *restrict q,ExceptionInfo *exception)
897 if (image->colorspace != CMYKColorspace)
899 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
900 "ColorSeparatedImageRequired","`%s'",image->filename);
903 switch (quantum_info->depth)
907 register unsigned char
910 for (x=0; x < (ssize_t) number_pixels; x++)
912 pixel=ScaleQuantumToChar(GetPixelBlack(image,p));
913 q=PopCharPixel(pixel,q);
914 p+=GetPixelChannels(image);
915 q+=quantum_info->pad;
921 register unsigned short
924 if (quantum_info->format == FloatingPointQuantumFormat)
926 for (x=0; x < (ssize_t) number_pixels; x++)
928 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlack(image,p));
929 q=PopShortPixel(quantum_info->endian,pixel,q);
930 p+=GetPixelChannels(image);
931 q+=quantum_info->pad;
935 for (x=0; x < (ssize_t) number_pixels; x++)
937 pixel=ScaleQuantumToShort(GetPixelBlack(image,p));
938 q=PopShortPixel(quantum_info->endian,pixel,q);
939 p+=GetPixelChannels(image);
940 q+=quantum_info->pad;
946 register unsigned int
949 if (quantum_info->format == FloatingPointQuantumFormat)
951 for (x=0; x < (ssize_t) number_pixels; x++)
953 q=PopFloatPixel(quantum_info,(float) GetPixelBlack(image,p),q);
954 p+=GetPixelChannels(image);
955 q+=quantum_info->pad;
959 for (x=0; x < (ssize_t) number_pixels; x++)
961 pixel=ScaleQuantumToLong(GetPixelBlack(image,p));
962 q=PopLongPixel(quantum_info->endian,pixel,q);
963 p+=GetPixelChannels(image);
964 q+=quantum_info->pad;
970 if (quantum_info->format == FloatingPointQuantumFormat)
972 for (x=0; x < (ssize_t) number_pixels; x++)
974 q=PopDoublePixel(quantum_info,(double) GetPixelBlack(image,p),q);
975 p+=GetPixelChannels(image);
976 q+=quantum_info->pad;
983 range=GetQuantumRange(quantum_info->depth);
984 for (x=0; x < (ssize_t) number_pixels; x++)
986 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlack(image,p),
988 p+=GetPixelChannels(image);
989 q+=quantum_info->pad;
996 static void ExportBlueQuantum(const Image *image,QuantumInfo *quantum_info,
997 const MagickSizeType number_pixels,const Quantum *restrict p,
998 unsigned char *restrict q,ExceptionInfo *exception)
1006 assert(exception != (ExceptionInfo *) NULL);
1007 assert(exception->signature == MagickSignature);
1008 switch (quantum_info->depth)
1012 register unsigned char
1015 for (x=0; x < (ssize_t) number_pixels; x++)
1017 pixel=ScaleQuantumToChar(GetPixelBlue(image,p));
1018 q=PopCharPixel(pixel,q);
1019 p+=GetPixelChannels(image);
1020 q+=quantum_info->pad;
1026 register unsigned short
1029 if (quantum_info->format == FloatingPointQuantumFormat)
1031 for (x=0; x < (ssize_t) number_pixels; x++)
1033 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlue(image,p));
1034 q=PopShortPixel(quantum_info->endian,pixel,q);
1035 p+=GetPixelChannels(image);
1036 q+=quantum_info->pad;
1040 for (x=0; x < (ssize_t) number_pixels; x++)
1042 pixel=ScaleQuantumToShort(GetPixelBlue(image,p));
1043 q=PopShortPixel(quantum_info->endian,pixel,q);
1044 p+=GetPixelChannels(image);
1045 q+=quantum_info->pad;
1051 register unsigned int
1054 if (quantum_info->format == FloatingPointQuantumFormat)
1056 for (x=0; x < (ssize_t) number_pixels; x++)
1058 q=PopFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q);
1059 p+=GetPixelChannels(image);
1060 q+=quantum_info->pad;
1064 for (x=0; x < (ssize_t) number_pixels; x++)
1066 pixel=ScaleQuantumToLong(GetPixelBlue(image,p));
1067 q=PopLongPixel(quantum_info->endian,pixel,q);
1068 p+=GetPixelChannels(image);
1069 q+=quantum_info->pad;
1075 if (quantum_info->format == FloatingPointQuantumFormat)
1077 for (x=0; x < (ssize_t) number_pixels; x++)
1079 q=PopDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q);
1080 p+=GetPixelChannels(image);
1081 q+=quantum_info->pad;
1088 range=GetQuantumRange(quantum_info->depth);
1089 for (x=0; x < (ssize_t) number_pixels; x++)
1091 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p),
1093 p+=GetPixelChannels(image);
1094 q+=quantum_info->pad;
1101 static void ExportCbYCrYQuantum(const Image *image,QuantumInfo *quantum_info,
1102 const MagickSizeType number_pixels,const Quantum *restrict p,
1103 unsigned char *restrict q,ExceptionInfo *exception)
1112 register unsigned int
1121 assert(exception != (ExceptionInfo *) NULL);
1122 assert(exception->signature == MagickSignature);
1125 switch (quantum_info->depth)
1129 if (quantum_info->pack == MagickFalse)
1131 for (x=0; x < (ssize_t) number_pixels; x+=2)
1133 for (i=0; i < 4; i++)
1139 quantum=GetPixelRed(image,p);
1144 quantum=GetPixelGreen(image,p);
1149 quantum=GetPixelBlue(image,p);
1153 cbcr[i]=(Quantum) quantum;
1156 pixel=(unsigned int) ((size_t) (cbcr[1]) << 22 | (size_t)
1157 (cbcr[0]) << 12 | (size_t) (cbcr[2]) << 2);
1158 q=PopLongPixel(quantum_info->endian,pixel,q);
1159 p+=GetPixelChannels(image);
1160 pixel=(unsigned int) ((size_t) (cbcr[3]) << 22 | (size_t)
1161 (cbcr[0]) << 12 | (size_t) (cbcr[2]) << 2);
1162 q=PopLongPixel(quantum_info->endian,pixel,q);
1163 p+=GetPixelChannels(image);
1164 q+=quantum_info->pad;
1175 for (x=0; x < (ssize_t) number_pixels; x+=2)
1177 for (i=0; i < 4; i++)
1183 quantum=GetPixelRed(image,p);
1188 quantum=GetPixelGreen(image,p);
1193 quantum=GetPixelBlue(image,p);
1197 cbcr[i]=(Quantum) quantum;
1200 range=GetQuantumRange(quantum_info->depth);
1201 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[1],range),q);
1202 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[0],range),q);
1203 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[2],range),q);
1204 p+=GetPixelChannels(image);
1205 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[3],range),q);
1206 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[0],range),q);
1207 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[2],range),q);
1208 p+=GetPixelChannels(image);
1209 q+=quantum_info->pad;
1216 static void ExportCMYKQuantum(const Image *image,QuantumInfo *quantum_info,
1217 const MagickSizeType number_pixels,const Quantum *restrict p,
1218 unsigned char *restrict q,ExceptionInfo *exception)
1223 if (image->colorspace != CMYKColorspace)
1225 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1226 "ColorSeparatedImageRequired","`%s'",image->filename);
1229 switch (quantum_info->depth)
1233 register unsigned char
1236 for (x=0; x < (ssize_t) number_pixels; x++)
1238 pixel=ScaleQuantumToChar(GetPixelRed(image,p));
1239 q=PopCharPixel(pixel,q);
1240 pixel=ScaleQuantumToChar(GetPixelGreen(image,p));
1241 q=PopCharPixel(pixel,q);
1242 pixel=ScaleQuantumToChar(GetPixelBlue(image,p));
1243 q=PopCharPixel(pixel,q);
1244 pixel=ScaleQuantumToChar(GetPixelBlack(image,p));
1245 q=PopCharPixel(pixel,q);
1246 p+=GetPixelChannels(image);
1247 q+=quantum_info->pad;
1253 register unsigned short
1256 if (quantum_info->format == FloatingPointQuantumFormat)
1258 for (x=0; x < (ssize_t) number_pixels; x++)
1260 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelRed(image,p));
1261 q=PopShortPixel(quantum_info->endian,pixel,q);
1262 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelGreen(image,p));
1263 q=PopShortPixel(quantum_info->endian,pixel,q);
1264 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlue(image,p));
1265 q=PopShortPixel(quantum_info->endian,pixel,q);
1266 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlack(image,p));
1267 q=PopShortPixel(quantum_info->endian,pixel,q);
1268 p+=GetPixelChannels(image);
1269 q+=quantum_info->pad;
1273 for (x=0; x < (ssize_t) number_pixels; x++)
1275 pixel=ScaleQuantumToShort(GetPixelRed(image,p));
1276 q=PopShortPixel(quantum_info->endian,pixel,q);
1277 pixel=ScaleQuantumToShort(GetPixelGreen(image,p));
1278 q=PopShortPixel(quantum_info->endian,pixel,q);
1279 pixel=ScaleQuantumToShort(GetPixelBlue(image,p));
1280 q=PopShortPixel(quantum_info->endian,pixel,q);
1281 pixel=ScaleQuantumToShort(GetPixelBlack(image,p));
1282 q=PopShortPixel(quantum_info->endian,pixel,q);
1283 p+=GetPixelChannels(image);
1284 q+=quantum_info->pad;
1290 register unsigned int
1293 if (quantum_info->format == FloatingPointQuantumFormat)
1295 for (x=0; x < (ssize_t) number_pixels; x++)
1297 q=PopFloatPixel(quantum_info,(float) GetPixelRed(image,p),q);
1298 q=PopFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q);
1299 q=PopFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q);
1300 q=PopFloatPixel(quantum_info,(float) GetPixelBlack(image,p),q);
1301 p+=GetPixelChannels(image);
1302 q+=quantum_info->pad;
1306 for (x=0; x < (ssize_t) number_pixels; x++)
1308 pixel=ScaleQuantumToLong(GetPixelRed(image,p));
1309 q=PopLongPixel(quantum_info->endian,pixel,q);
1310 pixel=ScaleQuantumToLong(GetPixelGreen(image,p));
1311 q=PopLongPixel(quantum_info->endian,pixel,q);
1312 pixel=ScaleQuantumToLong(GetPixelBlue(image,p));
1313 q=PopLongPixel(quantum_info->endian,pixel,q);
1314 pixel=ScaleQuantumToLong(GetPixelBlack(image,p));
1315 q=PopLongPixel(quantum_info->endian,pixel,q);
1316 p+=GetPixelChannels(image);
1317 q+=quantum_info->pad;
1323 if (quantum_info->format == FloatingPointQuantumFormat)
1325 for (x=0; x < (ssize_t) number_pixels; x++)
1327 q=PopDoublePixel(quantum_info,(double) GetPixelRed(image,p),q);
1328 q=PopDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q);
1329 q=PopDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q);
1330 q=PopDoublePixel(quantum_info,(double) GetPixelBlack(image,p),q);
1331 p+=GetPixelChannels(image);
1332 q+=quantum_info->pad;
1342 range=GetQuantumRange(quantum_info->depth);
1343 for (x=0; x < (ssize_t) number_pixels; x++)
1345 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p),
1347 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p),
1349 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p),
1351 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlack(image,p),
1353 p+=GetPixelChannels(image);
1354 q+=quantum_info->pad;
1361 static void ExportCMYKAQuantum(const Image *image,QuantumInfo *quantum_info,
1362 const MagickSizeType number_pixels,const Quantum *restrict p,
1363 unsigned char *restrict q,ExceptionInfo *exception)
1368 if (image->colorspace != CMYKColorspace)
1370 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1371 "ColorSeparatedImageRequired","`%s'",image->filename);
1374 switch (quantum_info->depth)
1378 register unsigned char
1381 for (x=0; x < (ssize_t) number_pixels; x++)
1383 pixel=ScaleQuantumToChar(GetPixelRed(image,p));
1384 q=PopCharPixel(pixel,q);
1385 pixel=ScaleQuantumToChar(GetPixelGreen(image,p));
1386 q=PopCharPixel(pixel,q);
1387 pixel=ScaleQuantumToChar(GetPixelBlue(image,p));
1388 q=PopCharPixel(pixel,q);
1389 pixel=ScaleQuantumToChar(GetPixelBlack(image,p));
1390 q=PopCharPixel(pixel,q);
1391 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p));
1392 q=PopCharPixel(pixel,q);
1393 p+=GetPixelChannels(image);
1394 q+=quantum_info->pad;
1400 register unsigned short
1403 if (quantum_info->format == FloatingPointQuantumFormat)
1405 for (x=0; x < (ssize_t) number_pixels; x++)
1407 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelRed(image,p));
1408 q=PopShortPixel(quantum_info->endian,pixel,q);
1409 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelGreen(image,p));
1410 q=PopShortPixel(quantum_info->endian,pixel,q);
1411 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlue(image,p));
1412 q=PopShortPixel(quantum_info->endian,pixel,q);
1413 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlack(image,p));
1414 q=PopShortPixel(quantum_info->endian,pixel,q);
1415 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelAlpha(image,p));
1416 q=PopShortPixel(quantum_info->endian,pixel,q);
1417 p+=GetPixelChannels(image);
1418 q+=quantum_info->pad;
1422 for (x=0; x < (ssize_t) number_pixels; x++)
1424 pixel=ScaleQuantumToShort(GetPixelRed(image,p));
1425 q=PopShortPixel(quantum_info->endian,pixel,q);
1426 pixel=ScaleQuantumToShort(GetPixelGreen(image,p));
1427 q=PopShortPixel(quantum_info->endian,pixel,q);
1428 pixel=ScaleQuantumToShort(GetPixelBlue(image,p));
1429 q=PopShortPixel(quantum_info->endian,pixel,q);
1430 pixel=ScaleQuantumToShort(GetPixelBlack(image,p));
1431 q=PopShortPixel(quantum_info->endian,pixel,q);
1432 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p));
1433 q=PopShortPixel(quantum_info->endian,pixel,q);
1434 p+=GetPixelChannels(image);
1435 q+=quantum_info->pad;
1441 register unsigned int
1444 if (quantum_info->format == FloatingPointQuantumFormat)
1446 for (x=0; x < (ssize_t) number_pixels; x++)
1451 q=PopFloatPixel(quantum_info,(float) GetPixelRed(image,p),q);
1452 q=PopFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q);
1453 q=PopFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q);
1454 q=PopFloatPixel(quantum_info,(float) GetPixelBlack(image,p),q);
1455 pixel=(float) (GetPixelAlpha(image,p));
1456 q=PopFloatPixel(quantum_info,pixel,q);
1457 p+=GetPixelChannels(image);
1458 q+=quantum_info->pad;
1462 for (x=0; x < (ssize_t) number_pixels; x++)
1464 pixel=ScaleQuantumToLong(GetPixelRed(image,p));
1465 q=PopLongPixel(quantum_info->endian,pixel,q);
1466 pixel=ScaleQuantumToLong(GetPixelGreen(image,p));
1467 q=PopLongPixel(quantum_info->endian,pixel,q);
1468 pixel=ScaleQuantumToLong(GetPixelBlue(image,p));
1469 q=PopLongPixel(quantum_info->endian,pixel,q);
1470 pixel=ScaleQuantumToLong(GetPixelBlack(image,p));
1471 q=PopLongPixel(quantum_info->endian,pixel,q);
1472 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p));
1473 q=PopLongPixel(quantum_info->endian,pixel,q);
1474 p+=GetPixelChannels(image);
1475 q+=quantum_info->pad;
1481 if (quantum_info->format == FloatingPointQuantumFormat)
1486 for (x=0; x < (ssize_t) number_pixels; x++)
1488 q=PopDoublePixel(quantum_info,(double) GetPixelRed(image,p),q);
1489 q=PopDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q);
1490 q=PopDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q);
1491 q=PopDoublePixel(quantum_info,(double) GetPixelBlack(image,p),q);
1492 pixel=(double) (GetPixelAlpha(image,p));
1493 q=PopDoublePixel(quantum_info,pixel,q);
1494 p+=GetPixelChannels(image);
1495 q+=quantum_info->pad;
1505 range=GetQuantumRange(quantum_info->depth);
1506 for (x=0; x < (ssize_t) number_pixels; x++)
1508 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p),
1510 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p),
1512 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p),
1514 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlack(image,p),
1516 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p),
1518 p+=GetPixelChannels(image);
1519 q+=quantum_info->pad;
1526 static void ExportGrayQuantum(const Image *image,QuantumInfo *quantum_info,
1527 const MagickSizeType number_pixels,const Quantum *restrict p,
1528 unsigned char *restrict q,ExceptionInfo *exception)
1536 assert(exception != (ExceptionInfo *) NULL);
1537 assert(exception->signature == MagickSignature);
1538 switch (quantum_info->depth)
1545 register unsigned char
1554 if (quantum_info->min_is_white != MagickFalse)
1559 threshold=QuantumRange/2.0;
1560 for (x=((ssize_t) number_pixels-7); x > 0; x-=8)
1563 *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 7;
1564 p+=GetPixelChannels(image);
1565 *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 6;
1566 p+=GetPixelChannels(image);
1567 *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 5;
1568 p+=GetPixelChannels(image);
1569 *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 4;
1570 p+=GetPixelChannels(image);
1571 *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 3;
1572 p+=GetPixelChannels(image);
1573 *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 2;
1574 p+=GetPixelChannels(image);
1575 *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 1;
1576 p+=GetPixelChannels(image);
1577 *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 0;
1578 p+=GetPixelChannels(image);
1581 if ((number_pixels % 8) != 0)
1584 for (bit=7; bit >= (ssize_t) (8-(number_pixels % 8)); bit--)
1586 *q|=(GetPixelLuma(image,p) < threshold ? black : white) << bit;
1587 p+=GetPixelChannels(image);
1595 register unsigned char
1598 for (x=0; x < (ssize_t) (number_pixels-1) ; x+=2)
1600 pixel=ScaleQuantumToChar(ClampToQuantum(GetPixelLuma(image,p)));
1601 *q=(((pixel >> 4) & 0xf) << 4);
1602 p+=GetPixelChannels(image);
1603 pixel=ScaleQuantumToChar(ClampToQuantum(GetPixelLuma(image,p)));
1605 p+=GetPixelChannels(image);
1608 if ((number_pixels % 2) != 0)
1610 pixel=ScaleQuantumToChar(ClampToQuantum(GetPixelLuma(image,p)));
1611 *q=(((pixel >> 4) & 0xf) << 4);
1612 p+=GetPixelChannels(image);
1619 register unsigned char
1622 for (x=0; x < (ssize_t) number_pixels; x++)
1624 pixel=ScaleQuantumToChar(ClampToQuantum(GetPixelLuma(image,p)));
1625 q=PopCharPixel(pixel,q);
1626 p+=GetPixelChannels(image);
1627 q+=quantum_info->pad;
1633 range=GetQuantumRange(quantum_info->depth);
1634 if (quantum_info->pack == MagickFalse)
1636 register unsigned int
1639 for (x=0; x < (ssize_t) (number_pixels-2); x+=3)
1641 pixel=(unsigned int) (ScaleQuantumToAny(ClampToQuantum(
1642 GetPixelLuma(image,p+2*GetPixelChannels(image))),range) << 22 |
1643 ScaleQuantumToAny(ClampToQuantum(GetPixelLuma(image,p+
1644 GetPixelChannels(image))),range) << 12 | ScaleQuantumToAny(
1645 ClampToQuantum(GetPixelLuma(image,p)),range) << 2);
1646 q=PopLongPixel(quantum_info->endian,pixel,q);
1647 p+=3*GetPixelChannels(image);
1648 q+=quantum_info->pad;
1650 if (x < (ssize_t) number_pixels)
1653 if (x++ < (ssize_t) (number_pixels-1))
1654 pixel|=ScaleQuantumToAny(ClampToQuantum(GetPixelLuma(image,p+
1655 GetPixelChannels(image))),range) << 12;
1656 if (x++ < (ssize_t) number_pixels)
1657 pixel|=ScaleQuantumToAny(ClampToQuantum(GetPixelLuma(image,p)),
1659 q=PopLongPixel(quantum_info->endian,pixel,q);
1663 for (x=0; x < (ssize_t) number_pixels; x++)
1665 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(ClampToQuantum(
1666 GetPixelLuma(image,p)),range),q);
1667 p+=GetPixelChannels(image);
1668 q+=quantum_info->pad;
1674 register unsigned short
1677 range=GetQuantumRange(quantum_info->depth);
1678 if (quantum_info->pack == MagickFalse)
1680 for (x=0; x < (ssize_t) number_pixels; x++)
1682 pixel=ScaleQuantumToShort(ClampToQuantum(GetPixelLuma(image,p)));
1683 q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel >> 4),
1685 p+=GetPixelChannels(image);
1686 q+=quantum_info->pad;
1690 for (x=0; x < (ssize_t) number_pixels; x++)
1692 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(ClampToQuantum(
1693 GetPixelLuma(image,p)),range),q);
1694 p+=GetPixelChannels(image);
1695 q+=quantum_info->pad;
1701 register unsigned short
1704 if (quantum_info->format == FloatingPointQuantumFormat)
1706 for (x=0; x < (ssize_t) number_pixels; x++)
1708 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelLuma(image,p));
1709 q=PopShortPixel(quantum_info->endian,pixel,q);
1710 p+=GetPixelChannels(image);
1711 q+=quantum_info->pad;
1715 for (x=0; x < (ssize_t) number_pixels; x++)
1717 pixel=ScaleQuantumToShort(ClampToQuantum(GetPixelLuma(image,p)));
1718 q=PopShortPixel(quantum_info->endian,pixel,q);
1719 p+=GetPixelChannels(image);
1720 q+=quantum_info->pad;
1726 register unsigned int
1729 if (quantum_info->format == FloatingPointQuantumFormat)
1731 for (x=0; x < (ssize_t) number_pixels; x++)
1736 pixel=(float) GetPixelLuma(image,p);
1737 q=PopFloatPixel(quantum_info,pixel,q);
1738 p+=GetPixelChannels(image);
1739 q+=quantum_info->pad;
1743 for (x=0; x < (ssize_t) number_pixels; x++)
1745 pixel=ScaleQuantumToLong(ClampToQuantum(GetPixelLuma(image,p)));
1746 q=PopLongPixel(quantum_info->endian,pixel,q);
1747 p+=GetPixelChannels(image);
1748 q+=quantum_info->pad;
1754 if (quantum_info->format == FloatingPointQuantumFormat)
1756 for (x=0; x < (ssize_t) number_pixels; x++)
1761 pixel=GetPixelLuma(image,p);
1762 q=PopDoublePixel(quantum_info,pixel,q);
1763 p+=GetPixelChannels(image);
1764 q+=quantum_info->pad;
1771 range=GetQuantumRange(quantum_info->depth);
1772 for (x=0; x < (ssize_t) number_pixels; x++)
1774 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(ClampToQuantum(
1775 GetPixelLuma(image,p)),range),q);
1776 p+=GetPixelChannels(image);
1777 q+=quantum_info->pad;
1784 static void ExportGrayAlphaQuantum(const Image *image,QuantumInfo *quantum_info,
1785 const MagickSizeType number_pixels,const Quantum *restrict p,
1786 unsigned char *restrict q,ExceptionInfo *exception)
1794 assert(exception != (ExceptionInfo *) NULL);
1795 assert(exception->signature == MagickSignature);
1796 switch (quantum_info->depth)
1803 register unsigned char
1813 if (quantum_info->min_is_white == MagickFalse)
1818 threshold=QuantumRange/2.0;
1819 for (x=((ssize_t) number_pixels-3); x > 0; x-=4)
1822 *q|=(GetPixelLuma(image,p) > threshold ? black : white) << 7;
1823 pixel=(unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ?
1825 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 6);
1826 p+=GetPixelChannels(image);
1827 *q|=(GetPixelLuma(image,p) > threshold ? black : white) << 5;
1828 pixel=(unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ?
1830 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 4);
1831 p+=GetPixelChannels(image);
1832 *q|=(GetPixelLuma(image,p) > threshold ? black : white) << 3;
1833 pixel=(unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ?
1835 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 2);
1836 p+=GetPixelChannels(image);
1837 *q|=(GetPixelLuma(image,p) > threshold ? black : white) << 1;
1838 pixel=(unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ?
1840 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 0);
1841 p+=GetPixelChannels(image);
1844 if ((number_pixels % 4) != 0)
1847 for (bit=0; bit <= (ssize_t) (number_pixels % 4); bit+=2)
1849 *q|=(GetPixelLuma(image,p) > threshold ? black : white) <<
1851 pixel=(unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ?
1853 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << (unsigned char)
1855 p+=GetPixelChannels(image);
1863 register unsigned char
1866 for (x=0; x < (ssize_t) number_pixels ; x++)
1868 pixel=ScaleQuantumToChar(ClampToQuantum(GetPixelLuma(image,p)));
1869 *q=(((pixel >> 4) & 0xf) << 4);
1870 pixel=(unsigned char) (16*QuantumScale*GetPixelAlpha(image,p)+0.5);
1872 p+=GetPixelChannels(image);
1879 register unsigned char
1882 for (x=0; x < (ssize_t) number_pixels; x++)
1884 pixel=ScaleQuantumToChar(ClampToQuantum(GetPixelLuma(image,p)));
1885 q=PopCharPixel(pixel,q);
1886 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p));
1887 q=PopCharPixel(pixel,q);
1888 p+=GetPixelChannels(image);
1889 q+=quantum_info->pad;
1895 register unsigned short
1898 if (quantum_info->format == FloatingPointQuantumFormat)
1900 for (x=0; x < (ssize_t) number_pixels; x++)
1902 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelLuma(image,p));
1903 q=PopShortPixel(quantum_info->endian,pixel,q);
1904 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelAlpha(image,p));
1905 q=PopShortPixel(quantum_info->endian,pixel,q);
1906 p+=GetPixelChannels(image);
1907 q+=quantum_info->pad;
1911 for (x=0; x < (ssize_t) number_pixels; x++)
1913 pixel=ScaleQuantumToShort(ClampToQuantum(GetPixelLuma(image,p)));
1914 q=PopShortPixel(quantum_info->endian,pixel,q);
1915 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p));
1916 q=PopShortPixel(quantum_info->endian,pixel,q);
1917 p+=GetPixelChannels(image);
1918 q+=quantum_info->pad;
1924 register unsigned int
1927 if (quantum_info->format == FloatingPointQuantumFormat)
1929 for (x=0; x < (ssize_t) number_pixels; x++)
1934 pixel=(float) GetPixelLuma(image,p);
1935 q=PopFloatPixel(quantum_info,pixel,q);
1936 pixel=(float) (GetPixelAlpha(image,p));
1937 q=PopFloatPixel(quantum_info,pixel,q);
1938 p+=GetPixelChannels(image);
1939 q+=quantum_info->pad;
1943 for (x=0; x < (ssize_t) number_pixels; x++)
1945 pixel=ScaleQuantumToLong(ClampToQuantum(GetPixelLuma(image,p)));
1946 q=PopLongPixel(quantum_info->endian,pixel,q);
1947 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p));
1948 q=PopLongPixel(quantum_info->endian,pixel,q);
1949 p+=GetPixelChannels(image);
1950 q+=quantum_info->pad;
1956 if (quantum_info->format == FloatingPointQuantumFormat)
1958 for (x=0; x < (ssize_t) number_pixels; x++)
1963 pixel=GetPixelLuma(image,p);
1964 q=PopDoublePixel(quantum_info,pixel,q);
1965 pixel=(double) (GetPixelAlpha(image,p));
1966 q=PopDoublePixel(quantum_info,pixel,q);
1967 p+=GetPixelChannels(image);
1968 q+=quantum_info->pad;
1975 range=GetQuantumRange(quantum_info->depth);
1976 for (x=0; x < (ssize_t) number_pixels; x++)
1978 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(ClampToQuantum(
1979 GetPixelLuma(image,p)),range),q);
1980 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p),
1982 p+=GetPixelChannels(image);
1983 q+=quantum_info->pad;
1990 static void ExportGreenQuantum(const Image *image,QuantumInfo *quantum_info,
1991 const MagickSizeType number_pixels,const Quantum *restrict p,
1992 unsigned char *restrict q,ExceptionInfo *exception)
2000 assert(exception != (ExceptionInfo *) NULL);
2001 assert(exception->signature == MagickSignature);
2002 switch (quantum_info->depth)
2006 register unsigned char
2009 for (x=0; x < (ssize_t) number_pixels; x++)
2011 pixel=ScaleQuantumToChar(GetPixelGreen(image,p));
2012 q=PopCharPixel(pixel,q);
2013 p+=GetPixelChannels(image);
2014 q+=quantum_info->pad;
2020 register unsigned short
2023 if (quantum_info->format == FloatingPointQuantumFormat)
2025 for (x=0; x < (ssize_t) number_pixels; x++)
2027 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelGreen(image,p));
2028 q=PopShortPixel(quantum_info->endian,pixel,q);
2029 p+=GetPixelChannels(image);
2030 q+=quantum_info->pad;
2034 for (x=0; x < (ssize_t) number_pixels; x++)
2036 pixel=ScaleQuantumToShort(GetPixelGreen(image,p));
2037 q=PopShortPixel(quantum_info->endian,pixel,q);
2038 p+=GetPixelChannels(image);
2039 q+=quantum_info->pad;
2045 register unsigned int
2048 if (quantum_info->format == FloatingPointQuantumFormat)
2050 for (x=0; x < (ssize_t) number_pixels; x++)
2052 q=PopFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q);
2053 p+=GetPixelChannels(image);
2054 q+=quantum_info->pad;
2058 for (x=0; x < (ssize_t) number_pixels; x++)
2060 pixel=ScaleQuantumToLong(GetPixelGreen(image,p));
2061 q=PopLongPixel(quantum_info->endian,pixel,q);
2062 p+=GetPixelChannels(image);
2063 q+=quantum_info->pad;
2069 if (quantum_info->format == FloatingPointQuantumFormat)
2071 for (x=0; x < (ssize_t) number_pixels; x++)
2073 q=PopDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q);
2074 p+=GetPixelChannels(image);
2075 q+=quantum_info->pad;
2082 range=GetQuantumRange(quantum_info->depth);
2083 for (x=0; x < (ssize_t) number_pixels; x++)
2085 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p),
2087 p+=GetPixelChannels(image);
2088 q+=quantum_info->pad;
2095 static void ExportIndexQuantum(const Image *image,QuantumInfo *quantum_info,
2096 const MagickSizeType number_pixels,const Quantum *restrict p,
2097 unsigned char *restrict q,ExceptionInfo *exception)
2105 if (image->storage_class != PseudoClass)
2107 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
2108 "ColormappedImageRequired","`%s'",image->filename);
2111 switch (quantum_info->depth)
2115 register unsigned char
2118 for (x=((ssize_t) number_pixels-7); x > 0; x-=8)
2120 pixel=(unsigned char) GetPixelIndex(image,p);
2121 *q=((pixel & 0x01) << 7);
2122 p+=GetPixelChannels(image);
2123 pixel=(unsigned char) GetPixelIndex(image,p);
2124 *q|=((pixel & 0x01) << 6);
2125 p+=GetPixelChannels(image);
2126 pixel=(unsigned char) GetPixelIndex(image,p);
2127 *q|=((pixel & 0x01) << 5);
2128 p+=GetPixelChannels(image);
2129 pixel=(unsigned char) GetPixelIndex(image,p);
2130 *q|=((pixel & 0x01) << 4);
2131 p+=GetPixelChannels(image);
2132 pixel=(unsigned char) GetPixelIndex(image,p);
2133 *q|=((pixel & 0x01) << 3);
2134 p+=GetPixelChannels(image);
2135 pixel=(unsigned char) GetPixelIndex(image,p);
2136 *q|=((pixel & 0x01) << 2);
2137 p+=GetPixelChannels(image);
2138 pixel=(unsigned char) GetPixelIndex(image,p);
2139 *q|=((pixel & 0x01) << 1);
2140 p+=GetPixelChannels(image);
2141 pixel=(unsigned char) GetPixelIndex(image,p);
2142 *q|=((pixel & 0x01) << 0);
2143 p+=GetPixelChannels(image);
2146 if ((number_pixels % 8) != 0)
2149 for (bit=7; bit >= (ssize_t) (8-(number_pixels % 8)); bit--)
2151 pixel=(unsigned char) GetPixelIndex(image,p);
2152 *q|=((pixel & 0x01) << (unsigned char) bit);
2153 p+=GetPixelChannels(image);
2161 register unsigned char
2164 for (x=0; x < (ssize_t) (number_pixels-1) ; x+=2)
2166 pixel=(unsigned char) GetPixelIndex(image,p);
2167 *q=((pixel & 0xf) << 4);
2168 p+=GetPixelChannels(image);
2169 pixel=(unsigned char) GetPixelIndex(image,p);
2170 *q|=((pixel & 0xf) << 0);
2171 p+=GetPixelChannels(image);
2174 if ((number_pixels % 2) != 0)
2176 pixel=(unsigned char) GetPixelIndex(image,p);
2177 *q=((pixel & 0xf) << 4);
2178 p+=GetPixelChannels(image);
2185 for (x=0; x < (ssize_t) number_pixels; x++)
2187 q=PopCharPixel((unsigned char) GetPixelIndex(image,p),q);
2188 p+=GetPixelChannels(image);
2189 q+=quantum_info->pad;
2195 if (quantum_info->format == FloatingPointQuantumFormat)
2197 for (x=0; x < (ssize_t) number_pixels; x++)
2199 q=PopShortPixel(quantum_info->endian,SinglePrecisionToHalf(
2200 QuantumScale*GetPixelIndex(image,p)),q);
2201 p+=GetPixelChannels(image);
2202 q+=quantum_info->pad;
2206 for (x=0; x < (ssize_t) number_pixels; x++)
2208 q=PopShortPixel(quantum_info->endian,(unsigned short)
2209 GetPixelIndex(image,p),q);
2210 p+=GetPixelChannels(image);
2211 q+=quantum_info->pad;
2217 if (quantum_info->format == FloatingPointQuantumFormat)
2219 for (x=0; x < (ssize_t) number_pixels; x++)
2221 q=PopFloatPixel(quantum_info,(float) GetPixelIndex(image,p),q);
2222 p+=GetPixelChannels(image);
2223 q+=quantum_info->pad;
2227 for (x=0; x < (ssize_t) number_pixels; x++)
2229 q=PopLongPixel(quantum_info->endian,(unsigned int)
2230 GetPixelIndex(image,p),q);
2231 p+=GetPixelChannels(image);
2232 q+=quantum_info->pad;
2238 if (quantum_info->format == FloatingPointQuantumFormat)
2240 for (x=0; x < (ssize_t) number_pixels; x++)
2242 q=PopDoublePixel(quantum_info,(double) GetPixelIndex(image,p),q);
2243 p+=GetPixelChannels(image);
2244 q+=quantum_info->pad;
2251 for (x=0; x < (ssize_t) number_pixels; x++)
2253 q=PopQuantumPixel(quantum_info,GetPixelIndex(image,p),q);
2254 p+=GetPixelChannels(image);
2255 q+=quantum_info->pad;
2262 static void ExportIndexAlphaQuantum(const Image *image,
2263 QuantumInfo *quantum_info,const MagickSizeType number_pixels,
2264 const Quantum *restrict p,unsigned char *restrict q,ExceptionInfo *exception)
2272 if (image->storage_class != PseudoClass)
2274 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
2275 "ColormappedImageRequired","`%s'",image->filename);
2278 switch (quantum_info->depth)
2282 register unsigned char
2285 for (x=((ssize_t) number_pixels-3); x > 0; x-=4)
2287 pixel=(unsigned char) GetPixelIndex(image,p);
2288 *q=((pixel & 0x01) << 7);
2289 pixel=(unsigned char) (GetPixelAlpha(image,p) == (Quantum)
2290 TransparentAlpha ? 1 : 0);
2291 *q|=((pixel & 0x01) << 6);
2292 p+=GetPixelChannels(image);
2293 pixel=(unsigned char) GetPixelIndex(image,p);
2294 *q|=((pixel & 0x01) << 5);
2295 pixel=(unsigned char) (GetPixelAlpha(image,p) == (Quantum)
2296 TransparentAlpha ? 1 : 0);
2297 *q|=((pixel & 0x01) << 4);
2298 p+=GetPixelChannels(image);
2299 pixel=(unsigned char) GetPixelIndex(image,p);
2300 *q|=((pixel & 0x01) << 3);
2301 pixel=(unsigned char) (GetPixelAlpha(image,p) == (Quantum)
2302 TransparentAlpha ? 1 : 0);
2303 *q|=((pixel & 0x01) << 2);
2304 p+=GetPixelChannels(image);
2305 pixel=(unsigned char) GetPixelIndex(image,p);
2306 *q|=((pixel & 0x01) << 1);
2307 pixel=(unsigned char) (GetPixelAlpha(image,p) == (Quantum)
2308 TransparentAlpha ? 1 : 0);
2309 *q|=((pixel & 0x01) << 0);
2310 p+=GetPixelChannels(image);
2313 if ((number_pixels % 4) != 0)
2316 for (bit=3; bit >= (ssize_t) (4-(number_pixels % 4)); bit-=2)
2318 pixel=(unsigned char) GetPixelIndex(image,p);
2319 *q|=((pixel & 0x01) << (unsigned char) (bit+4));
2320 pixel=(unsigned char) (GetPixelAlpha(image,p) == (Quantum)
2321 TransparentAlpha ? 1 : 0);
2322 *q|=((pixel & 0x01) << (unsigned char) (bit+4-1));
2323 p+=GetPixelChannels(image);
2331 register unsigned char
2334 for (x=0; x < (ssize_t) number_pixels ; x++)
2336 pixel=(unsigned char) GetPixelIndex(image,p);
2337 *q=((pixel & 0xf) << 4);
2338 pixel=(unsigned char) (16*QuantumScale*GetPixelAlpha(image,p)+0.5);
2339 *q|=((pixel & 0xf) << 0);
2340 p+=GetPixelChannels(image);
2347 register unsigned char
2350 for (x=0; x < (ssize_t) number_pixels; x++)
2352 q=PopCharPixel((unsigned char) GetPixelIndex(image,p),q);
2353 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p));
2354 q=PopCharPixel(pixel,q);
2355 p+=GetPixelChannels(image);
2356 q+=quantum_info->pad;
2362 register unsigned short
2365 if (quantum_info->format == FloatingPointQuantumFormat)
2367 for (x=0; x < (ssize_t) number_pixels; x++)
2369 q=PopShortPixel(quantum_info->endian,(unsigned short)
2370 GetPixelIndex(image,p),q);
2371 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelAlpha(image,p));
2372 q=PopShortPixel(quantum_info->endian,pixel,q);
2373 p+=GetPixelChannels(image);
2374 q+=quantum_info->pad;
2378 for (x=0; x < (ssize_t) number_pixels; x++)
2380 q=PopShortPixel(quantum_info->endian,(unsigned short)
2381 GetPixelIndex(image,p),q);
2382 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p));
2383 q=PopShortPixel(quantum_info->endian,pixel,q);
2384 p+=GetPixelChannels(image);
2385 q+=quantum_info->pad;
2391 register unsigned int
2394 if (quantum_info->format == FloatingPointQuantumFormat)
2396 for (x=0; x < (ssize_t) number_pixels; x++)
2401 q=PopFloatPixel(quantum_info,(float) GetPixelIndex(image,p),q);
2402 pixel=(float) GetPixelAlpha(image,p);
2403 q=PopFloatPixel(quantum_info,pixel,q);
2404 p+=GetPixelChannels(image);
2405 q+=quantum_info->pad;
2409 for (x=0; x < (ssize_t) number_pixels; x++)
2411 q=PopLongPixel(quantum_info->endian,(unsigned int)
2412 GetPixelIndex(image,p),q);
2413 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p));
2414 q=PopLongPixel(quantum_info->endian,pixel,q);
2415 p+=GetPixelChannels(image);
2416 q+=quantum_info->pad;
2422 if (quantum_info->format == FloatingPointQuantumFormat)
2424 for (x=0; x < (ssize_t) number_pixels; x++)
2429 q=PopDoublePixel(quantum_info,(double) GetPixelIndex(image,p),q);
2430 pixel=(double) GetPixelAlpha(image,p);
2431 q=PopDoublePixel(quantum_info,pixel,q);
2432 p+=GetPixelChannels(image);
2433 q+=quantum_info->pad;
2443 range=GetQuantumRange(quantum_info->depth);
2444 for (x=0; x < (ssize_t) number_pixels; x++)
2446 q=PopQuantumPixel(quantum_info,GetPixelIndex(image,p),q);
2447 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p),
2449 p+=GetPixelChannels(image);
2450 q+=quantum_info->pad;
2457 static void ExportOpacityQuantum(const Image *image,QuantumInfo *quantum_info,
2458 const MagickSizeType number_pixels,const Quantum *restrict p,
2459 unsigned char *restrict q,ExceptionInfo *exception)
2467 assert(exception != (ExceptionInfo *) NULL);
2468 assert(exception->signature == MagickSignature);
2469 switch (quantum_info->depth)
2473 register unsigned char
2476 for (x=0; x < (ssize_t) number_pixels; x++)
2478 pixel=ScaleQuantumToChar(GetPixelOpacity(image,p));
2479 q=PopCharPixel(pixel,q);
2480 p+=GetPixelChannels(image);
2481 q+=quantum_info->pad;
2487 register unsigned short
2490 if (quantum_info->format == FloatingPointQuantumFormat)
2492 for (x=0; x < (ssize_t) number_pixels; x++)
2494 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelOpacity(image,p));
2495 q=PopShortPixel(quantum_info->endian,pixel,q);
2496 p+=GetPixelChannels(image);
2497 q+=quantum_info->pad;
2501 for (x=0; x < (ssize_t) number_pixels; x++)
2503 pixel=ScaleQuantumToShort(GetPixelOpacity(image,p));
2504 q=PopShortPixel(quantum_info->endian,pixel,q);
2505 p+=GetPixelChannels(image);
2506 q+=quantum_info->pad;
2512 register unsigned int
2515 if (quantum_info->format == FloatingPointQuantumFormat)
2517 for (x=0; x < (ssize_t) number_pixels; x++)
2519 q=PopFloatPixel(quantum_info,(float) GetPixelOpacity(image,p),q);
2520 p+=GetPixelChannels(image);
2521 q+=quantum_info->pad;
2525 for (x=0; x < (ssize_t) number_pixels; x++)
2527 pixel=ScaleQuantumToLong(GetPixelOpacity(image,p));
2528 q=PopLongPixel(quantum_info->endian,pixel,q);
2529 p+=GetPixelChannels(image);
2530 q+=quantum_info->pad;
2536 if (quantum_info->format == FloatingPointQuantumFormat)
2538 for (x=0; x < (ssize_t) number_pixels; x++)
2540 q=PopDoublePixel(quantum_info,(double) GetPixelOpacity(image,p),q);
2541 p+=GetPixelChannels(image);
2542 q+=quantum_info->pad;
2549 range=GetQuantumRange(quantum_info->depth);
2550 for (x=0; x < (ssize_t) number_pixels; x++)
2552 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(
2553 GetPixelOpacity(image,p),range),q);
2554 p+=GetPixelChannels(image);
2555 q+=quantum_info->pad;
2562 static void ExportRedQuantum(const Image *image,QuantumInfo *quantum_info,
2563 const MagickSizeType number_pixels,const Quantum *restrict p,
2564 unsigned char *restrict q,ExceptionInfo *exception)
2572 assert(exception != (ExceptionInfo *) NULL);
2573 assert(exception->signature == MagickSignature);
2574 switch (quantum_info->depth)
2578 register unsigned char
2581 for (x=0; x < (ssize_t) number_pixels; x++)
2583 pixel=ScaleQuantumToChar(GetPixelRed(image,p));
2584 q=PopCharPixel(pixel,q);
2585 p+=GetPixelChannels(image);
2586 q+=quantum_info->pad;
2592 register unsigned short
2595 if (quantum_info->format == FloatingPointQuantumFormat)
2597 for (x=0; x < (ssize_t) number_pixels; x++)
2599 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelRed(image,p));
2600 q=PopShortPixel(quantum_info->endian,pixel,q);
2601 p+=GetPixelChannels(image);
2602 q+=quantum_info->pad;
2606 for (x=0; x < (ssize_t) number_pixels; x++)
2608 pixel=ScaleQuantumToShort(GetPixelRed(image,p));
2609 q=PopShortPixel(quantum_info->endian,pixel,q);
2610 p+=GetPixelChannels(image);
2611 q+=quantum_info->pad;
2617 register unsigned int
2620 if (quantum_info->format == FloatingPointQuantumFormat)
2622 for (x=0; x < (ssize_t) number_pixels; x++)
2624 q=PopFloatPixel(quantum_info,(float) GetPixelRed(image,p),q);
2625 p+=GetPixelChannels(image);
2626 q+=quantum_info->pad;
2630 for (x=0; x < (ssize_t) number_pixels; x++)
2632 pixel=ScaleQuantumToLong(GetPixelRed(image,p));
2633 q=PopLongPixel(quantum_info->endian,pixel,q);
2634 p+=GetPixelChannels(image);
2635 q+=quantum_info->pad;
2641 if (quantum_info->format == FloatingPointQuantumFormat)
2643 for (x=0; x < (ssize_t) number_pixels; x++)
2645 q=PopDoublePixel(quantum_info,(double) GetPixelRed(image,p),q);
2646 p+=GetPixelChannels(image);
2647 q+=quantum_info->pad;
2654 range=GetQuantumRange(quantum_info->depth);
2655 for (x=0; x < (ssize_t) number_pixels; x++)
2657 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p),
2659 p+=GetPixelChannels(image);
2660 q+=quantum_info->pad;
2667 static void ExportRGBQuantum(const Image *image,QuantumInfo *quantum_info,
2668 const MagickSizeType number_pixels,const Quantum *restrict p,
2669 unsigned char *restrict q,ExceptionInfo *exception)
2680 assert(exception != (ExceptionInfo *) NULL);
2681 assert(exception->signature == MagickSignature);
2682 switch (quantum_info->depth)
2686 for (x=0; x < (ssize_t) number_pixels; x++)
2688 q=PopCharPixel(ScaleQuantumToChar(GetPixelRed(image,p)),q);
2689 q=PopCharPixel(ScaleQuantumToChar(GetPixelGreen(image,p)),q);
2690 q=PopCharPixel(ScaleQuantumToChar(GetPixelBlue(image,p)),q);
2691 p+=GetPixelChannels(image);
2692 q+=quantum_info->pad;
2698 register unsigned int
2701 range=GetQuantumRange(quantum_info->depth);
2702 if (quantum_info->pack == MagickFalse)
2704 for (x=0; x < (ssize_t) number_pixels; x++)
2706 pixel=(unsigned int) (
2707 ScaleQuantumToAny(GetPixelRed(image,p),range) << 22 |
2708 ScaleQuantumToAny(GetPixelGreen(image,p),range) << 12 |
2709 ScaleQuantumToAny(GetPixelBlue(image,p),range) << 2);
2710 q=PopLongPixel(quantum_info->endian,pixel,q);
2711 p+=GetPixelChannels(image);
2712 q+=quantum_info->pad;
2716 if (quantum_info->quantum == 32UL)
2718 for (x=0; x < (ssize_t) number_pixels; x++)
2720 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
2721 q=PopQuantumLongPixel(quantum_info,pixel,q);
2722 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
2724 q=PopQuantumLongPixel(quantum_info,pixel,q);
2725 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
2726 q=PopQuantumLongPixel(quantum_info,pixel,q);
2727 p+=GetPixelChannels(image);
2728 q+=quantum_info->pad;
2732 for (x=0; x < (ssize_t) number_pixels; x++)
2734 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
2735 q=PopQuantumPixel(quantum_info,pixel,q);
2736 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range);
2737 q=PopQuantumPixel(quantum_info,pixel,q);
2738 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
2739 q=PopQuantumPixel(quantum_info,pixel,q);
2740 p+=GetPixelChannels(image);
2741 q+=quantum_info->pad;
2747 register unsigned int
2750 range=GetQuantumRange(quantum_info->depth);
2751 if (quantum_info->pack == MagickFalse)
2753 for (x=0; x < (ssize_t) (3*number_pixels-1); x+=2)
2760 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),
2766 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
2772 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),
2774 p+=GetPixelChannels(image);
2778 q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel << 4),
2785 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),
2791 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
2797 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),
2799 p+=GetPixelChannels(image);
2803 q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel << 4),
2805 q+=quantum_info->pad;
2807 for (bit=0; bit < (ssize_t) (3*number_pixels % 2); bit++)
2809 switch ((x+bit) % 3)
2814 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),
2820 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
2826 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),
2828 p+=GetPixelChannels(image);
2832 q=PopShortPixel(quantum_info->endian,(unsigned short) (pixel << 4),
2834 q+=quantum_info->pad;
2837 p+=GetPixelChannels(image);
2840 if (quantum_info->quantum == 32UL)
2842 for (x=0; x < (ssize_t) number_pixels; x++)
2844 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
2845 q=PopQuantumLongPixel(quantum_info,pixel,q);
2846 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
2848 q=PopQuantumLongPixel(quantum_info,pixel,q);
2849 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
2850 q=PopQuantumLongPixel(quantum_info,pixel,q);
2851 p+=GetPixelChannels(image);
2852 q+=quantum_info->pad;
2856 for (x=0; x < (ssize_t) number_pixels; x++)
2858 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
2859 q=PopQuantumPixel(quantum_info,pixel,q);
2860 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range);
2861 q=PopQuantumPixel(quantum_info,pixel,q);
2862 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
2863 q=PopQuantumPixel(quantum_info,pixel,q);
2864 p+=GetPixelChannels(image);
2865 q+=quantum_info->pad;
2871 register unsigned short
2874 if (quantum_info->format == FloatingPointQuantumFormat)
2876 for (x=0; x < (ssize_t) number_pixels; x++)
2878 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelRed(image,p));
2879 q=PopShortPixel(quantum_info->endian,pixel,q);
2880 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelGreen(image,p));
2881 q=PopShortPixel(quantum_info->endian,pixel,q);
2882 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlue(image,p));
2883 q=PopShortPixel(quantum_info->endian,pixel,q);
2884 p+=GetPixelChannels(image);
2885 q+=quantum_info->pad;
2889 for (x=0; x < (ssize_t) number_pixels; x++)
2891 pixel=ScaleQuantumToShort(GetPixelRed(image,p));
2892 q=PopShortPixel(quantum_info->endian,pixel,q);
2893 pixel=ScaleQuantumToShort(GetPixelGreen(image,p));
2894 q=PopShortPixel(quantum_info->endian,pixel,q);
2895 pixel=ScaleQuantumToShort(GetPixelBlue(image,p));
2896 q=PopShortPixel(quantum_info->endian,pixel,q);
2897 p+=GetPixelChannels(image);
2898 q+=quantum_info->pad;
2904 register unsigned int
2907 if (quantum_info->format == FloatingPointQuantumFormat)
2909 for (x=0; x < (ssize_t) number_pixels; x++)
2911 q=PopFloatPixel(quantum_info,(float) GetPixelRed(image,p),q);
2912 q=PopFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q);
2913 q=PopFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q);
2914 p+=GetPixelChannels(image);
2915 q+=quantum_info->pad;
2919 for (x=0; x < (ssize_t) number_pixels; x++)
2921 pixel=ScaleQuantumToLong(GetPixelRed(image,p));
2922 q=PopLongPixel(quantum_info->endian,pixel,q);
2923 pixel=ScaleQuantumToLong(GetPixelGreen(image,p));
2924 q=PopLongPixel(quantum_info->endian,pixel,q);
2925 pixel=ScaleQuantumToLong(GetPixelBlue(image,p));
2926 q=PopLongPixel(quantum_info->endian,pixel,q);
2927 p+=GetPixelChannels(image);
2928 q+=quantum_info->pad;
2934 if (quantum_info->format == FloatingPointQuantumFormat)
2936 for (x=0; x < (ssize_t) number_pixels; x++)
2938 q=PopDoublePixel(quantum_info,(double) GetPixelRed(image,p),q);
2939 q=PopDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q);
2940 q=PopDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q);
2941 p+=GetPixelChannels(image);
2942 q+=quantum_info->pad;
2949 range=GetQuantumRange(quantum_info->depth);
2950 for (x=0; x < (ssize_t) number_pixels; x++)
2952 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p),
2954 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p),
2956 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p),
2958 p+=GetPixelChannels(image);
2959 q+=quantum_info->pad;
2966 static void ExportRGBAQuantum(const Image *image,QuantumInfo *quantum_info,
2967 const MagickSizeType number_pixels,const Quantum *restrict p,
2968 unsigned char *restrict q,ExceptionInfo *exception)
2976 assert(exception != (ExceptionInfo *) NULL);
2977 assert(exception->signature == MagickSignature);
2978 switch (quantum_info->depth)
2982 register unsigned char
2985 for (x=0; x < (ssize_t) number_pixels; x++)
2987 pixel=ScaleQuantumToChar(GetPixelRed(image,p));
2988 q=PopCharPixel(pixel,q);
2989 pixel=ScaleQuantumToChar(GetPixelGreen(image,p));
2990 q=PopCharPixel(pixel,q);
2991 pixel=ScaleQuantumToChar(GetPixelBlue(image,p));
2992 q=PopCharPixel(pixel,q);
2993 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p));
2994 q=PopCharPixel(pixel,q);
2995 p+=GetPixelChannels(image);
2996 q+=quantum_info->pad;
3002 register unsigned int
3005 range=GetQuantumRange(quantum_info->depth);
3006 if (quantum_info->pack == MagickFalse)
3020 for (x=0; x < (ssize_t) number_pixels; x++)
3022 for (i=0; i < 4; i++)
3026 case 0: quantum=GetPixelRed(image,p); break;
3027 case 1: quantum=GetPixelGreen(image,p); break;
3028 case 2: quantum=GetPixelBlue(image,p); break;
3029 case 3: quantum=GetPixelAlpha(image,p); break;
3035 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum,
3041 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum,
3047 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum,
3049 q=PopLongPixel(quantum_info->endian,pixel,q);
3056 p+=GetPixelChannels(image);
3057 q+=quantum_info->pad;
3061 if (quantum_info->quantum == 32UL)
3063 for (x=0; x < (ssize_t) number_pixels; x++)
3065 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
3066 q=PopQuantumLongPixel(quantum_info,pixel,q);
3067 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
3069 q=PopQuantumLongPixel(quantum_info,pixel,q);
3070 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
3071 q=PopQuantumLongPixel(quantum_info,pixel,q);
3072 pixel=(unsigned int) ScaleQuantumToAny(GetPixelAlpha(image,p),
3074 q=PopQuantumLongPixel(quantum_info,pixel,q);
3075 p+=GetPixelChannels(image);
3076 q+=quantum_info->pad;
3080 for (x=0; x < (ssize_t) number_pixels; x++)
3082 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
3083 q=PopQuantumPixel(quantum_info,pixel,q);
3084 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range);
3085 q=PopQuantumPixel(quantum_info,pixel,q);
3086 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
3087 q=PopQuantumPixel(quantum_info,pixel,q);
3088 pixel=(unsigned int) ScaleQuantumToAny(GetPixelAlpha(image,p),range);
3089 q=PopQuantumPixel(quantum_info,pixel,q);
3090 p+=GetPixelChannels(image);
3091 q+=quantum_info->pad;
3097 register unsigned short
3100 if (quantum_info->format == FloatingPointQuantumFormat)
3102 for (x=0; x < (ssize_t) number_pixels; x++)
3104 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelRed(image,p));
3105 q=PopShortPixel(quantum_info->endian,pixel,q);
3106 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelGreen(image,p));
3107 q=PopShortPixel(quantum_info->endian,pixel,q);
3108 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelBlue(image,p));
3109 q=PopShortPixel(quantum_info->endian,pixel,q);
3110 pixel=SinglePrecisionToHalf(QuantumScale*GetPixelAlpha(image,p));
3111 q=PopShortPixel(quantum_info->endian,pixel,q);
3112 p+=GetPixelChannels(image);
3113 q+=quantum_info->pad;
3117 for (x=0; x < (ssize_t) number_pixels; x++)
3119 pixel=ScaleQuantumToShort(GetPixelRed(image,p));
3120 q=PopShortPixel(quantum_info->endian,pixel,q);
3121 pixel=ScaleQuantumToShort(GetPixelGreen(image,p));
3122 q=PopShortPixel(quantum_info->endian,pixel,q);
3123 pixel=ScaleQuantumToShort(GetPixelBlue(image,p));
3124 q=PopShortPixel(quantum_info->endian,pixel,q);
3125 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p));
3126 q=PopShortPixel(quantum_info->endian,pixel,q);
3127 p+=GetPixelChannels(image);
3128 q+=quantum_info->pad;
3134 register unsigned int
3137 if (quantum_info->format == FloatingPointQuantumFormat)
3139 for (x=0; x < (ssize_t) number_pixels; x++)
3144 q=PopFloatPixel(quantum_info,(float) GetPixelRed(image,p),q);
3145 q=PopFloatPixel(quantum_info,(float) GetPixelGreen(image,p),q);
3146 q=PopFloatPixel(quantum_info,(float) GetPixelBlue(image,p),q);
3147 pixel=(float) GetPixelAlpha(image,p);
3148 q=PopFloatPixel(quantum_info,pixel,q);
3149 p+=GetPixelChannels(image);
3150 q+=quantum_info->pad;
3154 for (x=0; x < (ssize_t) number_pixels; x++)
3156 pixel=ScaleQuantumToLong(GetPixelRed(image,p));
3157 q=PopLongPixel(quantum_info->endian,pixel,q);
3158 pixel=ScaleQuantumToLong(GetPixelGreen(image,p));
3159 q=PopLongPixel(quantum_info->endian,pixel,q);
3160 pixel=ScaleQuantumToLong(GetPixelBlue(image,p));
3161 q=PopLongPixel(quantum_info->endian,pixel,q);
3162 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p));
3163 q=PopLongPixel(quantum_info->endian,pixel,q);
3164 p+=GetPixelChannels(image);
3165 q+=quantum_info->pad;
3171 if (quantum_info->format == FloatingPointQuantumFormat)
3176 for (x=0; x < (ssize_t) number_pixels; x++)
3178 q=PopDoublePixel(quantum_info,(double) GetPixelRed(image,p),q);
3179 q=PopDoublePixel(quantum_info,(double) GetPixelGreen(image,p),q);
3180 q=PopDoublePixel(quantum_info,(double) GetPixelBlue(image,p),q);
3181 pixel=(double) GetPixelAlpha(image,p);
3182 q=PopDoublePixel(quantum_info,pixel,q);
3183 p+=GetPixelChannels(image);
3184 q+=quantum_info->pad;
3191 range=GetQuantumRange(quantum_info->depth);
3192 for (x=0; x < (ssize_t) number_pixels; x++)
3194 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p),
3196 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p),
3198 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p),
3200 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p),
3202 p+=GetPixelChannels(image);
3203 q+=quantum_info->pad;
3210 MagickExport size_t ExportQuantumPixels(const Image *image,
3211 CacheView *image_view,QuantumInfo *quantum_info,
3212 const QuantumType quantum_type,unsigned char *restrict pixels,
3213 ExceptionInfo *exception)
3218 register const Quantum
3224 register unsigned char
3230 assert(image != (Image *) NULL);
3231 assert(image->signature == MagickSignature);
3232 if (image->debug != MagickFalse)
3233 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3234 assert(quantum_info != (QuantumInfo *) NULL);
3235 assert(quantum_info->signature == MagickSignature);
3236 if (pixels == (unsigned char *) NULL)
3237 pixels=GetQuantumPixels(quantum_info);
3238 if (image_view == (CacheView *) NULL)
3240 number_pixels=GetImageExtent(image);
3241 p=GetVirtualPixelQueue(image);
3245 number_pixels=GetCacheViewExtent(image_view);
3246 p=GetCacheViewVirtualPixelQueue(image_view);
3248 if (quantum_info->alpha_type == AssociatedQuantumAlpha)
3259 q=GetAuthenticPixelQueue(image);
3260 if (image_view != (CacheView *) NULL)
3261 q=GetCacheViewAuthenticPixelQueue(image_view);
3262 for (x=0; x < (ssize_t) image->columns; x++)
3267 if (GetPixelReadMask(image,q) == 0)
3269 q+=GetPixelChannels(image);
3272 Sa=QuantumScale*GetPixelAlpha(image,q);
3273 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
3275 PixelChannel channel=GetPixelChannelChannel(image,i);
3276 PixelTrait traits=GetPixelChannelTraits(image,channel);
3277 if ((traits & UpdatePixelTrait) == 0)
3279 q[i]=ClampToQuantum(Sa*q[i]);
3281 q+=GetPixelChannels(image);
3284 if ((quantum_type == RGBOQuantum) || (quantum_type == CMYKOQuantum) ||
3285 (quantum_type == BGROQuantum))
3290 q=GetAuthenticPixelQueue(image);
3291 if (image_view != (CacheView *) NULL)
3292 q=GetCacheViewAuthenticPixelQueue(image_view);
3293 for (x=0; x < (ssize_t) number_pixels; x++)
3295 SetPixelAlpha(image,GetPixelAlpha(image,q),q);
3296 q+=GetPixelChannels(image);
3299 if ((quantum_type == CbYCrQuantum) || (quantum_type == CbYCrAQuantum))
3307 q=GetAuthenticPixelQueue(image);
3308 if (image_view != (CacheView *) NULL)
3309 q=GetAuthenticPixelQueue(image);
3310 for (x=0; x < (ssize_t) number_pixels; x++)
3312 quantum=GetPixelRed(image,q);
3313 SetPixelRed(image,GetPixelGreen(image,q),q);
3314 SetPixelGreen(image,quantum,q);
3315 q+=GetPixelChannels(image);
3320 ResetQuantumState(quantum_info);
3321 extent=GetQuantumExtent(image,quantum_info,quantum_type);
3322 switch (quantum_type)
3326 ExportAlphaQuantum(image,quantum_info,number_pixels,p,q,exception);
3331 ExportBGRQuantum(image,quantum_info,number_pixels,p,q,exception);
3337 ExportBGRAQuantum(image,quantum_info,number_pixels,p,q,exception);
3342 ExportBlackQuantum(image,quantum_info,number_pixels,p,q,exception);
3348 ExportBlueQuantum(image,quantum_info,number_pixels,p,q,exception);
3353 ExportCMYKQuantum(image,quantum_info,number_pixels,p,q,exception);
3359 ExportCMYKAQuantum(image,quantum_info,number_pixels,p,q,exception);
3364 ExportCbYCrYQuantum(image,quantum_info,number_pixels,p,q,exception);
3369 ExportGrayQuantum(image,quantum_info,number_pixels,p,q,exception);
3372 case GrayAlphaQuantum:
3374 ExportGrayAlphaQuantum(image,quantum_info,number_pixels,p,q,exception);
3378 case MagentaQuantum:
3380 ExportGreenQuantum(image,quantum_info,number_pixels,p,q,exception);
3385 ExportIndexQuantum(image,quantum_info,number_pixels,p,q,exception);
3388 case IndexAlphaQuantum:
3390 ExportIndexAlphaQuantum(image,quantum_info,number_pixels,p,q,exception);
3396 ExportRedQuantum(image,quantum_info,number_pixels,p,q,exception);
3399 case OpacityQuantum:
3401 ExportOpacityQuantum(image,quantum_info,number_pixels,p,q,exception);
3407 ExportRGBQuantum(image,quantum_info,number_pixels,p,q,exception);
3414 ExportRGBAQuantum(image,quantum_info,number_pixels,p,q,exception);
3420 if ((quantum_type == CbYCrQuantum) || (quantum_type == CbYCrAQuantum))
3428 q=GetAuthenticPixelQueue(image);
3429 if (image_view != (CacheView *) NULL)
3430 q=GetCacheViewAuthenticPixelQueue(image_view);
3431 for (x=0; x < (ssize_t) number_pixels; x++)
3433 quantum=GetPixelRed(image,q);
3434 SetPixelRed(image,GetPixelGreen(image,q),q);
3435 SetPixelGreen(image,quantum,q);
3436 q+=GetPixelChannels(image);
3439 if ((quantum_type == RGBOQuantum) || (quantum_type == CMYKOQuantum) ||
3440 (quantum_type == BGROQuantum))
3445 q=GetAuthenticPixelQueue(image);
3446 if (image_view != (CacheView *) NULL)
3447 q=GetCacheViewAuthenticPixelQueue(image_view);
3448 for (x=0; x < (ssize_t) number_pixels; x++)
3450 SetPixelAlpha(image,GetPixelAlpha(image,q),q);
3451 q+=GetPixelChannels(image);