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"
112static inline unsigned char *PopQuantumDoublePixel(
QuantumInfo *quantum_info,
113 const double pixel,
unsigned char *magick_restrict pixels)
121 (void) memset(quantum,0,
sizeof(quantum));
122 p=(
double *) quantum;
123 *p=(double) (pixel*quantum_info->state.inverse_scale+quantum_info->minimum);
124 if (quantum_info->endian == LSBEndian)
126 *pixels++=quantum[0];
127 *pixels++=quantum[1];
128 *pixels++=quantum[2];
129 *pixels++=quantum[3];
130 *pixels++=quantum[4];
131 *pixels++=quantum[5];
132 *pixels++=quantum[6];
133 *pixels++=quantum[7];
136 *pixels++=quantum[7];
137 *pixels++=quantum[6];
138 *pixels++=quantum[5];
139 *pixels++=quantum[4];
140 *pixels++=quantum[3];
141 *pixels++=quantum[2];
142 *pixels++=quantum[1];
143 *pixels++=quantum[0];
147static inline unsigned char *PopQuantumFloatPixel(
QuantumInfo *quantum_info,
148 const float pixel,
unsigned char *magick_restrict pixels)
156 (void) memset(quantum,0,
sizeof(quantum));
158 *p=(float) ((
double) pixel*quantum_info->state.inverse_scale+
159 quantum_info->minimum);
160 if (quantum_info->endian == LSBEndian)
162 *pixels++=quantum[0];
163 *pixels++=quantum[1];
164 *pixels++=quantum[2];
165 *pixels++=quantum[3];
168 *pixels++=quantum[3];
169 *pixels++=quantum[2];
170 *pixels++=quantum[1];
171 *pixels++=quantum[0];
175static inline unsigned char *PopQuantumPixel(
QuantumInfo *quantum_info,
176 const QuantumAny pixel,
unsigned char *magick_restrict pixels)
184 if (quantum_info->state.bits == 0UL)
185 quantum_info->state.bits=8U;
186 for (i=(ssize_t) quantum_info->depth; i > 0L; )
188 quantum_bits=(size_t) i;
189 if (quantum_bits > quantum_info->state.bits)
190 quantum_bits=quantum_info->state.bits;
191 i-=(ssize_t) quantum_bits;
194 if (quantum_info->state.bits == 8UL)
196 quantum_info->state.bits-=quantum_bits;
197 *pixels|=(((pixel >> i) &~ (((QuantumAny) ~0UL) << quantum_bits)) <<
198 quantum_info->state.bits);
199 if (quantum_info->state.bits == 0UL)
202 quantum_info->state.bits=8UL;
208static inline unsigned char *PopQuantumLongPixel(
QuantumInfo *quantum_info,
209 const size_t pixel,
unsigned char *magick_restrict pixels)
217 if (quantum_info->state.bits == 0U)
218 quantum_info->state.bits=32UL;
219 for (i=(ssize_t) quantum_info->depth; i > 0; )
221 quantum_bits=(size_t) i;
222 if (quantum_bits > quantum_info->state.bits)
223 quantum_bits=quantum_info->state.bits;
224 quantum_info->state.pixel|=(((pixel >> ((ssize_t) quantum_info->depth-i)) &
225 quantum_info->state.mask[quantum_bits]) << (32U-
226 quantum_info->state.bits));
227 i-=(ssize_t) quantum_bits;
228 quantum_info->state.bits-=quantum_bits;
229 if (quantum_info->state.bits == 0U)
231 pixels=PopLongPixel(quantum_info->endian,quantum_info->state.pixel,
233 quantum_info->state.pixel=0U;
234 quantum_info->state.bits=32U;
241 const MagickSizeType number_pixels,
const Quantum *magick_restrict p,
242 unsigned char *magick_restrict q)
250 switch (quantum_info->depth)
257 for (x=0; x < (ssize_t) number_pixels; x++)
259 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p));
260 q=PopCharPixel(pixel,q);
261 p+=(ptrdiff_t) GetPixelChannels(image);
262 q+=(ptrdiff_t) quantum_info->pad;
271 if (quantum_info->format == FloatingPointQuantumFormat)
273 for (x=0; x < (ssize_t) number_pixels; x++)
275 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
276 GetPixelAlpha(image,p));
277 q=PopShortPixel(quantum_info->endian,pixel,q);
278 p+=(ptrdiff_t) GetPixelChannels(image);
279 q+=(ptrdiff_t) 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+=(ptrdiff_t) GetPixelChannels(image);
288 q+=(ptrdiff_t) quantum_info->pad;
297 if (quantum_info->format == FloatingPointQuantumFormat)
299 for (x=0; x < (ssize_t) number_pixels; x++)
301 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelAlpha(image,p),q);
302 p+=(ptrdiff_t) GetPixelChannels(image);
303 q+=(ptrdiff_t) 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+=(ptrdiff_t) GetPixelChannels(image);
312 q+=(ptrdiff_t) quantum_info->pad;
318 if (quantum_info->format == FloatingPointQuantumFormat)
320 for (x=0; x < (ssize_t) number_pixels; x++)
322 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelAlpha(image,p),q);
323 p+=(ptrdiff_t) GetPixelChannels(image);
324 q+=(ptrdiff_t) quantum_info->pad;
332 range=GetQuantumRange(quantum_info->depth);
333 for (x=0; x < (ssize_t) number_pixels; x++)
335 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p),
337 p+=(ptrdiff_t) GetPixelChannels(image);
338 q+=(ptrdiff_t) quantum_info->pad;
346 const MagickSizeType number_pixels,
const Quantum *magick_restrict p,
347 unsigned char *magick_restrict q)
358 switch (quantum_info->depth)
362 for (x=0; x < (ssize_t) number_pixels; x++)
364 q=PopCharPixel(ScaleQuantumToChar(GetPixelBlue(image,p)),q);
365 q=PopCharPixel(ScaleQuantumToChar(GetPixelGreen(image,p)),q);
366 q=PopCharPixel(ScaleQuantumToChar(GetPixelRed(image,p)),q);
367 p+=(ptrdiff_t) GetPixelChannels(image);
368 q+=(ptrdiff_t) quantum_info->pad;
377 range=GetQuantumRange(quantum_info->depth);
378 if (quantum_info->pack == MagickFalse)
380 for (x=0; x < (ssize_t) number_pixels; x++)
382 pixel=(
unsigned int) (
383 ScaleQuantumToAny(GetPixelRed(image,p),range) << 22 |
384 ScaleQuantumToAny(GetPixelGreen(image,p),range) << 12 |
385 ScaleQuantumToAny(GetPixelBlue(image,p),range) << 2);
386 q=PopLongPixel(quantum_info->endian,pixel,q);
387 p+=(ptrdiff_t) GetPixelChannels(image);
388 q+=(ptrdiff_t) quantum_info->pad;
392 if (quantum_info->quantum == 32UL)
394 for (x=0; x < (ssize_t) number_pixels; x++)
396 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
397 q=PopQuantumLongPixel(quantum_info,pixel,q);
398 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
400 q=PopQuantumLongPixel(quantum_info,pixel,q);
401 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
402 q=PopQuantumLongPixel(quantum_info,pixel,q);
403 p+=(ptrdiff_t) GetPixelChannels(image);
404 q+=(ptrdiff_t) quantum_info->pad;
408 for (x=0; x < (ssize_t) number_pixels; x++)
410 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
411 q=PopQuantumPixel(quantum_info,pixel,q);
412 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range);
413 q=PopQuantumPixel(quantum_info,pixel,q);
414 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
415 q=PopQuantumPixel(quantum_info,pixel,q);
416 p+=(ptrdiff_t) GetPixelChannels(image);
417 q+=(ptrdiff_t) quantum_info->pad;
426 range=GetQuantumRange(quantum_info->depth);
427 if (quantum_info->pack == MagickFalse)
429 for (x=0; x < (ssize_t) (3*number_pixels-1); x+=2)
436 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),
442 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
448 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),
450 p+=(ptrdiff_t) GetPixelChannels(image);
454 q=PopShortPixel(quantum_info->endian,(
unsigned short) (pixel << 4),
461 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),
467 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
473 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),
475 p+=(ptrdiff_t) GetPixelChannels(image);
479 q=PopShortPixel(quantum_info->endian,(
unsigned short) (pixel << 4),
481 q+=(ptrdiff_t) quantum_info->pad;
483 for (bit=0; bit < (ssize_t) (3*number_pixels % 2); bit++)
490 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),
496 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
502 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),
504 p+=(ptrdiff_t) GetPixelChannels(image);
508 q=PopShortPixel(quantum_info->endian,(
unsigned short) (pixel << 4),
510 q+=(ptrdiff_t) quantum_info->pad;
513 p+=(ptrdiff_t) GetPixelChannels(image);
516 if (quantum_info->quantum == 32UL)
518 for (x=0; x < (ssize_t) number_pixels; x++)
520 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
521 q=PopQuantumLongPixel(quantum_info,pixel,q);
522 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
524 q=PopQuantumLongPixel(quantum_info,pixel,q);
525 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
526 q=PopQuantumLongPixel(quantum_info,pixel,q);
527 p+=(ptrdiff_t) GetPixelChannels(image);
528 q+=(ptrdiff_t) quantum_info->pad;
532 for (x=0; x < (ssize_t) number_pixels; x++)
534 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
535 q=PopQuantumPixel(quantum_info,pixel,q);
536 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range);
537 q=PopQuantumPixel(quantum_info,pixel,q);
538 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
539 q=PopQuantumPixel(quantum_info,pixel,q);
540 p+=(ptrdiff_t) GetPixelChannels(image);
541 q+=(ptrdiff_t) quantum_info->pad;
550 if (quantum_info->format == FloatingPointQuantumFormat)
552 for (x=0; x < (ssize_t) number_pixels; x++)
554 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
555 GetPixelBlue(image,p));
556 q=PopShortPixel(quantum_info->endian,pixel,q);
557 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
558 GetPixelGreen(image,p));
559 q=PopShortPixel(quantum_info->endian,pixel,q);
560 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
561 GetPixelRed(image,p));
562 q=PopShortPixel(quantum_info->endian,pixel,q);
563 p+=(ptrdiff_t) GetPixelChannels(image);
564 q+=(ptrdiff_t) quantum_info->pad;
568 for (x=0; x < (ssize_t) number_pixels; x++)
570 pixel=ScaleQuantumToShort(GetPixelBlue(image,p));
571 q=PopShortPixel(quantum_info->endian,pixel,q);
572 pixel=ScaleQuantumToShort(GetPixelGreen(image,p));
573 q=PopShortPixel(quantum_info->endian,pixel,q);
574 pixel=ScaleQuantumToShort(GetPixelRed(image,p));
575 q=PopShortPixel(quantum_info->endian,pixel,q);
576 p+=(ptrdiff_t) GetPixelChannels(image);
577 q+=(ptrdiff_t) quantum_info->pad;
586 if (quantum_info->format == FloatingPointQuantumFormat)
588 for (x=0; x < (ssize_t) number_pixels; x++)
590 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelRed(image,p),q);
591 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelGreen(image,p),q);
592 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelBlue(image,p),q);
593 p+=(ptrdiff_t) GetPixelChannels(image);
594 q+=(ptrdiff_t) quantum_info->pad;
598 for (x=0; x < (ssize_t) number_pixels; x++)
600 pixel=ScaleQuantumToLong(GetPixelBlue(image,p));
601 q=PopLongPixel(quantum_info->endian,pixel,q);
602 pixel=ScaleQuantumToLong(GetPixelGreen(image,p));
603 q=PopLongPixel(quantum_info->endian,pixel,q);
604 pixel=ScaleQuantumToLong(GetPixelRed(image,p));
605 q=PopLongPixel(quantum_info->endian,pixel,q);
606 p+=(ptrdiff_t) GetPixelChannels(image);
607 q+=(ptrdiff_t) quantum_info->pad;
613 if (quantum_info->format == FloatingPointQuantumFormat)
615 for (x=0; x < (ssize_t) number_pixels; x++)
617 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelRed(image,p),q);
618 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelGreen(image,p),q);
619 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelBlue(image,p),q);
620 p+=(ptrdiff_t) GetPixelChannels(image);
621 q+=(ptrdiff_t) quantum_info->pad;
629 range=GetQuantumRange(quantum_info->depth);
630 for (x=0; x < (ssize_t) number_pixels; x++)
632 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p),
634 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p),
636 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p),
638 p+=(ptrdiff_t) GetPixelChannels(image);
639 q+=(ptrdiff_t) quantum_info->pad;
647 const MagickSizeType number_pixels,
const Quantum *magick_restrict p,
648 unsigned char *magick_restrict q)
656 switch (quantum_info->depth)
663 for (x=0; x < (ssize_t) number_pixels; x++)
665 pixel=ScaleQuantumToChar(GetPixelBlue(image,p));
666 q=PopCharPixel(pixel,q);
667 pixel=ScaleQuantumToChar(GetPixelGreen(image,p));
668 q=PopCharPixel(pixel,q);
669 pixel=ScaleQuantumToChar(GetPixelRed(image,p));
670 q=PopCharPixel(pixel,q);
671 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p));
672 q=PopCharPixel(pixel,q);
673 p+=(ptrdiff_t) GetPixelChannels(image);
674 q+=(ptrdiff_t) quantum_info->pad;
683 range=GetQuantumRange(quantum_info->depth);
684 if (quantum_info->pack == MagickFalse)
698 for (x=0; x < (ssize_t) number_pixels; x++)
700 for (i=0; i < 4; i++)
704 case 0: quantum=(size_t) GetPixelRed(image,p);
break;
705 case 1: quantum=(size_t) GetPixelGreen(image,p);
break;
706 case 2: quantum=(size_t) GetPixelBlue(image,p);
break;
707 case 3: quantum=(size_t) GetPixelAlpha(image,p);
break;
713 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum,
719 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum,
725 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum,
727 q=PopLongPixel(quantum_info->endian,pixel,q);
734 p+=(ptrdiff_t) GetPixelChannels(image);
735 q+=(ptrdiff_t) quantum_info->pad;
739 if (quantum_info->quantum == 32UL)
741 for (x=0; x < (ssize_t) number_pixels; x++)
743 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
744 q=PopQuantumLongPixel(quantum_info,pixel,q);
745 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
747 q=PopQuantumLongPixel(quantum_info,pixel,q);
748 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
749 q=PopQuantumLongPixel(quantum_info,pixel,q);
750 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelAlpha(image,p),
752 q=PopQuantumLongPixel(quantum_info,pixel,q);
753 p+=(ptrdiff_t) GetPixelChannels(image);
754 q+=(ptrdiff_t) quantum_info->pad;
758 for (x=0; x < (ssize_t) number_pixels; x++)
760 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
761 q=PopQuantumPixel(quantum_info,pixel,q);
762 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range);
763 q=PopQuantumPixel(quantum_info,pixel,q);
764 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
765 q=PopQuantumPixel(quantum_info,pixel,q);
766 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelAlpha(image,p),range);
767 q=PopQuantumPixel(quantum_info,pixel,q);
768 p+=(ptrdiff_t) GetPixelChannels(image);
769 q+=(ptrdiff_t) quantum_info->pad;
778 if (quantum_info->format == FloatingPointQuantumFormat)
780 for (x=0; x < (ssize_t) number_pixels; x++)
782 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
783 GetPixelBlue(image,p));
784 q=PopShortPixel(quantum_info->endian,pixel,q);
785 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
786 GetPixelGreen(image,p));
787 q=PopShortPixel(quantum_info->endian,pixel,q);
788 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
789 GetPixelRed(image,p));
790 q=PopShortPixel(quantum_info->endian,pixel,q);
791 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
792 GetPixelAlpha(image,p));
793 q=PopShortPixel(quantum_info->endian,pixel,q);
794 p+=(ptrdiff_t) GetPixelChannels(image);
795 q+=(ptrdiff_t) quantum_info->pad;
799 for (x=0; x < (ssize_t) number_pixels; x++)
801 pixel=ScaleQuantumToShort(GetPixelBlue(image,p));
802 q=PopShortPixel(quantum_info->endian,pixel,q);
803 pixel=ScaleQuantumToShort(GetPixelGreen(image,p));
804 q=PopShortPixel(quantum_info->endian,pixel,q);
805 pixel=ScaleQuantumToShort(GetPixelRed(image,p));
806 q=PopShortPixel(quantum_info->endian,pixel,q);
807 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p));
808 q=PopShortPixel(quantum_info->endian,pixel,q);
809 p+=(ptrdiff_t) GetPixelChannels(image);
810 q+=(ptrdiff_t) quantum_info->pad;
819 if (quantum_info->format == FloatingPointQuantumFormat)
821 for (x=0; x < (ssize_t) number_pixels; x++)
826 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelRed(image,p),q);
827 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelGreen(image,p),q);
828 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelBlue(image,p),q);
829 float_pixel=(float) GetPixelAlpha(image,p);
830 q=PopQuantumFloatPixel(quantum_info,float_pixel,q);
831 p+=(ptrdiff_t) GetPixelChannels(image);
832 q+=(ptrdiff_t) quantum_info->pad;
836 for (x=0; x < (ssize_t) number_pixels; x++)
838 pixel=ScaleQuantumToLong(GetPixelBlue(image,p));
839 q=PopLongPixel(quantum_info->endian,pixel,q);
840 pixel=ScaleQuantumToLong(GetPixelGreen(image,p));
841 q=PopLongPixel(quantum_info->endian,pixel,q);
842 pixel=ScaleQuantumToLong(GetPixelRed(image,p));
843 q=PopLongPixel(quantum_info->endian,pixel,q);
844 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p));
845 q=PopLongPixel(quantum_info->endian,pixel,q);
846 p+=(ptrdiff_t) GetPixelChannels(image);
847 q+=(ptrdiff_t) quantum_info->pad;
853 if (quantum_info->format == FloatingPointQuantumFormat)
858 for (x=0; x < (ssize_t) number_pixels; x++)
860 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelRed(image,p),q);
861 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelGreen(image,p),q);
862 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelBlue(image,p),q);
863 pixel=(double) GetPixelAlpha(image,p);
864 q=PopQuantumDoublePixel(quantum_info,pixel,q);
865 p+=(ptrdiff_t) GetPixelChannels(image);
866 q+=(ptrdiff_t) quantum_info->pad;
874 range=GetQuantumRange(quantum_info->depth);
875 for (x=0; x < (ssize_t) number_pixels; x++)
877 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p),
879 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p),
881 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p),
883 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p),
885 p+=(ptrdiff_t) GetPixelChannels(image);
886 q+=(ptrdiff_t) quantum_info->pad;
894 const MagickSizeType number_pixels,
const Quantum *magick_restrict p,
895 unsigned char *magick_restrict q)
903 switch (quantum_info->depth)
910 for (x=0; x < (ssize_t) number_pixels; x++)
912 pixel=ScaleQuantumToChar(GetPixelBlue(image,p));
913 q=PopCharPixel(pixel,q);
914 pixel=ScaleQuantumToChar(GetPixelGreen(image,p));
915 q=PopCharPixel(pixel,q);
916 pixel=ScaleQuantumToChar(GetPixelRed(image,p));
917 q=PopCharPixel(pixel,q);
918 pixel=ScaleQuantumToChar(GetPixelOpacity(image,p));
919 q=PopCharPixel(pixel,q);
920 p+=(ptrdiff_t) GetPixelChannels(image);
921 q+=(ptrdiff_t) quantum_info->pad;
930 range=GetQuantumRange(quantum_info->depth);
931 if (quantum_info->pack == MagickFalse)
945 for (x=0; x < (ssize_t) number_pixels; x++)
947 for (i=0; i < 4; i++)
951 case 0: quantum=(size_t) GetPixelRed(image,p);
break;
952 case 1: quantum=(size_t) GetPixelGreen(image,p);
break;
953 case 2: quantum=(size_t) GetPixelBlue(image,p);
break;
954 case 3: quantum=(size_t) GetPixelOpacity(image,p);
break;
960 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum,
966 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum,
972 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum,
974 q=PopLongPixel(quantum_info->endian,pixel,q);
981 p+=(ptrdiff_t) GetPixelChannels(image);
982 q+=(ptrdiff_t) quantum_info->pad;
986 if (quantum_info->quantum == 32UL)
988 for (x=0; x < (ssize_t) number_pixels; x++)
990 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
991 q=PopQuantumLongPixel(quantum_info,pixel,q);
992 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
994 q=PopQuantumLongPixel(quantum_info,pixel,q);
995 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
996 q=PopQuantumLongPixel(quantum_info,pixel,q);
997 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelOpacity(image,p),
999 q=PopQuantumLongPixel(quantum_info,pixel,q);
1000 p+=(ptrdiff_t) GetPixelChannels(image);
1001 q+=(ptrdiff_t) quantum_info->pad;
1005 for (x=0; x < (ssize_t) number_pixels; x++)
1007 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
1008 q=PopQuantumPixel(quantum_info,pixel,q);
1009 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range);
1010 q=PopQuantumPixel(quantum_info,pixel,q);
1011 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
1012 q=PopQuantumPixel(quantum_info,pixel,q);
1013 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelOpacity(image,p),range);
1014 q=PopQuantumPixel(quantum_info,pixel,q);
1015 p+=(ptrdiff_t) GetPixelChannels(image);
1016 q+=(ptrdiff_t) quantum_info->pad;
1025 if (quantum_info->format == FloatingPointQuantumFormat)
1027 for (x=0; x < (ssize_t) number_pixels; x++)
1029 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
1030 GetPixelBlue(image,p));
1031 q=PopShortPixel(quantum_info->endian,pixel,q);
1032 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
1033 GetPixelGreen(image,p));
1034 q=PopShortPixel(quantum_info->endian,pixel,q);
1035 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
1036 GetPixelRed(image,p));
1037 q=PopShortPixel(quantum_info->endian,pixel,q);
1038 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
1039 GetPixelOpacity(image,p));
1040 q=PopShortPixel(quantum_info->endian,pixel,q);
1041 p+=(ptrdiff_t) GetPixelChannels(image);
1042 q+=(ptrdiff_t) quantum_info->pad;
1046 for (x=0; x < (ssize_t) number_pixels; x++)
1048 pixel=ScaleQuantumToShort(GetPixelBlue(image,p));
1049 q=PopShortPixel(quantum_info->endian,pixel,q);
1050 pixel=ScaleQuantumToShort(GetPixelGreen(image,p));
1051 q=PopShortPixel(quantum_info->endian,pixel,q);
1052 pixel=ScaleQuantumToShort(GetPixelRed(image,p));
1053 q=PopShortPixel(quantum_info->endian,pixel,q);
1054 pixel=ScaleQuantumToShort(GetPixelOpacity(image,p));
1055 q=PopShortPixel(quantum_info->endian,pixel,q);
1056 p+=(ptrdiff_t) GetPixelChannels(image);
1057 q+=(ptrdiff_t) quantum_info->pad;
1066 if (quantum_info->format == FloatingPointQuantumFormat)
1068 for (x=0; x < (ssize_t) number_pixels; x++)
1073 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelRed(image,p),q);
1074 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelGreen(image,p),q);
1075 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelBlue(image,p),q);
1076 float_pixel=(float) GetPixelOpacity(image,p);
1077 q=PopQuantumFloatPixel(quantum_info,float_pixel,q);
1078 p+=(ptrdiff_t) GetPixelChannels(image);
1079 q+=(ptrdiff_t) quantum_info->pad;
1083 for (x=0; x < (ssize_t) number_pixels; x++)
1085 pixel=ScaleQuantumToLong(GetPixelBlue(image,p));
1086 q=PopLongPixel(quantum_info->endian,pixel,q);
1087 pixel=ScaleQuantumToLong(GetPixelGreen(image,p));
1088 q=PopLongPixel(quantum_info->endian,pixel,q);
1089 pixel=ScaleQuantumToLong(GetPixelRed(image,p));
1090 q=PopLongPixel(quantum_info->endian,pixel,q);
1091 pixel=ScaleQuantumToLong(GetPixelOpacity(image,p));
1092 q=PopLongPixel(quantum_info->endian,pixel,q);
1093 p+=(ptrdiff_t) GetPixelChannels(image);
1094 q+=(ptrdiff_t) quantum_info->pad;
1100 if (quantum_info->format == FloatingPointQuantumFormat)
1105 for (x=0; x < (ssize_t) number_pixels; x++)
1107 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelRed(image,p),q);
1108 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelGreen(image,p),q);
1109 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelBlue(image,p),q);
1110 pixel=(double) GetPixelOpacity(image,p);
1111 q=PopQuantumDoublePixel(quantum_info,pixel,q);
1112 p+=(ptrdiff_t) GetPixelChannels(image);
1113 q+=(ptrdiff_t) quantum_info->pad;
1121 range=GetQuantumRange(quantum_info->depth);
1122 for (x=0; x < (ssize_t) number_pixels; x++)
1124 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p),
1126 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p),
1128 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p),
1130 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelOpacity(image,p),
1132 p+=(ptrdiff_t) GetPixelChannels(image);
1133 q+=(ptrdiff_t) quantum_info->pad;
1140static void ExportBlackQuantum(
const Image *image,
QuantumInfo *quantum_info,
1141 const MagickSizeType number_pixels,
const Quantum *magick_restrict p,
1151 assert(exception->signature == MagickCoreSignature);
1152 if (image->colorspace != CMYKColorspace)
1154 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1155 "ColorSeparatedImageRequired",
"`%s'",image->filename);
1158 switch (quantum_info->depth)
1165 for (x=0; x < (ssize_t) number_pixels; x++)
1167 pixel=ScaleQuantumToChar(GetPixelBlack(image,p));
1168 q=PopCharPixel(pixel,q);
1169 p+=(ptrdiff_t) GetPixelChannels(image);
1170 q+=(ptrdiff_t) quantum_info->pad;
1179 if (quantum_info->format == FloatingPointQuantumFormat)
1181 for (x=0; x < (ssize_t) number_pixels; x++)
1183 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
1184 GetPixelBlack(image,p));
1185 q=PopShortPixel(quantum_info->endian,pixel,q);
1186 p+=(ptrdiff_t) GetPixelChannels(image);
1187 q+=(ptrdiff_t) quantum_info->pad;
1191 for (x=0; x < (ssize_t) number_pixels; x++)
1193 pixel=ScaleQuantumToShort(GetPixelBlack(image,p));
1194 q=PopShortPixel(quantum_info->endian,pixel,q);
1195 p+=(ptrdiff_t) GetPixelChannels(image);
1196 q+=(ptrdiff_t) quantum_info->pad;
1205 if (quantum_info->format == FloatingPointQuantumFormat)
1207 for (x=0; x < (ssize_t) number_pixels; x++)
1209 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelBlack(image,p),q);
1210 p+=(ptrdiff_t) GetPixelChannels(image);
1211 q+=(ptrdiff_t) quantum_info->pad;
1215 for (x=0; x < (ssize_t) number_pixels; x++)
1217 pixel=ScaleQuantumToLong(GetPixelBlack(image,p));
1218 q=PopLongPixel(quantum_info->endian,pixel,q);
1219 p+=(ptrdiff_t) GetPixelChannels(image);
1220 q+=(ptrdiff_t) quantum_info->pad;
1226 if (quantum_info->format == FloatingPointQuantumFormat)
1228 for (x=0; x < (ssize_t) number_pixels; x++)
1230 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelBlack(image,p),q);
1231 p+=(ptrdiff_t) GetPixelChannels(image);
1232 q+=(ptrdiff_t) quantum_info->pad;
1240 range=GetQuantumRange(quantum_info->depth);
1241 for (x=0; x < (ssize_t) number_pixels; x++)
1243 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlack(image,p),
1245 p+=(ptrdiff_t) GetPixelChannels(image);
1246 q+=(ptrdiff_t) quantum_info->pad;
1254 const MagickSizeType number_pixels,
const Quantum *magick_restrict p,
1255 unsigned char *magick_restrict q)
1263 switch (quantum_info->depth)
1270 for (x=0; x < (ssize_t) number_pixels; x++)
1272 pixel=ScaleQuantumToChar(GetPixelBlue(image,p));
1273 q=PopCharPixel(pixel,q);
1274 p+=(ptrdiff_t) GetPixelChannels(image);
1275 q+=(ptrdiff_t) quantum_info->pad;
1284 if (quantum_info->format == FloatingPointQuantumFormat)
1286 for (x=0; x < (ssize_t) number_pixels; x++)
1288 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
1289 GetPixelBlue(image,p));
1290 q=PopShortPixel(quantum_info->endian,pixel,q);
1291 p+=(ptrdiff_t) GetPixelChannels(image);
1292 q+=(ptrdiff_t) quantum_info->pad;
1296 for (x=0; x < (ssize_t) number_pixels; x++)
1298 pixel=ScaleQuantumToShort(GetPixelBlue(image,p));
1299 q=PopShortPixel(quantum_info->endian,pixel,q);
1300 p+=(ptrdiff_t) GetPixelChannels(image);
1301 q+=(ptrdiff_t) quantum_info->pad;
1310 if (quantum_info->format == FloatingPointQuantumFormat)
1312 for (x=0; x < (ssize_t) number_pixels; x++)
1314 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelBlue(image,p),q);
1315 p+=(ptrdiff_t) GetPixelChannels(image);
1316 q+=(ptrdiff_t) quantum_info->pad;
1320 for (x=0; x < (ssize_t) number_pixels; x++)
1322 pixel=ScaleQuantumToLong(GetPixelBlue(image,p));
1323 q=PopLongPixel(quantum_info->endian,pixel,q);
1324 p+=(ptrdiff_t) GetPixelChannels(image);
1325 q+=(ptrdiff_t) quantum_info->pad;
1331 if (quantum_info->format == FloatingPointQuantumFormat)
1333 for (x=0; x < (ssize_t) number_pixels; x++)
1335 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelBlue(image,p),q);
1336 p+=(ptrdiff_t) GetPixelChannels(image);
1337 q+=(ptrdiff_t) quantum_info->pad;
1345 range=GetQuantumRange(quantum_info->depth);
1346 for (x=0; x < (ssize_t) number_pixels; x++)
1348 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p),
1350 p+=(ptrdiff_t) GetPixelChannels(image);
1351 q+=(ptrdiff_t) quantum_info->pad;
1358static void ExportCbYCrYQuantum(
const Image *image,
QuantumInfo *quantum_info,
1359 const MagickSizeType number_pixels,
const Quantum *magick_restrict p,
1360 unsigned char *magick_restrict q)
1380 switch (quantum_info->depth)
1384 if (quantum_info->pack == MagickFalse)
1386 for (x=0; x < (ssize_t) number_pixels; x+=2)
1388 for (i=0; i < 4; i++)
1394 quantum=(size_t) GetPixelRed(image,p);
1399 quantum=(size_t) GetPixelGreen(image,p);
1404 quantum=(size_t) GetPixelBlue(image,p);
1408 cbcr[i]=(Quantum) quantum;
1411 pixel=(
unsigned int) ((
size_t) (cbcr[1]) << 22 | (
size_t)
1412 (cbcr[0]) << 12 | (
size_t) (cbcr[2]) << 2);
1413 q=PopLongPixel(quantum_info->endian,pixel,q);
1414 p+=(ptrdiff_t) GetPixelChannels(image);
1415 pixel=(
unsigned int) ((
size_t) (cbcr[3]) << 22 | (
size_t)
1416 (cbcr[0]) << 12 | (
size_t) (cbcr[2]) << 2);
1417 q=PopLongPixel(quantum_info->endian,pixel,q);
1418 p+=(ptrdiff_t) GetPixelChannels(image);
1419 q+=(ptrdiff_t) quantum_info->pad;
1430 for (x=0; x < (ssize_t) number_pixels; x+=2)
1432 for (i=0; i < 4; i++)
1438 quantum=(size_t) GetPixelRed(image,p);
1443 quantum=(size_t) GetPixelGreen(image,p);
1448 quantum=(size_t) GetPixelBlue(image,p);
1452 cbcr[i]=(Quantum) quantum;
1455 range=GetQuantumRange(quantum_info->depth);
1456 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[1],range),q);
1457 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[0],range),q);
1458 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[2],range),q);
1459 p+=(ptrdiff_t) GetPixelChannels(image);
1460 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[3],range),q);
1461 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[0],range),q);
1462 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(cbcr[2],range),q);
1463 p+=(ptrdiff_t) GetPixelChannels(image);
1464 q+=(ptrdiff_t) quantum_info->pad;
1472 const MagickSizeType number_pixels,
const Quantum *magick_restrict p,
1479 assert(exception->signature == MagickCoreSignature);
1480 if (image->colorspace != CMYKColorspace)
1482 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1483 "ColorSeparatedImageRequired",
"`%s'",image->filename);
1486 switch (quantum_info->depth)
1493 for (x=0; x < (ssize_t) number_pixels; x++)
1495 pixel=ScaleQuantumToChar(GetPixelRed(image,p));
1496 q=PopCharPixel(pixel,q);
1497 pixel=ScaleQuantumToChar(GetPixelGreen(image,p));
1498 q=PopCharPixel(pixel,q);
1499 pixel=ScaleQuantumToChar(GetPixelBlue(image,p));
1500 q=PopCharPixel(pixel,q);
1501 pixel=ScaleQuantumToChar(GetPixelBlack(image,p));
1502 q=PopCharPixel(pixel,q);
1503 p+=(ptrdiff_t) GetPixelChannels(image);
1504 q+=(ptrdiff_t) quantum_info->pad;
1513 if (quantum_info->format == FloatingPointQuantumFormat)
1515 for (x=0; x < (ssize_t) number_pixels; x++)
1517 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
1518 GetPixelRed(image,p));
1519 q=PopShortPixel(quantum_info->endian,pixel,q);
1520 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
1521 GetPixelGreen(image,p));
1522 q=PopShortPixel(quantum_info->endian,pixel,q);
1523 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
1524 GetPixelBlue(image,p));
1525 q=PopShortPixel(quantum_info->endian,pixel,q);
1526 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
1527 GetPixelBlack(image,p));
1528 q=PopShortPixel(quantum_info->endian,pixel,q);
1529 p+=(ptrdiff_t) GetPixelChannels(image);
1530 q+=(ptrdiff_t) quantum_info->pad;
1534 for (x=0; x < (ssize_t) number_pixels; x++)
1536 pixel=ScaleQuantumToShort(GetPixelRed(image,p));
1537 q=PopShortPixel(quantum_info->endian,pixel,q);
1538 pixel=ScaleQuantumToShort(GetPixelGreen(image,p));
1539 q=PopShortPixel(quantum_info->endian,pixel,q);
1540 pixel=ScaleQuantumToShort(GetPixelBlue(image,p));
1541 q=PopShortPixel(quantum_info->endian,pixel,q);
1542 pixel=ScaleQuantumToShort(GetPixelBlack(image,p));
1543 q=PopShortPixel(quantum_info->endian,pixel,q);
1544 p+=(ptrdiff_t) GetPixelChannels(image);
1545 q+=(ptrdiff_t) quantum_info->pad;
1554 if (quantum_info->format == FloatingPointQuantumFormat)
1556 for (x=0; x < (ssize_t) number_pixels; x++)
1558 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelRed(image,p),q);
1559 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelGreen(image,p),q);
1560 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelBlue(image,p),q);
1561 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelBlack(image,p),q);
1562 p+=(ptrdiff_t) GetPixelChannels(image);
1563 q+=(ptrdiff_t) quantum_info->pad;
1567 for (x=0; x < (ssize_t) number_pixels; x++)
1569 pixel=ScaleQuantumToLong(GetPixelRed(image,p));
1570 q=PopLongPixel(quantum_info->endian,pixel,q);
1571 pixel=ScaleQuantumToLong(GetPixelGreen(image,p));
1572 q=PopLongPixel(quantum_info->endian,pixel,q);
1573 pixel=ScaleQuantumToLong(GetPixelBlue(image,p));
1574 q=PopLongPixel(quantum_info->endian,pixel,q);
1575 pixel=ScaleQuantumToLong(GetPixelBlack(image,p));
1576 q=PopLongPixel(quantum_info->endian,pixel,q);
1577 p+=(ptrdiff_t) GetPixelChannels(image);
1578 q+=(ptrdiff_t) quantum_info->pad;
1584 if (quantum_info->format == FloatingPointQuantumFormat)
1586 for (x=0; x < (ssize_t) number_pixels; x++)
1588 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelRed(image,p),q);
1589 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelGreen(image,p),q);
1590 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelBlue(image,p),q);
1591 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelBlack(image,p),q);
1592 p+=(ptrdiff_t) GetPixelChannels(image);
1593 q+=(ptrdiff_t) quantum_info->pad;
1604 range=GetQuantumRange(quantum_info->depth);
1605 for (x=0; x < (ssize_t) number_pixels; x++)
1607 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p),
1609 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p),
1611 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p),
1613 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlack(image,p),
1615 p+=(ptrdiff_t) GetPixelChannels(image);
1616 q+=(ptrdiff_t) quantum_info->pad;
1623static void ExportCMYKAQuantum(
const Image *image,
QuantumInfo *quantum_info,
1624 const MagickSizeType number_pixels,
const Quantum *magick_restrict p,
1631 assert(exception->signature == MagickCoreSignature);
1632 if (image->colorspace != CMYKColorspace)
1634 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1635 "ColorSeparatedImageRequired",
"`%s'",image->filename);
1638 switch (quantum_info->depth)
1645 for (x=0; x < (ssize_t) number_pixels; x++)
1647 pixel=ScaleQuantumToChar(GetPixelRed(image,p));
1648 q=PopCharPixel(pixel,q);
1649 pixel=ScaleQuantumToChar(GetPixelGreen(image,p));
1650 q=PopCharPixel(pixel,q);
1651 pixel=ScaleQuantumToChar(GetPixelBlue(image,p));
1652 q=PopCharPixel(pixel,q);
1653 pixel=ScaleQuantumToChar(GetPixelBlack(image,p));
1654 q=PopCharPixel(pixel,q);
1655 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p));
1656 q=PopCharPixel(pixel,q);
1657 p+=(ptrdiff_t) GetPixelChannels(image);
1658 q+=(ptrdiff_t) quantum_info->pad;
1667 if (quantum_info->format == FloatingPointQuantumFormat)
1669 for (x=0; x < (ssize_t) number_pixels; x++)
1671 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
1672 GetPixelRed(image,p));
1673 q=PopShortPixel(quantum_info->endian,pixel,q);
1674 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
1675 GetPixelGreen(image,p));
1676 q=PopShortPixel(quantum_info->endian,pixel,q);
1677 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
1678 GetPixelBlue(image,p));
1679 q=PopShortPixel(quantum_info->endian,pixel,q);
1680 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
1681 GetPixelBlack(image,p));
1682 q=PopShortPixel(quantum_info->endian,pixel,q);
1683 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
1684 GetPixelAlpha(image,p));
1685 q=PopShortPixel(quantum_info->endian,pixel,q);
1686 p+=(ptrdiff_t) GetPixelChannels(image);
1687 q+=(ptrdiff_t) quantum_info->pad;
1691 for (x=0; x < (ssize_t) number_pixels; x++)
1693 pixel=ScaleQuantumToShort(GetPixelRed(image,p));
1694 q=PopShortPixel(quantum_info->endian,pixel,q);
1695 pixel=ScaleQuantumToShort(GetPixelGreen(image,p));
1696 q=PopShortPixel(quantum_info->endian,pixel,q);
1697 pixel=ScaleQuantumToShort(GetPixelBlue(image,p));
1698 q=PopShortPixel(quantum_info->endian,pixel,q);
1699 pixel=ScaleQuantumToShort(GetPixelBlack(image,p));
1700 q=PopShortPixel(quantum_info->endian,pixel,q);
1701 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p));
1702 q=PopShortPixel(quantum_info->endian,pixel,q);
1703 p+=(ptrdiff_t) GetPixelChannels(image);
1704 q+=(ptrdiff_t) quantum_info->pad;
1713 if (quantum_info->format == FloatingPointQuantumFormat)
1715 for (x=0; x < (ssize_t) number_pixels; x++)
1717 q=PopQuantumFloatPixel(quantum_info,(
float)
1718 GetPixelRed(image,p),q);
1719 q=PopQuantumFloatPixel(quantum_info,(
float)
1720 GetPixelGreen(image,p),q);
1721 q=PopQuantumFloatPixel(quantum_info,(
float)
1722 GetPixelBlue(image,p),q);
1723 q=PopQuantumFloatPixel(quantum_info,(
float)
1724 GetPixelBlack(image,p),q);
1725 q=PopQuantumFloatPixel(quantum_info,(
float)
1726 GetPixelAlpha(image,p),q);
1727 p+=(ptrdiff_t) GetPixelChannels(image);
1728 q+=(ptrdiff_t) quantum_info->pad;
1732 for (x=0; x < (ssize_t) number_pixels; x++)
1734 pixel=ScaleQuantumToLong(GetPixelRed(image,p));
1735 q=PopLongPixel(quantum_info->endian,pixel,q);
1736 pixel=ScaleQuantumToLong(GetPixelGreen(image,p));
1737 q=PopLongPixel(quantum_info->endian,pixel,q);
1738 pixel=ScaleQuantumToLong(GetPixelBlue(image,p));
1739 q=PopLongPixel(quantum_info->endian,pixel,q);
1740 pixel=ScaleQuantumToLong(GetPixelBlack(image,p));
1741 q=PopLongPixel(quantum_info->endian,pixel,q);
1742 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p));
1743 q=PopLongPixel(quantum_info->endian,pixel,q);
1744 p+=(ptrdiff_t) GetPixelChannels(image);
1745 q+=(ptrdiff_t) quantum_info->pad;
1751 if (quantum_info->format == FloatingPointQuantumFormat)
1753 for (x=0; x < (ssize_t) number_pixels; x++)
1755 q=PopQuantumDoublePixel(quantum_info,(
double)
1756 GetPixelRed(image,p),q);
1757 q=PopQuantumDoublePixel(quantum_info,(
double)
1758 GetPixelGreen(image,p),q);
1759 q=PopQuantumDoublePixel(quantum_info,(
double)
1760 GetPixelBlue(image,p),q);
1761 q=PopQuantumDoublePixel(quantum_info,(
double)
1762 GetPixelBlack(image,p),q);
1763 q=PopQuantumDoublePixel(quantum_info,(
double)
1764 GetPixelAlpha(image,p),q);
1765 p+=(ptrdiff_t) GetPixelChannels(image);
1766 q+=(ptrdiff_t) quantum_info->pad;
1777 range=GetQuantumRange(quantum_info->depth);
1778 for (x=0; x < (ssize_t) number_pixels; x++)
1780 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p),
1782 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p),
1784 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p),
1786 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlack(image,p),
1788 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p),
1790 p+=(ptrdiff_t) GetPixelChannels(image);
1791 q+=(ptrdiff_t) quantum_info->pad;
1798static void ExportCMYKOQuantum(
const Image *image,
QuantumInfo *quantum_info,
1799 const MagickSizeType number_pixels,
const Quantum *magick_restrict p,
1806 assert(exception->signature == MagickCoreSignature);
1807 if (image->colorspace != CMYKColorspace)
1809 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1810 "ColorSeparatedImageRequired",
"`%s'",image->filename);
1813 switch (quantum_info->depth)
1820 for (x=0; x < (ssize_t) number_pixels; x++)
1822 pixel=ScaleQuantumToChar(GetPixelRed(image,p));
1823 q=PopCharPixel(pixel,q);
1824 pixel=ScaleQuantumToChar(GetPixelGreen(image,p));
1825 q=PopCharPixel(pixel,q);
1826 pixel=ScaleQuantumToChar(GetPixelBlue(image,p));
1827 q=PopCharPixel(pixel,q);
1828 pixel=ScaleQuantumToChar(GetPixelBlack(image,p));
1829 q=PopCharPixel(pixel,q);
1830 pixel=ScaleQuantumToChar(GetPixelOpacity(image,p));
1831 q=PopCharPixel(pixel,q);
1832 p+=(ptrdiff_t) GetPixelChannels(image);
1833 q+=(ptrdiff_t) quantum_info->pad;
1842 if (quantum_info->format == FloatingPointQuantumFormat)
1844 for (x=0; x < (ssize_t) number_pixels; x++)
1846 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
1847 GetPixelRed(image,p));
1848 q=PopShortPixel(quantum_info->endian,pixel,q);
1849 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
1850 GetPixelGreen(image,p));
1851 q=PopShortPixel(quantum_info->endian,pixel,q);
1852 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
1853 GetPixelBlue(image,p));
1854 q=PopShortPixel(quantum_info->endian,pixel,q);
1855 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
1856 GetPixelBlack(image,p));
1857 q=PopShortPixel(quantum_info->endian,pixel,q);
1858 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
1859 GetPixelOpacity(image,p));
1860 q=PopShortPixel(quantum_info->endian,pixel,q);
1861 p+=(ptrdiff_t) GetPixelChannels(image);
1862 q+=(ptrdiff_t) quantum_info->pad;
1866 for (x=0; x < (ssize_t) number_pixels; x++)
1868 pixel=ScaleQuantumToShort(GetPixelRed(image,p));
1869 q=PopShortPixel(quantum_info->endian,pixel,q);
1870 pixel=ScaleQuantumToShort(GetPixelGreen(image,p));
1871 q=PopShortPixel(quantum_info->endian,pixel,q);
1872 pixel=ScaleQuantumToShort(GetPixelBlue(image,p));
1873 q=PopShortPixel(quantum_info->endian,pixel,q);
1874 pixel=ScaleQuantumToShort(GetPixelBlack(image,p));
1875 q=PopShortPixel(quantum_info->endian,pixel,q);
1876 pixel=ScaleQuantumToShort(GetPixelOpacity(image,p));
1877 q=PopShortPixel(quantum_info->endian,pixel,q);
1878 p+=(ptrdiff_t) GetPixelChannels(image);
1879 q+=(ptrdiff_t) quantum_info->pad;
1888 if (quantum_info->format == FloatingPointQuantumFormat)
1890 for (x=0; x < (ssize_t) number_pixels; x++)
1895 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelRed(image,p),q);
1896 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelGreen(image,p),q);
1897 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelBlue(image,p),q);
1898 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelBlack(image,p),q);
1899 float_pixel=(float) (GetPixelOpacity(image,p));
1900 q=PopQuantumFloatPixel(quantum_info,float_pixel,q);
1901 p+=(ptrdiff_t) GetPixelChannels(image);
1902 q+=(ptrdiff_t) quantum_info->pad;
1906 for (x=0; x < (ssize_t) number_pixels; x++)
1908 pixel=ScaleQuantumToLong(GetPixelRed(image,p));
1909 q=PopLongPixel(quantum_info->endian,pixel,q);
1910 pixel=ScaleQuantumToLong(GetPixelGreen(image,p));
1911 q=PopLongPixel(quantum_info->endian,pixel,q);
1912 pixel=ScaleQuantumToLong(GetPixelBlue(image,p));
1913 q=PopLongPixel(quantum_info->endian,pixel,q);
1914 pixel=ScaleQuantumToLong(GetPixelBlack(image,p));
1915 q=PopLongPixel(quantum_info->endian,pixel,q);
1916 pixel=ScaleQuantumToLong(GetPixelOpacity(image,p));
1917 q=PopLongPixel(quantum_info->endian,pixel,q);
1918 p+=(ptrdiff_t) GetPixelChannels(image);
1919 q+=(ptrdiff_t) quantum_info->pad;
1925 if (quantum_info->format == FloatingPointQuantumFormat)
1930 for (x=0; x < (ssize_t) number_pixels; x++)
1932 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelRed(image,p),q);
1933 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelGreen(image,p),q);
1934 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelBlue(image,p),q);
1935 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelBlack(image,p),q);
1936 pixel=(double) (GetPixelOpacity(image,p));
1937 q=PopQuantumDoublePixel(quantum_info,pixel,q);
1938 p+=(ptrdiff_t) GetPixelChannels(image);
1939 q+=(ptrdiff_t) quantum_info->pad;
1950 range=GetQuantumRange(quantum_info->depth);
1951 for (x=0; x < (ssize_t) number_pixels; x++)
1953 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p),
1955 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p),
1957 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p),
1959 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlack(image,p),
1961 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelOpacity(image,p),
1963 p+=(ptrdiff_t) GetPixelChannels(image);
1964 q+=(ptrdiff_t) quantum_info->pad;
1972 const MagickSizeType number_pixels,
const Quantum *magick_restrict p,
1973 unsigned char *magick_restrict q)
1981 switch (quantum_info->depth)
1997 if (quantum_info->min_is_white != MagickFalse)
2002 threshold=(double) QuantumRange/2.0;
2003 for (x=((ssize_t) number_pixels-7); x > 0; x-=8)
2006 *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 7;
2007 p+=(ptrdiff_t) GetPixelChannels(image);
2008 *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 6;
2009 p+=(ptrdiff_t) GetPixelChannels(image);
2010 *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 5;
2011 p+=(ptrdiff_t) GetPixelChannels(image);
2012 *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 4;
2013 p+=(ptrdiff_t) GetPixelChannels(image);
2014 *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 3;
2015 p+=(ptrdiff_t) GetPixelChannels(image);
2016 *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 2;
2017 p+=(ptrdiff_t) GetPixelChannels(image);
2018 *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 1;
2019 p+=(ptrdiff_t) GetPixelChannels(image);
2020 *q|=(GetPixelLuma(image,p) < threshold ? black : white) << 0;
2021 p+=(ptrdiff_t) GetPixelChannels(image);
2024 if ((number_pixels % 8) != 0)
2027 for (bit=7; bit >= (ssize_t) (8-(number_pixels % 8)); bit--)
2029 *q|=(GetPixelLuma(image,p) < threshold ? black : white) << bit;
2030 p+=(ptrdiff_t) GetPixelChannels(image);
2041 for (x=0; x < (ssize_t) (number_pixels-1) ; x+=2)
2043 pixel=ScaleQuantumToChar(ClampToQuantum(GetPixelLuma(image,p)));
2044 *q=(((pixel >> 4) & 0xf) << 4);
2045 p+=(ptrdiff_t) GetPixelChannels(image);
2046 pixel=ScaleQuantumToChar(ClampToQuantum(GetPixelLuma(image,p)));
2048 p+=(ptrdiff_t) GetPixelChannels(image);
2051 if ((number_pixels % 2) != 0)
2053 pixel=ScaleQuantumToChar(ClampToQuantum(GetPixelLuma(image,p)));
2054 *q=(((pixel >> 4) & 0xf) << 4);
2055 p+=(ptrdiff_t) GetPixelChannels(image);
2065 for (x=0; x < (ssize_t) number_pixels; x++)
2067 pixel=ScaleQuantumToChar(ClampToQuantum(GetPixelLuma(image,p)));
2068 q=PopCharPixel(pixel,q);
2069 p+=(ptrdiff_t) GetPixelChannels(image);
2070 q+=(ptrdiff_t) quantum_info->pad;
2076 range=GetQuantumRange(quantum_info->depth);
2077 if (quantum_info->pack == MagickFalse)
2082 for (x=0; x < (ssize_t) (number_pixels-2); x+=3)
2084 pixel=(
unsigned int) (ScaleQuantumToAny(ClampToQuantum(
2085 GetPixelLuma(image,p+2*GetPixelChannels(image))),range) << 22 |
2086 ScaleQuantumToAny(ClampToQuantum(GetPixelLuma(image,p+
2087 GetPixelChannels(image))),range) << 12 | ScaleQuantumToAny(
2088 ClampToQuantum(GetPixelLuma(image,p)),range) << 2);
2089 q=PopLongPixel(quantum_info->endian,pixel,q);
2090 p+=(ptrdiff_t) 3*GetPixelChannels(image);
2091 q+=(ptrdiff_t) quantum_info->pad;
2093 if (x < (ssize_t) number_pixels)
2096 if (x++ < (ssize_t) (number_pixels-1))
2097 pixel|=ScaleQuantumToAny(ClampToQuantum(GetPixelLuma(image,p+
2098 GetPixelChannels(image))),range) << 12;
2099 if (x++ < (ssize_t) number_pixels)
2100 pixel|=ScaleQuantumToAny(ClampToQuantum(GetPixelLuma(image,p)),
2102 q=PopLongPixel(quantum_info->endian,pixel,q);
2106 for (x=0; x < (ssize_t) number_pixels; x++)
2108 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(ClampToQuantum(
2109 GetPixelLuma(image,p)),range),q);
2110 p+=(ptrdiff_t) GetPixelChannels(image);
2111 q+=(ptrdiff_t) quantum_info->pad;
2120 range=GetQuantumRange(quantum_info->depth);
2121 if (quantum_info->pack == MagickFalse)
2123 for (x=0; x < (ssize_t) number_pixels; x++)
2125 pixel=ScaleQuantumToShort(ClampToQuantum(GetPixelLuma(image,p)));
2126 q=PopShortPixel(quantum_info->endian,(
unsigned short) (pixel >> 4),
2128 p+=(ptrdiff_t) GetPixelChannels(image);
2129 q+=(ptrdiff_t) quantum_info->pad;
2133 for (x=0; x < (ssize_t) number_pixels; x++)
2135 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(ClampToQuantum(
2136 GetPixelLuma(image,p)),range),q);
2137 p+=(ptrdiff_t) GetPixelChannels(image);
2138 q+=(ptrdiff_t) quantum_info->pad;
2147 if (quantum_info->format == FloatingPointQuantumFormat)
2149 for (x=0; x < (ssize_t) number_pixels; x++)
2151 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
2152 GetPixelLuma(image,p));
2153 q=PopShortPixel(quantum_info->endian,pixel,q);
2154 p+=(ptrdiff_t) GetPixelChannels(image);
2155 q+=(ptrdiff_t) quantum_info->pad;
2159 for (x=0; x < (ssize_t) number_pixels; x++)
2161 pixel=ScaleQuantumToShort(ClampToQuantum(GetPixelLuma(image,p)));
2162 q=PopShortPixel(quantum_info->endian,pixel,q);
2163 p+=(ptrdiff_t) GetPixelChannels(image);
2164 q+=(ptrdiff_t) quantum_info->pad;
2173 if (quantum_info->format == FloatingPointQuantumFormat)
2175 for (x=0; x < (ssize_t) number_pixels; x++)
2180 float_pixel=(float) GetPixelLuma(image,p);
2181 q=PopQuantumFloatPixel(quantum_info,float_pixel,q);
2182 p+=(ptrdiff_t) GetPixelChannels(image);
2183 q+=(ptrdiff_t) quantum_info->pad;
2187 for (x=0; x < (ssize_t) number_pixels; x++)
2189 pixel=ScaleQuantumToLong(ClampToQuantum(GetPixelLuma(image,p)));
2190 q=PopLongPixel(quantum_info->endian,pixel,q);
2191 p+=(ptrdiff_t) GetPixelChannels(image);
2192 q+=(ptrdiff_t) quantum_info->pad;
2198 if (quantum_info->format == FloatingPointQuantumFormat)
2200 for (x=0; x < (ssize_t) number_pixels; x++)
2205 pixel=GetPixelLuma(image,p);
2206 q=PopQuantumDoublePixel(quantum_info,pixel,q);
2207 p+=(ptrdiff_t) GetPixelChannels(image);
2208 q+=(ptrdiff_t) quantum_info->pad;
2216 range=GetQuantumRange(quantum_info->depth);
2217 for (x=0; x < (ssize_t) number_pixels; x++)
2219 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(ClampToQuantum(
2220 GetPixelLuma(image,p)),range),q);
2221 p+=(ptrdiff_t) GetPixelChannels(image);
2222 q+=(ptrdiff_t) quantum_info->pad;
2229static void ExportGrayAlphaQuantum(
const Image *image,
QuantumInfo *quantum_info,
2230 const MagickSizeType number_pixels,
const Quantum *magick_restrict p,
2231 unsigned char *magick_restrict q)
2239 switch (quantum_info->depth)
2256 if (quantum_info->min_is_white != MagickFalse)
2261 threshold=(double) QuantumRange/2.0;
2262 for (x=((ssize_t) number_pixels-3); x > 0; x-=4)
2265 *q|=(GetPixelLuma(image,p) > threshold ? black : white) << 7;
2266 pixel=(
unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ?
2268 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 6);
2269 p+=(ptrdiff_t) GetPixelChannels(image);
2270 *q|=(GetPixelLuma(image,p) > threshold ? black : white) << 5;
2271 pixel=(
unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ?
2273 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 4);
2274 p+=(ptrdiff_t) GetPixelChannels(image);
2275 *q|=(GetPixelLuma(image,p) > threshold ? black : white) << 3;
2276 pixel=(
unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ?
2278 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 2);
2279 p+=(ptrdiff_t) GetPixelChannels(image);
2280 *q|=(GetPixelLuma(image,p) > threshold ? black : white) << 1;
2281 pixel=(
unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ?
2283 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 0);
2284 p+=(ptrdiff_t) GetPixelChannels(image);
2287 if ((number_pixels % 4) != 0)
2290 for (bit=0; bit <= (ssize_t) (number_pixels % 4); bit+=2)
2292 *q|=(GetPixelLuma(image,p) > threshold ? black : white) <<
2294 pixel=(
unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ?
2296 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << (
unsigned char)
2298 p+=(ptrdiff_t) GetPixelChannels(image);
2309 for (x=0; x < (ssize_t) number_pixels ; x++)
2311 pixel=ScaleQuantumToChar(ClampToQuantum(GetPixelLuma(image,p)));
2312 *q=(((pixel >> 4) & 0xf) << 4);
2313 pixel=(
unsigned char) (16.0*QuantumScale*(
double)
2314 GetPixelAlpha(image,p)+0.5);
2316 p+=(ptrdiff_t) GetPixelChannels(image);
2326 for (x=0; x < (ssize_t) number_pixels; x++)
2328 pixel=ScaleQuantumToChar(ClampToQuantum(GetPixelLuma(image,p)));
2329 q=PopCharPixel(pixel,q);
2330 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p));
2331 q=PopCharPixel(pixel,q);
2332 p+=(ptrdiff_t) GetPixelChannels(image);
2333 q+=(ptrdiff_t) quantum_info->pad;
2342 if (quantum_info->format == FloatingPointQuantumFormat)
2344 for (x=0; x < (ssize_t) number_pixels; x++)
2346 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
2347 GetPixelLuma(image,p));
2348 q=PopShortPixel(quantum_info->endian,pixel,q);
2349 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
2350 GetPixelAlpha(image,p));
2351 q=PopShortPixel(quantum_info->endian,pixel,q);
2352 p+=(ptrdiff_t) GetPixelChannels(image);
2353 q+=(ptrdiff_t) quantum_info->pad;
2357 for (x=0; x < (ssize_t) number_pixels; x++)
2359 pixel=ScaleQuantumToShort(ClampToQuantum(GetPixelLuma(image,p)));
2360 q=PopShortPixel(quantum_info->endian,pixel,q);
2361 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p));
2362 q=PopShortPixel(quantum_info->endian,pixel,q);
2363 p+=(ptrdiff_t) GetPixelChannels(image);
2364 q+=(ptrdiff_t) quantum_info->pad;
2373 if (quantum_info->format == FloatingPointQuantumFormat)
2375 for (x=0; x < (ssize_t) number_pixels; x++)
2380 float_pixel=(float) GetPixelLuma(image,p);
2381 q=PopQuantumFloatPixel(quantum_info,float_pixel,q);
2382 float_pixel=(float) (GetPixelAlpha(image,p));
2383 q=PopQuantumFloatPixel(quantum_info,float_pixel,q);
2384 p+=(ptrdiff_t) GetPixelChannels(image);
2385 q+=(ptrdiff_t) quantum_info->pad;
2389 for (x=0; x < (ssize_t) number_pixels; x++)
2391 pixel=ScaleQuantumToLong(ClampToQuantum(GetPixelLuma(image,p)));
2392 q=PopLongPixel(quantum_info->endian,pixel,q);
2393 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p));
2394 q=PopLongPixel(quantum_info->endian,pixel,q);
2395 p+=(ptrdiff_t) GetPixelChannels(image);
2396 q+=(ptrdiff_t) quantum_info->pad;
2402 if (quantum_info->format == FloatingPointQuantumFormat)
2404 for (x=0; x < (ssize_t) number_pixels; x++)
2409 pixel=GetPixelLuma(image,p);
2410 q=PopQuantumDoublePixel(quantum_info,pixel,q);
2411 pixel=(double) (GetPixelAlpha(image,p));
2412 q=PopQuantumDoublePixel(quantum_info,pixel,q);
2413 p+=(ptrdiff_t) GetPixelChannels(image);
2414 q+=(ptrdiff_t) quantum_info->pad;
2422 range=GetQuantumRange(quantum_info->depth);
2423 for (x=0; x < (ssize_t) number_pixels; x++)
2425 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(ClampToQuantum(
2426 GetPixelLuma(image,p)),range),q);
2427 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p),
2429 p+=(ptrdiff_t) GetPixelChannels(image);
2430 q+=(ptrdiff_t) quantum_info->pad;
2437static void ExportGreenQuantum(
const Image *image,
QuantumInfo *quantum_info,
2438 const MagickSizeType number_pixels,
const Quantum *magick_restrict p,
2439 unsigned char *magick_restrict q)
2447 switch (quantum_info->depth)
2454 for (x=0; x < (ssize_t) number_pixels; x++)
2456 pixel=ScaleQuantumToChar(GetPixelGreen(image,p));
2457 q=PopCharPixel(pixel,q);
2458 p+=(ptrdiff_t) GetPixelChannels(image);
2459 q+=(ptrdiff_t) quantum_info->pad;
2468 if (quantum_info->format == FloatingPointQuantumFormat)
2470 for (x=0; x < (ssize_t) number_pixels; x++)
2472 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
2473 GetPixelGreen(image,p));
2474 q=PopShortPixel(quantum_info->endian,pixel,q);
2475 p+=(ptrdiff_t) GetPixelChannels(image);
2476 q+=(ptrdiff_t) quantum_info->pad;
2480 for (x=0; x < (ssize_t) number_pixels; x++)
2482 pixel=ScaleQuantumToShort(GetPixelGreen(image,p));
2483 q=PopShortPixel(quantum_info->endian,pixel,q);
2484 p+=(ptrdiff_t) GetPixelChannels(image);
2485 q+=(ptrdiff_t) quantum_info->pad;
2494 if (quantum_info->format == FloatingPointQuantumFormat)
2496 for (x=0; x < (ssize_t) number_pixels; x++)
2498 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelGreen(image,p),q);
2499 p+=(ptrdiff_t) GetPixelChannels(image);
2500 q+=(ptrdiff_t) quantum_info->pad;
2504 for (x=0; x < (ssize_t) number_pixels; x++)
2506 pixel=ScaleQuantumToLong(GetPixelGreen(image,p));
2507 q=PopLongPixel(quantum_info->endian,pixel,q);
2508 p+=(ptrdiff_t) GetPixelChannels(image);
2509 q+=(ptrdiff_t) quantum_info->pad;
2515 if (quantum_info->format == FloatingPointQuantumFormat)
2517 for (x=0; x < (ssize_t) number_pixels; x++)
2519 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelGreen(image,p),q);
2520 p+=(ptrdiff_t) GetPixelChannels(image);
2521 q+=(ptrdiff_t) quantum_info->pad;
2529 range=GetQuantumRange(quantum_info->depth);
2530 for (x=0; x < (ssize_t) number_pixels; x++)
2532 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p),
2534 p+=(ptrdiff_t) GetPixelChannels(image);
2535 q+=(ptrdiff_t) quantum_info->pad;
2542static void ExportIndexQuantum(
const Image *image,
QuantumInfo *quantum_info,
2543 const MagickSizeType number_pixels,
const Quantum *magick_restrict p,
2552 if (image->storage_class != PseudoClass)
2554 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
2555 "ColormappedImageRequired",
"`%s'",image->filename);
2558 switch (quantum_info->depth)
2565 for (x=((ssize_t) number_pixels-7); x > 0; x-=8)
2567 pixel=(
unsigned char) ((ssize_t) GetPixelIndex(image,p));
2568 *q=((pixel & 0x01) << 7);
2569 p+=(ptrdiff_t) GetPixelChannels(image);
2570 pixel=(
unsigned char) ((ssize_t) GetPixelIndex(image,p));
2571 *q|=((pixel & 0x01) << 6);
2572 p+=(ptrdiff_t) GetPixelChannels(image);
2573 pixel=(
unsigned char) ((ssize_t) GetPixelIndex(image,p));
2574 *q|=((pixel & 0x01) << 5);
2575 p+=(ptrdiff_t) GetPixelChannels(image);
2576 pixel=(
unsigned char) ((ssize_t) GetPixelIndex(image,p));
2577 *q|=((pixel & 0x01) << 4);
2578 p+=(ptrdiff_t) GetPixelChannels(image);
2579 pixel=(
unsigned char) ((ssize_t) GetPixelIndex(image,p));
2580 *q|=((pixel & 0x01) << 3);
2581 p+=(ptrdiff_t) GetPixelChannels(image);
2582 pixel=(
unsigned char) ((ssize_t) GetPixelIndex(image,p));
2583 *q|=((pixel & 0x01) << 2);
2584 p+=(ptrdiff_t) GetPixelChannels(image);
2585 pixel=(
unsigned char) ((ssize_t) GetPixelIndex(image,p));
2586 *q|=((pixel & 0x01) << 1);
2587 p+=(ptrdiff_t) GetPixelChannels(image);
2588 pixel=(
unsigned char) ((ssize_t) GetPixelIndex(image,p));
2589 *q|=((pixel & 0x01) << 0);
2590 p+=(ptrdiff_t) GetPixelChannels(image);
2593 if ((number_pixels % 8) != 0)
2596 for (bit=7; bit >= (ssize_t) (8-(number_pixels % 8)); bit--)
2598 pixel=(
unsigned char) ((ssize_t) GetPixelIndex(image,p));
2599 *q|=((pixel & 0x01) << (
unsigned char) bit);
2600 p+=(ptrdiff_t) GetPixelChannels(image);
2611 for (x=0; x < (ssize_t) (number_pixels-1) ; x+=2)
2613 pixel=(
unsigned char) ((ssize_t) GetPixelIndex(image,p));
2614 *q=((pixel & 0xf) << 4);
2615 p+=(ptrdiff_t) GetPixelChannels(image);
2616 pixel=(
unsigned char) ((ssize_t) GetPixelIndex(image,p));
2617 *q|=((pixel & 0xf) << 0);
2618 p+=(ptrdiff_t) GetPixelChannels(image);
2621 if ((number_pixels % 2) != 0)
2623 pixel=(
unsigned char) ((ssize_t) GetPixelIndex(image,p));
2624 *q=((pixel & 0xf) << 4);
2625 p+=(ptrdiff_t) GetPixelChannels(image);
2632 for (x=0; x < (ssize_t) number_pixels; x++)
2634 q=PopCharPixel((
unsigned char) ((ssize_t) GetPixelIndex(image,p)),q);
2635 p+=(ptrdiff_t) GetPixelChannels(image);
2636 q+=(ptrdiff_t) quantum_info->pad;
2642 if (quantum_info->format == FloatingPointQuantumFormat)
2644 for (x=0; x < (ssize_t) number_pixels; x++)
2646 q=PopShortPixel(quantum_info->endian,SinglePrecisionToHalf(
2647 QuantumScale*(
double) GetPixelIndex(image,p)),q);
2648 p+=(ptrdiff_t) GetPixelChannels(image);
2649 q+=(ptrdiff_t) quantum_info->pad;
2653 for (x=0; x < (ssize_t) number_pixels; x++)
2655 q=PopShortPixel(quantum_info->endian,(
unsigned short)
2656 GetPixelIndex(image,p),q);
2657 p+=(ptrdiff_t) GetPixelChannels(image);
2658 q+=(ptrdiff_t) quantum_info->pad;
2664 if (quantum_info->format == FloatingPointQuantumFormat)
2666 for (x=0; x < (ssize_t) number_pixels; x++)
2668 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelIndex(image,p),q);
2669 p+=(ptrdiff_t) GetPixelChannels(image);
2670 q+=(ptrdiff_t) quantum_info->pad;
2674 for (x=0; x < (ssize_t) number_pixels; x++)
2676 q=PopLongPixel(quantum_info->endian,(
unsigned int)
2677 GetPixelIndex(image,p),q);
2678 p+=(ptrdiff_t) GetPixelChannels(image);
2679 q+=(ptrdiff_t) quantum_info->pad;
2685 if (quantum_info->format == FloatingPointQuantumFormat)
2687 for (x=0; x < (ssize_t) number_pixels; x++)
2689 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelIndex(image,p),q);
2690 p+=(ptrdiff_t) GetPixelChannels(image);
2691 q+=(ptrdiff_t) quantum_info->pad;
2699 for (x=0; x < (ssize_t) number_pixels; x++)
2701 q=PopQuantumPixel(quantum_info,(QuantumAny) GetPixelIndex(image,p),q);
2702 p+=(ptrdiff_t) GetPixelChannels(image);
2703 q+=(ptrdiff_t) quantum_info->pad;
2710static void ExportIndexAlphaQuantum(
const Image *image,
2711 QuantumInfo *quantum_info,
const MagickSizeType number_pixels,
2712 const Quantum *magick_restrict p,
unsigned char *magick_restrict q,
2721 if (image->storage_class != PseudoClass)
2723 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
2724 "ColormappedImageRequired",
"`%s'",image->filename);
2727 switch (quantum_info->depth)
2734 for (x=((ssize_t) number_pixels-3); x > 0; x-=4)
2736 pixel=(
unsigned char) ((ssize_t) GetPixelIndex(image,p));
2737 *q=((pixel & 0x01) << 7);
2738 pixel=(
unsigned char) (GetPixelAlpha(image,p) == (Quantum)
2739 TransparentAlpha ? 1 : 0);
2740 *q|=((pixel & 0x01) << 6);
2741 p+=(ptrdiff_t) GetPixelChannels(image);
2742 pixel=(
unsigned char) ((ssize_t) GetPixelIndex(image,p));
2743 *q|=((pixel & 0x01) << 5);
2744 pixel=(
unsigned char) (GetPixelAlpha(image,p) == (Quantum)
2745 TransparentAlpha ? 1 : 0);
2746 *q|=((pixel & 0x01) << 4);
2747 p+=(ptrdiff_t) GetPixelChannels(image);
2748 pixel=(
unsigned char) ((ssize_t) GetPixelIndex(image,p));
2749 *q|=((pixel & 0x01) << 3);
2750 pixel=(
unsigned char) (GetPixelAlpha(image,p) == (Quantum)
2751 TransparentAlpha ? 1 : 0);
2752 *q|=((pixel & 0x01) << 2);
2753 p+=(ptrdiff_t) GetPixelChannels(image);
2754 pixel=(
unsigned char) ((ssize_t) GetPixelIndex(image,p));
2755 *q|=((pixel & 0x01) << 1);
2756 pixel=(
unsigned char) (GetPixelAlpha(image,p) == (Quantum)
2757 TransparentAlpha ? 1 : 0);
2758 *q|=((pixel & 0x01) << 0);
2759 p+=(ptrdiff_t) GetPixelChannels(image);
2762 if ((number_pixels % 4) != 0)
2765 for (bit=3; bit >= (ssize_t) (4-(number_pixels % 4)); bit-=2)
2767 pixel=(
unsigned char) ((ssize_t) GetPixelIndex(image,p));
2768 *q|=((pixel & 0x01) << (
unsigned char) (bit+4));
2769 pixel=(
unsigned char) (GetPixelAlpha(image,p) == (Quantum)
2770 TransparentAlpha ? 1 : 0);
2771 *q|=((pixel & 0x01) << (
unsigned char) (bit+4-1));
2772 p+=(ptrdiff_t) GetPixelChannels(image);
2783 for (x=0; x < (ssize_t) number_pixels ; x++)
2785 pixel=(
unsigned char) ((ssize_t) GetPixelIndex(image,p));
2786 *q=((pixel & 0xf) << 4);
2787 pixel=(
unsigned char) (16.0*QuantumScale*(
double)
2788 GetPixelAlpha(image,p)+0.5);
2789 *q|=((pixel & 0xf) << 0);
2790 p+=(ptrdiff_t) GetPixelChannels(image);
2800 for (x=0; x < (ssize_t) number_pixels; x++)
2802 q=PopCharPixel((
unsigned char) ((ssize_t) GetPixelIndex(image,p)),q);
2803 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p));
2804 q=PopCharPixel(pixel,q);
2805 p+=(ptrdiff_t) GetPixelChannels(image);
2806 q+=(ptrdiff_t) quantum_info->pad;
2815 if (quantum_info->format == FloatingPointQuantumFormat)
2817 for (x=0; x < (ssize_t) number_pixels; x++)
2819 q=PopShortPixel(quantum_info->endian,(
unsigned short)
2820 ((ssize_t) GetPixelIndex(image,p)),q);
2821 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
2822 GetPixelAlpha(image,p));
2823 q=PopShortPixel(quantum_info->endian,pixel,q);
2824 p+=(ptrdiff_t) GetPixelChannels(image);
2825 q+=(ptrdiff_t) quantum_info->pad;
2829 for (x=0; x < (ssize_t) number_pixels; x++)
2831 q=PopShortPixel(quantum_info->endian,(
unsigned short)
2832 ((ssize_t) GetPixelIndex(image,p)),q);
2833 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p));
2834 q=PopShortPixel(quantum_info->endian,pixel,q);
2835 p+=(ptrdiff_t) GetPixelChannels(image);
2836 q+=(ptrdiff_t) quantum_info->pad;
2845 if (quantum_info->format == FloatingPointQuantumFormat)
2847 for (x=0; x < (ssize_t) number_pixels; x++)
2852 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelIndex(image,p),q);
2853 float_pixel=(float) GetPixelAlpha(image,p);
2854 q=PopQuantumFloatPixel(quantum_info,float_pixel,q);
2855 p+=(ptrdiff_t) GetPixelChannels(image);
2856 q+=(ptrdiff_t) quantum_info->pad;
2860 for (x=0; x < (ssize_t) number_pixels; x++)
2862 q=PopLongPixel(quantum_info->endian,(
unsigned int)
2863 GetPixelIndex(image,p),q);
2864 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p));
2865 q=PopLongPixel(quantum_info->endian,pixel,q);
2866 p+=(ptrdiff_t) GetPixelChannels(image);
2867 q+=(ptrdiff_t) quantum_info->pad;
2873 if (quantum_info->format == FloatingPointQuantumFormat)
2875 for (x=0; x < (ssize_t) number_pixels; x++)
2880 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelIndex(image,p),q);
2881 pixel=(double) GetPixelAlpha(image,p);
2882 q=PopQuantumDoublePixel(quantum_info,pixel,q);
2883 p+=(ptrdiff_t) GetPixelChannels(image);
2884 q+=(ptrdiff_t) quantum_info->pad;
2895 range=GetQuantumRange(quantum_info->depth);
2896 for (x=0; x < (ssize_t) number_pixels; x++)
2898 q=PopQuantumPixel(quantum_info,(QuantumAny) GetPixelIndex(image,p),q);
2899 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p),
2901 p+=(ptrdiff_t) GetPixelChannels(image);
2902 q+=(ptrdiff_t) quantum_info->pad;
2909static void ExportMultispectralQuantum(
const Image *image,
2910 QuantumInfo *quantum_info,
const MagickSizeType number_pixels,
2911 const Quantum *magick_restrict p,
unsigned char *magick_restrict q,
2918 if (image->number_meta_channels == 0)
2920 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
2921 "MultispectralImageRequired",
"`%s'",image->filename);
2924 switch (quantum_info->depth)
2931 for (x=0; x < (ssize_t) number_pixels; x++)
2933 for (i=0; i < (ssize_t) GetImageChannels(image); i++)
2935 pixel=ScaleQuantumToChar(p[i]);
2936 q=PopCharPixel(pixel,q);
2938 p+=(ptrdiff_t) GetPixelChannels(image);
2939 q+=(ptrdiff_t) quantum_info->pad;
2948 if (quantum_info->format == FloatingPointQuantumFormat)
2950 for (x=0; x < (ssize_t) number_pixels; x++)
2952 for (i=0; i < (ssize_t) GetImageChannels(image); i++)
2954 pixel=SinglePrecisionToHalf(QuantumScale*(
double) p[i]);
2955 q=PopShortPixel(quantum_info->endian,pixel,q);
2957 p+=(ptrdiff_t) GetPixelChannels(image);
2958 q+=(ptrdiff_t) quantum_info->pad;
2962 for (x=0; x < (ssize_t) number_pixels; x++)
2964 for (i=0; i < (ssize_t) GetImageChannels(image); i++)
2966 pixel=ScaleQuantumToShort(p[i]);
2967 q=PopShortPixel(quantum_info->endian,pixel,q);
2969 p+=(ptrdiff_t) GetPixelChannels(image);
2970 q+=(ptrdiff_t) quantum_info->pad;
2979 if (quantum_info->format == FloatingPointQuantumFormat)
2981 for (x=0; x < (ssize_t) number_pixels; x++)
2983 for (i=0; i < (ssize_t) GetImageChannels(image); i++)
2984 q=PopQuantumFloatPixel(quantum_info,(
float) p[i],q);
2985 p+=(ptrdiff_t) GetPixelChannels(image);
2986 q+=(ptrdiff_t) quantum_info->pad;
2990 for (x=0; x < (ssize_t) number_pixels; x++)
2992 for (i=0; i < (ssize_t) GetImageChannels(image); i++)
2994 pixel=ScaleQuantumToLong(p[i]);
2995 q=PopLongPixel(quantum_info->endian,pixel,q);
2997 p+=(ptrdiff_t) GetPixelChannels(image);
2998 q+=(ptrdiff_t) quantum_info->pad;
3004 if (quantum_info->format == FloatingPointQuantumFormat)
3006 for (x=0; x < (ssize_t) number_pixels; x++)
3008 for (i=0; i < (ssize_t) GetImageChannels(image); i++)
3009 q=PopQuantumDoublePixel(quantum_info,(
double) p[i],q);
3010 p+=(ptrdiff_t) GetPixelChannels(image);
3011 q+=(ptrdiff_t) quantum_info->pad;
3022 range=GetQuantumRange(quantum_info->depth);
3023 for (x=0; x < (ssize_t) number_pixels; x++)
3025 for (i=0; i < (ssize_t) GetImageChannels(image); i++)
3026 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(p[i],range),q);
3027 p+=(ptrdiff_t) GetPixelChannels(image);
3028 q+=(ptrdiff_t) quantum_info->pad;
3035static void ExportOpacityQuantum(
const Image *image,
QuantumInfo *quantum_info,
3036 const MagickSizeType number_pixels,
const Quantum *magick_restrict p,
3037 unsigned char *magick_restrict q)
3045 switch (quantum_info->depth)
3052 for (x=0; x < (ssize_t) number_pixels; x++)
3054 pixel=ScaleQuantumToChar(GetPixelOpacity(image,p));
3055 q=PopCharPixel(pixel,q);
3056 p+=(ptrdiff_t) GetPixelChannels(image);
3057 q+=(ptrdiff_t) quantum_info->pad;
3066 if (quantum_info->format == FloatingPointQuantumFormat)
3068 for (x=0; x < (ssize_t) number_pixels; x++)
3070 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
3071 GetPixelOpacity(image,p));
3072 q=PopShortPixel(quantum_info->endian,pixel,q);
3073 p+=(ptrdiff_t) GetPixelChannels(image);
3074 q+=(ptrdiff_t) quantum_info->pad;
3078 for (x=0; x < (ssize_t) number_pixels; x++)
3080 pixel=ScaleQuantumToShort(GetPixelOpacity(image,p));
3081 q=PopShortPixel(quantum_info->endian,pixel,q);
3082 p+=(ptrdiff_t) GetPixelChannels(image);
3083 q+=(ptrdiff_t) quantum_info->pad;
3092 if (quantum_info->format == FloatingPointQuantumFormat)
3094 for (x=0; x < (ssize_t) number_pixels; x++)
3096 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelOpacity(image,p),q);
3097 p+=(ptrdiff_t) GetPixelChannels(image);
3098 q+=(ptrdiff_t) quantum_info->pad;
3102 for (x=0; x < (ssize_t) number_pixels; x++)
3104 pixel=ScaleQuantumToLong(GetPixelOpacity(image,p));
3105 q=PopLongPixel(quantum_info->endian,pixel,q);
3106 p+=(ptrdiff_t) GetPixelChannels(image);
3107 q+=(ptrdiff_t) quantum_info->pad;
3113 if (quantum_info->format == FloatingPointQuantumFormat)
3115 for (x=0; x < (ssize_t) number_pixels; x++)
3117 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelOpacity(image,p),q);
3118 p+=(ptrdiff_t) GetPixelChannels(image);
3119 q+=(ptrdiff_t) quantum_info->pad;
3127 range=GetQuantumRange(quantum_info->depth);
3128 for (x=0; x < (ssize_t) number_pixels; x++)
3130 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(
3131 GetPixelOpacity(image,p),range),q);
3132 p+=(ptrdiff_t) GetPixelChannels(image);
3133 q+=(ptrdiff_t) quantum_info->pad;
3141 const MagickSizeType number_pixels,
const Quantum *magick_restrict p,
3142 unsigned char *magick_restrict q)
3150 switch (quantum_info->depth)
3157 for (x=0; x < (ssize_t) number_pixels; x++)
3159 pixel=ScaleQuantumToChar(GetPixelRed(image,p));
3160 q=PopCharPixel(pixel,q);
3161 p+=(ptrdiff_t) GetPixelChannels(image);
3162 q+=(ptrdiff_t) quantum_info->pad;
3171 if (quantum_info->format == FloatingPointQuantumFormat)
3173 for (x=0; x < (ssize_t) number_pixels; x++)
3175 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
3176 GetPixelRed(image,p));
3177 q=PopShortPixel(quantum_info->endian,pixel,q);
3178 p+=(ptrdiff_t) GetPixelChannels(image);
3179 q+=(ptrdiff_t) quantum_info->pad;
3183 for (x=0; x < (ssize_t) number_pixels; x++)
3185 pixel=ScaleQuantumToShort(GetPixelRed(image,p));
3186 q=PopShortPixel(quantum_info->endian,pixel,q);
3187 p+=(ptrdiff_t) GetPixelChannels(image);
3188 q+=(ptrdiff_t) quantum_info->pad;
3197 if (quantum_info->format == FloatingPointQuantumFormat)
3199 for (x=0; x < (ssize_t) number_pixels; x++)
3201 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelRed(image,p),q);
3202 p+=(ptrdiff_t) GetPixelChannels(image);
3203 q+=(ptrdiff_t) quantum_info->pad;
3207 for (x=0; x < (ssize_t) number_pixels; x++)
3209 pixel=ScaleQuantumToLong(GetPixelRed(image,p));
3210 q=PopLongPixel(quantum_info->endian,pixel,q);
3211 p+=(ptrdiff_t) GetPixelChannels(image);
3212 q+=(ptrdiff_t) quantum_info->pad;
3218 if (quantum_info->format == FloatingPointQuantumFormat)
3220 for (x=0; x < (ssize_t) number_pixels; x++)
3222 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelRed(image,p),q);
3223 p+=(ptrdiff_t) GetPixelChannels(image);
3224 q+=(ptrdiff_t) quantum_info->pad;
3232 range=GetQuantumRange(quantum_info->depth);
3233 for (x=0; x < (ssize_t) number_pixels; x++)
3235 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p),
3237 p+=(ptrdiff_t) GetPixelChannels(image);
3238 q+=(ptrdiff_t) quantum_info->pad;
3246 const MagickSizeType number_pixels,
const Quantum *magick_restrict p,
3247 unsigned char *magick_restrict q)
3258 switch (quantum_info->depth)
3262 for (x=0; x < (ssize_t) number_pixels; x++)
3264 q=PopCharPixel(ScaleQuantumToChar(GetPixelRed(image,p)),q);
3265 q=PopCharPixel(ScaleQuantumToChar(GetPixelGreen(image,p)),q);
3266 q=PopCharPixel(ScaleQuantumToChar(GetPixelBlue(image,p)),q);
3267 p+=(ptrdiff_t) GetPixelChannels(image);
3268 q+=(ptrdiff_t) quantum_info->pad;
3277 range=GetQuantumRange(quantum_info->depth);
3278 if (quantum_info->pack == MagickFalse)
3280 for (x=0; x < (ssize_t) number_pixels; x++)
3282 pixel=(
unsigned int) (
3283 ScaleQuantumToAny(GetPixelRed(image,p),range) << 22 |
3284 ScaleQuantumToAny(GetPixelGreen(image,p),range) << 12 |
3285 ScaleQuantumToAny(GetPixelBlue(image,p),range) << 2);
3286 q=PopLongPixel(quantum_info->endian,pixel,q);
3287 p+=(ptrdiff_t) GetPixelChannels(image);
3288 q+=(ptrdiff_t) quantum_info->pad;
3292 if (quantum_info->quantum == 32UL)
3294 for (x=0; x < (ssize_t) number_pixels; x++)
3296 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
3297 q=PopQuantumLongPixel(quantum_info,pixel,q);
3298 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
3300 q=PopQuantumLongPixel(quantum_info,pixel,q);
3301 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
3302 q=PopQuantumLongPixel(quantum_info,pixel,q);
3303 p+=(ptrdiff_t) GetPixelChannels(image);
3304 q+=(ptrdiff_t) quantum_info->pad;
3308 for (x=0; x < (ssize_t) number_pixels; x++)
3310 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
3311 q=PopQuantumPixel(quantum_info,pixel,q);
3312 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range);
3313 q=PopQuantumPixel(quantum_info,pixel,q);
3314 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
3315 q=PopQuantumPixel(quantum_info,pixel,q);
3316 p+=(ptrdiff_t) GetPixelChannels(image);
3317 q+=(ptrdiff_t) quantum_info->pad;
3326 range=GetQuantumRange(quantum_info->depth);
3327 if (quantum_info->pack == MagickFalse)
3329 for (x=0; x < (ssize_t) (3*number_pixels-1); x+=2)
3336 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),
3342 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
3348 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),
3350 p+=(ptrdiff_t) GetPixelChannels(image);
3354 q=PopShortPixel(quantum_info->endian,(
unsigned short) (pixel << 4),
3361 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),
3367 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
3373 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),
3375 p+=(ptrdiff_t) GetPixelChannels(image);
3379 q=PopShortPixel(quantum_info->endian,(
unsigned short) (pixel << 4),
3381 q+=(ptrdiff_t) quantum_info->pad;
3383 for (bit=0; bit < (ssize_t) (3*number_pixels % 2); bit++)
3385 switch ((x+bit) % 3)
3390 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),
3396 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
3402 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),
3404 p+=(ptrdiff_t) GetPixelChannels(image);
3408 q=PopShortPixel(quantum_info->endian,(
unsigned short) (pixel << 4),
3410 q+=(ptrdiff_t) quantum_info->pad;
3413 p+=(ptrdiff_t) GetPixelChannels(image);
3416 if (quantum_info->quantum == 32UL)
3418 for (x=0; x < (ssize_t) number_pixels; x++)
3420 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
3421 q=PopQuantumLongPixel(quantum_info,pixel,q);
3422 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
3424 q=PopQuantumLongPixel(quantum_info,pixel,q);
3425 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
3426 q=PopQuantumLongPixel(quantum_info,pixel,q);
3427 p+=(ptrdiff_t) GetPixelChannels(image);
3428 q+=(ptrdiff_t) quantum_info->pad;
3432 for (x=0; x < (ssize_t) number_pixels; x++)
3434 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
3435 q=PopQuantumPixel(quantum_info,pixel,q);
3436 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range);
3437 q=PopQuantumPixel(quantum_info,pixel,q);
3438 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
3439 q=PopQuantumPixel(quantum_info,pixel,q);
3440 p+=(ptrdiff_t) GetPixelChannels(image);
3441 q+=(ptrdiff_t) quantum_info->pad;
3450 if (quantum_info->format == FloatingPointQuantumFormat)
3452 for (x=0; x < (ssize_t) number_pixels; x++)
3454 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
3455 GetPixelRed(image,p));
3456 q=PopShortPixel(quantum_info->endian,pixel,q);
3457 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
3458 GetPixelGreen(image,p));
3459 q=PopShortPixel(quantum_info->endian,pixel,q);
3460 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
3461 GetPixelBlue(image,p));
3462 q=PopShortPixel(quantum_info->endian,pixel,q);
3463 p+=(ptrdiff_t) GetPixelChannels(image);
3464 q+=(ptrdiff_t) quantum_info->pad;
3468 for (x=0; x < (ssize_t) number_pixels; x++)
3470 pixel=ScaleQuantumToShort(GetPixelRed(image,p));
3471 q=PopShortPixel(quantum_info->endian,pixel,q);
3472 pixel=ScaleQuantumToShort(GetPixelGreen(image,p));
3473 q=PopShortPixel(quantum_info->endian,pixel,q);
3474 pixel=ScaleQuantumToShort(GetPixelBlue(image,p));
3475 q=PopShortPixel(quantum_info->endian,pixel,q);
3476 p+=(ptrdiff_t) GetPixelChannels(image);
3477 q+=(ptrdiff_t) quantum_info->pad;
3486 if (quantum_info->format == FloatingPointQuantumFormat)
3488 for (x=0; x < (ssize_t) number_pixels; x++)
3490 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelRed(image,p),
3492 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelGreen(image,p),
3494 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelBlue(image,p),
3496 p+=(ptrdiff_t) GetPixelChannels(image);
3497 q+=(ptrdiff_t) quantum_info->pad;
3501 for (x=0; x < (ssize_t) number_pixels; x++)
3503 pixel=ScaleQuantumToLong(GetPixelRed(image,p));
3504 q=PopLongPixel(quantum_info->endian,pixel,q);
3505 pixel=ScaleQuantumToLong(GetPixelGreen(image,p));
3506 q=PopLongPixel(quantum_info->endian,pixel,q);
3507 pixel=ScaleQuantumToLong(GetPixelBlue(image,p));
3508 q=PopLongPixel(quantum_info->endian,pixel,q);
3509 p+=(ptrdiff_t) GetPixelChannels(image);
3510 q+=(ptrdiff_t) quantum_info->pad;
3516 if (quantum_info->format == FloatingPointQuantumFormat)
3518 for (x=0; x < (ssize_t) number_pixels; x++)
3520 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelRed(image,p),q);
3521 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelGreen(image,p),q);
3522 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelBlue(image,p),q);
3523 p+=(ptrdiff_t) GetPixelChannels(image);
3524 q+=(ptrdiff_t) quantum_info->pad;
3532 range=GetQuantumRange(quantum_info->depth);
3533 for (x=0; x < (ssize_t) number_pixels; x++)
3535 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p),
3537 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p),
3539 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p),
3541 p+=(ptrdiff_t) GetPixelChannels(image);
3542 q+=(ptrdiff_t) quantum_info->pad;
3550 const MagickSizeType number_pixels,
const Quantum *magick_restrict p,
3551 unsigned char *magick_restrict q)
3559 switch (quantum_info->depth)
3566 for (x=0; x < (ssize_t) number_pixels; x++)
3568 pixel=ScaleQuantumToChar(GetPixelRed(image,p));
3569 q=PopCharPixel(pixel,q);
3570 pixel=ScaleQuantumToChar(GetPixelGreen(image,p));
3571 q=PopCharPixel(pixel,q);
3572 pixel=ScaleQuantumToChar(GetPixelBlue(image,p));
3573 q=PopCharPixel(pixel,q);
3574 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p));
3575 q=PopCharPixel(pixel,q);
3576 p+=(ptrdiff_t) GetPixelChannels(image);
3577 q+=(ptrdiff_t) quantum_info->pad;
3586 range=GetQuantumRange(quantum_info->depth);
3587 if (quantum_info->pack == MagickFalse)
3601 for (x=0; x < (ssize_t) number_pixels; x++)
3603 for (i=0; i < 4; i++)
3607 case 0: quantum=(size_t) GetPixelRed(image,p);
break;
3608 case 1: quantum=(size_t) GetPixelGreen(image,p);
break;
3609 case 2: quantum=(size_t) GetPixelBlue(image,p);
break;
3610 case 3: quantum=(size_t) GetPixelAlpha(image,p);
break;
3616 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum,
3622 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum,
3628 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum,
3630 q=PopLongPixel(quantum_info->endian,pixel,q);
3637 p+=(ptrdiff_t) GetPixelChannels(image);
3638 q+=(ptrdiff_t) quantum_info->pad;
3642 if (quantum_info->quantum == 32UL)
3644 for (x=0; x < (ssize_t) number_pixels; x++)
3646 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
3647 q=PopQuantumLongPixel(quantum_info,pixel,q);
3648 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
3650 q=PopQuantumLongPixel(quantum_info,pixel,q);
3651 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
3652 q=PopQuantumLongPixel(quantum_info,pixel,q);
3653 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelAlpha(image,p),
3655 q=PopQuantumLongPixel(quantum_info,pixel,q);
3656 p+=(ptrdiff_t) GetPixelChannels(image);
3657 q+=(ptrdiff_t) quantum_info->pad;
3661 for (x=0; x < (ssize_t) number_pixels; x++)
3663 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
3664 q=PopQuantumPixel(quantum_info,pixel,q);
3665 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range);
3666 q=PopQuantumPixel(quantum_info,pixel,q);
3667 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
3668 q=PopQuantumPixel(quantum_info,pixel,q);
3669 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelAlpha(image,p),range);
3670 q=PopQuantumPixel(quantum_info,pixel,q);
3671 p+=(ptrdiff_t) GetPixelChannels(image);
3672 q+=(ptrdiff_t) quantum_info->pad;
3681 if (quantum_info->format == FloatingPointQuantumFormat)
3683 for (x=0; x < (ssize_t) number_pixels; x++)
3685 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
3686 GetPixelRed(image,p));
3687 q=PopShortPixel(quantum_info->endian,pixel,q);
3688 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
3689 GetPixelGreen(image,p));
3690 q=PopShortPixel(quantum_info->endian,pixel,q);
3691 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
3692 GetPixelBlue(image,p));
3693 q=PopShortPixel(quantum_info->endian,pixel,q);
3694 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
3695 GetPixelAlpha(image,p));
3696 q=PopShortPixel(quantum_info->endian,pixel,q);
3697 p+=(ptrdiff_t) GetPixelChannels(image);
3698 q+=(ptrdiff_t) quantum_info->pad;
3702 for (x=0; x < (ssize_t) number_pixels; x++)
3704 pixel=ScaleQuantumToShort(GetPixelRed(image,p));
3705 q=PopShortPixel(quantum_info->endian,pixel,q);
3706 pixel=ScaleQuantumToShort(GetPixelGreen(image,p));
3707 q=PopShortPixel(quantum_info->endian,pixel,q);
3708 pixel=ScaleQuantumToShort(GetPixelBlue(image,p));
3709 q=PopShortPixel(quantum_info->endian,pixel,q);
3710 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p));
3711 q=PopShortPixel(quantum_info->endian,pixel,q);
3712 p+=(ptrdiff_t) GetPixelChannels(image);
3713 q+=(ptrdiff_t) quantum_info->pad;
3722 if (quantum_info->format == FloatingPointQuantumFormat)
3724 for (x=0; x < (ssize_t) number_pixels; x++)
3729 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelRed(image,p),q);
3730 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelGreen(image,p),q);
3731 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelBlue(image,p),q);
3732 float_pixel=(float) GetPixelAlpha(image,p);
3733 q=PopQuantumFloatPixel(quantum_info,float_pixel,q);
3734 p+=(ptrdiff_t) GetPixelChannels(image);
3735 q+=(ptrdiff_t) quantum_info->pad;
3739 for (x=0; x < (ssize_t) number_pixels; x++)
3741 pixel=ScaleQuantumToLong(GetPixelRed(image,p));
3742 q=PopLongPixel(quantum_info->endian,pixel,q);
3743 pixel=ScaleQuantumToLong(GetPixelGreen(image,p));
3744 q=PopLongPixel(quantum_info->endian,pixel,q);
3745 pixel=ScaleQuantumToLong(GetPixelBlue(image,p));
3746 q=PopLongPixel(quantum_info->endian,pixel,q);
3747 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p));
3748 q=PopLongPixel(quantum_info->endian,pixel,q);
3749 p+=(ptrdiff_t) GetPixelChannels(image);
3750 q+=(ptrdiff_t) quantum_info->pad;
3756 if (quantum_info->format == FloatingPointQuantumFormat)
3761 for (x=0; x < (ssize_t) number_pixels; x++)
3763 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelRed(image,p),q);
3764 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelGreen(image,p),q);
3765 q=PopQuantumDoublePixel(quantum_info,(
double) GetPixelBlue(image,p),q);
3766 pixel=(double) GetPixelAlpha(image,p);
3767 q=PopQuantumDoublePixel(quantum_info,pixel,q);
3768 p+=(ptrdiff_t) GetPixelChannels(image);
3769 q+=(ptrdiff_t) quantum_info->pad;
3777 range=GetQuantumRange(quantum_info->depth);
3778 for (x=0; x < (ssize_t) number_pixels; x++)
3780 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p),
3782 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p),
3784 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p),
3786 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelAlpha(image,p),
3788 p+=(ptrdiff_t) GetPixelChannels(image);
3789 q+=(ptrdiff_t) quantum_info->pad;
3797 const MagickSizeType number_pixels,
const Quantum *magick_restrict p,
3798 unsigned char *magick_restrict q)
3806 switch (quantum_info->depth)
3813 for (x=0; x < (ssize_t) number_pixels; x++)
3815 pixel=ScaleQuantumToChar(GetPixelRed(image,p));
3816 q=PopCharPixel(pixel,q);
3817 pixel=ScaleQuantumToChar(GetPixelGreen(image,p));
3818 q=PopCharPixel(pixel,q);
3819 pixel=ScaleQuantumToChar(GetPixelBlue(image,p));
3820 q=PopCharPixel(pixel,q);
3821 pixel=ScaleQuantumToChar(GetPixelOpacity(image,p));
3822 q=PopCharPixel(pixel,q);
3823 p+=(ptrdiff_t) GetPixelChannels(image);
3824 q+=(ptrdiff_t) quantum_info->pad;
3833 range=GetQuantumRange(quantum_info->depth);
3834 if (quantum_info->pack == MagickFalse)
3848 for (x=0; x < (ssize_t) number_pixels; x++)
3850 for (i=0; i < 4; i++)
3854 case 0: quantum=(size_t) GetPixelRed(image,p);
break;
3855 case 1: quantum=(size_t) GetPixelGreen(image,p);
break;
3856 case 2: quantum=(size_t) GetPixelBlue(image,p);
break;
3857 case 3: quantum=(size_t) GetPixelOpacity(image,p);
break;
3863 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum,
3869 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum,
3875 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum,
3877 q=PopLongPixel(quantum_info->endian,pixel,q);
3884 p+=(ptrdiff_t) GetPixelChannels(image);
3885 q+=(ptrdiff_t) quantum_info->pad;
3889 if (quantum_info->quantum == 32UL)
3891 for (x=0; x < (ssize_t) number_pixels; x++)
3893 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
3894 q=PopQuantumLongPixel(quantum_info,pixel,q);
3895 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
3897 q=PopQuantumLongPixel(quantum_info,pixel,q);
3898 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
3899 q=PopQuantumLongPixel(quantum_info,pixel,q);
3900 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelOpacity(image,p),
3902 q=PopQuantumLongPixel(quantum_info,pixel,q);
3903 p+=(ptrdiff_t) GetPixelChannels(image);
3904 q+=(ptrdiff_t) quantum_info->pad;
3908 for (x=0; x < (ssize_t) number_pixels; x++)
3910 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),range);
3911 q=PopQuantumPixel(quantum_info,pixel,q);
3912 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),range);
3913 q=PopQuantumPixel(quantum_info,pixel,q);
3914 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),range);
3915 q=PopQuantumPixel(quantum_info,pixel,q);
3916 pixel=(
unsigned int) ScaleQuantumToAny(GetPixelOpacity(image,p),range);
3917 q=PopQuantumPixel(quantum_info,pixel,q);
3918 p+=(ptrdiff_t) GetPixelChannels(image);
3919 q+=(ptrdiff_t) quantum_info->pad;
3928 if (quantum_info->format == FloatingPointQuantumFormat)
3930 for (x=0; x < (ssize_t) number_pixels; x++)
3932 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
3933 GetPixelRed(image,p));
3934 q=PopShortPixel(quantum_info->endian,pixel,q);
3935 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
3936 GetPixelGreen(image,p));
3937 q=PopShortPixel(quantum_info->endian,pixel,q);
3938 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
3939 GetPixelBlue(image,p));
3940 q=PopShortPixel(quantum_info->endian,pixel,q);
3941 pixel=SinglePrecisionToHalf(QuantumScale*(
double)
3942 GetPixelOpacity(image,p));
3943 q=PopShortPixel(quantum_info->endian,pixel,q);
3944 p+=(ptrdiff_t) GetPixelChannels(image);
3945 q+=(ptrdiff_t) quantum_info->pad;
3949 for (x=0; x < (ssize_t) number_pixels; x++)
3951 pixel=ScaleQuantumToShort(GetPixelRed(image,p));
3952 q=PopShortPixel(quantum_info->endian,pixel,q);
3953 pixel=ScaleQuantumToShort(GetPixelGreen(image,p));
3954 q=PopShortPixel(quantum_info->endian,pixel,q);
3955 pixel=ScaleQuantumToShort(GetPixelBlue(image,p));
3956 q=PopShortPixel(quantum_info->endian,pixel,q);
3957 pixel=ScaleQuantumToShort(GetPixelOpacity(image,p));
3958 q=PopShortPixel(quantum_info->endian,pixel,q);
3959 p+=(ptrdiff_t) GetPixelChannels(image);
3960 q+=(ptrdiff_t) quantum_info->pad;
3969 if (quantum_info->format == FloatingPointQuantumFormat)
3971 for (x=0; x < (ssize_t) number_pixels; x++)
3976 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelRed(image,p),
3978 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelGreen(image,p),
3980 q=PopQuantumFloatPixel(quantum_info,(
float) GetPixelBlue(image,p),
3982 float_pixel=(float) GetPixelOpacity(image,p);
3983 q=PopQuantumFloatPixel(quantum_info,float_pixel,q);
3984 p+=(ptrdiff_t) GetPixelChannels(image);
3985 q+=(ptrdiff_t) quantum_info->pad;
3989 for (x=0; x < (ssize_t) number_pixels; x++)
3991 pixel=ScaleQuantumToLong(GetPixelRed(image,p));
3992 q=PopLongPixel(quantum_info->endian,pixel,q);
3993 pixel=ScaleQuantumToLong(GetPixelGreen(image,p));
3994 q=PopLongPixel(quantum_info->endian,pixel,q);
3995 pixel=ScaleQuantumToLong(GetPixelBlue(image,p));
3996 q=PopLongPixel(quantum_info->endian,pixel,q);
3997 pixel=ScaleQuantumToLong(GetPixelOpacity(image,p));
3998 q=PopLongPixel(quantum_info->endian,pixel,q);
3999 p+=(ptrdiff_t) GetPixelChannels(image);
4000 q+=(ptrdiff_t) quantum_info->pad;
4006 if (quantum_info->format == FloatingPointQuantumFormat)
4011 for (x=0; x < (ssize_t) number_pixels; x++)
4013 q=PopQuantumDoublePixel(quantum_info,(
double)
4014 GetPixelRed(image,p),q);
4015 q=PopQuantumDoublePixel(quantum_info,(
double)
4016 GetPixelGreen(image,p),q);
4017 q=PopQuantumDoublePixel(quantum_info,(
double)
4018 GetPixelBlue(image,p),q);
4019 pixel=(double) GetPixelOpacity(image,p);
4020 q=PopQuantumDoublePixel(quantum_info,pixel,q);
4021 p+=(ptrdiff_t) GetPixelChannels(image);
4022 q+=(ptrdiff_t) quantum_info->pad;
4030 range=GetQuantumRange(quantum_info->depth);
4031 for (x=0; x < (ssize_t) number_pixels; x++)
4033 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelRed(image,p),
4035 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelGreen(image,p),
4037 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelBlue(image,p),
4039 q=PopQuantumPixel(quantum_info,ScaleQuantumToAny(GetPixelOpacity(image,p),
4041 p+=(ptrdiff_t) GetPixelChannels(image);
4042 q+=(ptrdiff_t) quantum_info->pad;
4049MagickExport
size_t ExportQuantumPixels(
const Image *image,
4051 const QuantumType quantum_type,
unsigned char *magick_restrict pixels,
4069 assert(image != (
Image *) NULL);
4070 assert(image->signature == MagickCoreSignature);
4072 assert(quantum_info->signature == MagickCoreSignature);
4073 if (IsEventLogging() != MagickFalse)
4074 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
4075 if (pixels == (
unsigned char *) NULL)
4076 pixels=(
unsigned char *) GetQuantumPixels(quantum_info);
4079 number_pixels=GetImageExtent(image);
4080 p=GetVirtualPixelQueue(image);
4084 number_pixels=GetCacheViewExtent(image_view);
4085 p=GetCacheViewVirtualPixelQueue(image_view);
4087 if (quantum_info->alpha_type == AssociatedQuantumAlpha)
4099 r=GetAuthenticPixelQueue(image);
4101 r=GetCacheViewAuthenticPixelQueue(image_view);
4102 for (x=0; x < (ssize_t) image->columns; x++)
4107 Sa=QuantumScale*(double) GetPixelAlpha(image,r);
4108 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
4110 PixelChannel channel = GetPixelChannelChannel(image,i);
4111 PixelTrait traits = GetPixelChannelTraits(image,channel);
4112 if ((traits & UpdatePixelTrait) == 0)
4114 r[i]=ClampToQuantum(Sa*(
double) r[i]);
4116 r+=(ptrdiff_t) GetPixelChannels(image);
4119 if ((quantum_type == CbYCrQuantum) || (quantum_type == CbYCrAQuantum))
4128 r=GetAuthenticPixelQueue(image);
4130 r=GetCacheViewAuthenticPixelQueue(image_view);
4131 for (x=0; x < (ssize_t) number_pixels; x++)
4133 quantum=GetPixelRed(image,r);
4134 SetPixelRed(image,GetPixelGreen(image,r),r);
4135 SetPixelGreen(image,quantum,r);
4136 r+=(ptrdiff_t) GetPixelChannels(image);
4140 ResetQuantumState(quantum_info);
4141 extent=GetQuantumExtent(image,quantum_info,quantum_type);
4142 switch (quantum_type)
4146 ExportAlphaQuantum(image,quantum_info,number_pixels,p,q);
4151 ExportBGRQuantum(image,quantum_info,number_pixels,p,q);
4156 ExportBGRAQuantum(image,quantum_info,number_pixels,p,q);
4161 ExportBGROQuantum(image,quantum_info,number_pixels,p,q);
4166 ExportBlackQuantum(image,quantum_info,number_pixels,p,q,exception);
4172 ExportBlueQuantum(image,quantum_info,number_pixels,p,q);
4177 ExportCMYKQuantum(image,quantum_info,number_pixels,p,q,exception);
4182 ExportCMYKAQuantum(image,quantum_info,number_pixels,p,q,exception);
4185 case MultispectralQuantum:
4187 ExportMultispectralQuantum(image,quantum_info,number_pixels,p,q,exception);
4192 ExportCMYKOQuantum(image,quantum_info,number_pixels,p,q,exception);
4197 ExportCbYCrYQuantum(image,quantum_info,number_pixels,p,q);
4202 ExportGrayQuantum(image,quantum_info,number_pixels,p,q);
4205 case GrayAlphaQuantum:
4207 ExportGrayAlphaQuantum(image,quantum_info,number_pixels,p,q);
4211 case MagentaQuantum:
4213 ExportGreenQuantum(image,quantum_info,number_pixels,p,q);
4218 ExportIndexQuantum(image,quantum_info,number_pixels,p,q,exception);
4221 case IndexAlphaQuantum:
4223 ExportIndexAlphaQuantum(image,quantum_info,number_pixels,p,q,exception);
4229 ExportRedQuantum(image,quantum_info,number_pixels,p,q);
4232 case OpacityQuantum:
4234 ExportOpacityQuantum(image,quantum_info,number_pixels,p,q);
4240 ExportRGBQuantum(image,quantum_info,number_pixels,p,q);
4246 ExportRGBAQuantum(image,quantum_info,number_pixels,p,q);
4251 ExportRGBOQuantum(image,quantum_info,number_pixels,p,q);
4257 if ((quantum_type == CbYCrQuantum) || (quantum_type == CbYCrAQuantum))
4266 r=GetAuthenticPixelQueue(image);
4268 r=GetCacheViewAuthenticPixelQueue(image_view);
4269 for (x=0; x < (ssize_t) number_pixels; x++)
4271 quantum=GetPixelRed(image,r);
4272 SetPixelRed(image,GetPixelGreen(image,r),r);
4273 SetPixelGreen(image,quantum,r);
4274 r+=(ptrdiff_t) GetPixelChannels(image);