47 #include "magick/studio.h"
48 #include "magick/property.h"
49 #include "magick/blob.h"
50 #include "magick/blob-private.h"
51 #include "magick/color-private.h"
52 #include "magick/exception.h"
53 #include "magick/exception-private.h"
54 #include "magick/cache.h"
55 #include "magick/constitute.h"
56 #include "magick/delegate.h"
57 #include "magick/geometry.h"
58 #include "magick/list.h"
59 #include "magick/magick.h"
60 #include "magick/memory_.h"
61 #include "magick/monitor.h"
62 #include "magick/option.h"
63 #include "magick/pixel.h"
64 #include "magick/pixel-private.h"
65 #include "magick/quantum.h"
66 #include "magick/quantum-private.h"
67 #include "magick/resource_.h"
68 #include "magick/semaphore.h"
69 #include "magick/statistic.h"
70 #include "magick/stream.h"
71 #include "magick/string_.h"
72 #include "magick/utility.h"
113 static inline IndexPacket PushColormapIndex(
const Image *image,
114 const size_t index,MagickBooleanType *range_exception)
116 if (index < image->colors)
117 return((IndexPacket) index);
118 *range_exception=MagickTrue;
119 return((IndexPacket) 0);
122 static inline const unsigned char *PushDoublePixel(
123 const QuantumInfo *quantum_info,
const unsigned char *magick_restrict pixels,
132 if (quantum_info->endian == LSBEndian)
134 quantum[0]=(*pixels++);
135 quantum[1]=(*pixels++);
136 quantum[2]=(*pixels++);
137 quantum[3]=(*pixels++);
138 quantum[4]=(*pixels++);
139 quantum[5]=(*pixels++);
140 quantum[6]=(*pixels++);
141 quantum[7]=(*pixels++);
145 quantum[7]=(*pixels++);
146 quantum[6]=(*pixels++);
147 quantum[5]=(*pixels++);
148 quantum[4]=(*pixels++);
149 quantum[3]=(*pixels++);
150 quantum[2]=(*pixels++);
151 quantum[1]=(*pixels++);
152 quantum[0]=(*pixels++);
154 p=(
double *) quantum;
156 *pixel-=quantum_info->minimum;
157 *pixel*=quantum_info->scale;
161 static inline float ScaleFloatPixel(
const QuantumInfo *quantum_info,
162 const unsigned char *quantum)
167 pixel=(double) (*((
float *) quantum));
168 pixel-=quantum_info->minimum;
169 pixel*=quantum_info->scale;
170 if (pixel < -FLT_MAX)
177 static inline const unsigned char *PushQuantumFloatPixel(
178 const QuantumInfo *quantum_info,
const unsigned char *magick_restrict pixels,
184 if (quantum_info->endian == LSBEndian)
186 quantum[0]=(*pixels++);
187 quantum[1]=(*pixels++);
188 quantum[2]=(*pixels++);
189 quantum[3]=(*pixels++);
193 quantum[3]=(*pixels++);
194 quantum[2]=(*pixels++);
195 quantum[1]=(*pixels++);
196 quantum[0]=(*pixels++);
198 *pixel=ScaleFloatPixel(quantum_info,quantum);
202 static inline const unsigned char *PushQuantumFloat24Pixel(
203 const QuantumInfo *quantum_info,
const unsigned char *magick_restrict pixels,
209 if (quantum_info->endian == LSBEndian)
211 quantum[0]=(*pixels++);
212 quantum[1]=(*pixels++);
213 quantum[2]=(*pixels++);
217 quantum[2]=(*pixels++);
218 quantum[1]=(*pixels++);
219 quantum[0]=(*pixels++);
221 if ((quantum[0] | quantum[1] | quantum[2]) == 0U)
229 sign_bit=(quantum[2] & 0x80);
230 exponent=(quantum[2] & 0x7F);
232 exponent=exponent-63+127;
233 quantum[3]=sign_bit | (exponent >> 1);
234 quantum[2]=((exponent & 1) << 7) | ((quantum[1] & 0xFE) >> 1);
235 quantum[1]=((quantum[1] & 0x01) << 7) | ((quantum[0] & 0xFE) >> 1);
236 quantum[0]=(quantum[0] & 0x01) << 7;
238 *pixel=ScaleFloatPixel(quantum_info,quantum);
242 static inline const unsigned char *PushQuantumPixel(
QuantumInfo *quantum_info,
243 const unsigned char *magick_restrict pixels,
unsigned int *quantum)
251 *quantum=(QuantumAny) 0;
252 for (i=(ssize_t) quantum_info->depth; i > 0L; )
254 if (quantum_info->state.bits == 0UL)
256 quantum_info->state.pixel=(*pixels++);
257 quantum_info->state.bits=8UL;
259 quantum_bits=(size_t) i;
260 if (quantum_bits > quantum_info->state.bits)
261 quantum_bits=quantum_info->state.bits;
262 i-=(ssize_t) quantum_bits;
263 quantum_info->state.bits-=quantum_bits;
264 *quantum=(
unsigned int) ((*quantum << quantum_bits) |
265 ((quantum_info->state.pixel >> quantum_info->state.bits) &~ ((~0UL) <<
271 static inline const unsigned char *PushQuantumLongPixel(
272 QuantumInfo *quantum_info,
const unsigned char *magick_restrict pixels,
273 unsigned int *quantum)
282 for (i=(ssize_t) quantum_info->depth; i > 0; )
284 if (quantum_info->state.bits == 0)
286 pixels=PushLongPixel(quantum_info->endian,pixels,
287 &quantum_info->state.pixel);
288 quantum_info->state.bits=32U;
290 quantum_bits=(size_t) i;
291 if (quantum_bits > quantum_info->state.bits)
292 quantum_bits=quantum_info->state.bits;
293 *quantum|=(((quantum_info->state.pixel >> (32U-quantum_info->state.bits)) &
294 quantum_info->state.mask[quantum_bits]) << (quantum_info->depth-i));
295 i-=(ssize_t) quantum_bits;
296 quantum_info->state.bits-=quantum_bits;
301 static void ImportAlphaQuantum(
QuantumInfo *quantum_info,
302 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
311 switch (quantum_info->depth)
318 for (x=0; x < (ssize_t) number_pixels; x++)
320 p=PushCharPixel(p,&pixel);
321 SetPixelAlpha(q,ScaleCharToQuantum(pixel));
322 p+=quantum_info->pad;
332 if (quantum_info->format == FloatingPointQuantumFormat)
334 for (x=0; x < (ssize_t) number_pixels; x++)
336 p=PushShortPixel(quantum_info->endian,p,&pixel);
337 SetPixelAlpha(q,ClampToQuantum((MagickRealType)
338 QuantumRange*HalfToSinglePrecision(pixel)));
339 p+=quantum_info->pad;
344 for (x=0; x < (ssize_t) number_pixels; x++)
346 p=PushShortPixel(quantum_info->endian,p,&pixel);
347 SetPixelAlpha(q,ScaleShortToQuantum(pixel));
348 p+=quantum_info->pad;
355 if (quantum_info->format == FloatingPointQuantumFormat)
360 for (x=0; x < (ssize_t) number_pixels; x++)
362 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
363 SetPixelAlpha(q,ClampToQuantum(pixel));
364 p+=quantum_info->pad;
369 for (x=0; x < (ssize_t) number_pixels; x++)
371 p=PushLongPixel(quantum_info->endian,p,&pixel);
372 SetPixelAlpha(q,ScaleLongToQuantum(pixel));
373 p+=quantum_info->pad;
380 if (quantum_info->format == FloatingPointQuantumFormat)
385 for (x=0; x < (ssize_t) number_pixels; x++)
387 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
388 SetPixelAlpha(q,ClampToQuantum(pixel));
389 p+=quantum_info->pad;
397 if (quantum_info->format == FloatingPointQuantumFormat)
402 for (x=0; x < (ssize_t) number_pixels; x++)
404 p=PushDoublePixel(quantum_info,p,&pixel);
405 SetPixelAlpha(q,ClampToQuantum(pixel));
406 p+=quantum_info->pad;
417 range=GetQuantumRange(quantum_info->depth);
418 for (x=0; x < (ssize_t) number_pixels; x++)
420 p=PushQuantumPixel(quantum_info,p,&pixel);
421 SetPixelAlpha(q,ScaleAnyToQuantum(pixel,range));
422 p+=quantum_info->pad;
430 static void ImportBGRQuantum(
QuantumInfo *quantum_info,
431 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
446 switch (quantum_info->depth)
453 for (x=0; x < (ssize_t) number_pixels; x++)
455 p=PushCharPixel(p,&pixel);
456 SetPixelBlue(q,ScaleCharToQuantum(pixel));
457 p=PushCharPixel(p,&pixel);
458 SetPixelGreen(q,ScaleCharToQuantum(pixel));
459 p=PushCharPixel(p,&pixel);
460 SetPixelRed(q,ScaleCharToQuantum(pixel));
461 SetPixelOpacity(q,OpaqueOpacity);
462 p+=quantum_info->pad;
469 range=GetQuantumRange(quantum_info->depth);
470 if (quantum_info->pack == MagickFalse)
472 for (x=0; x < (ssize_t) number_pixels; x++)
474 p=PushLongPixel(quantum_info->endian,p,&pixel);
475 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range));
476 SetPixelGreen(q,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range));
477 SetPixelBlue(q,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range));
478 p+=quantum_info->pad;
483 if (quantum_info->quantum == 32U)
485 for (x=0; x < (ssize_t) number_pixels; x++)
487 p=PushQuantumLongPixel(quantum_info,p,&pixel);
488 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
489 p=PushQuantumLongPixel(quantum_info,p,&pixel);
490 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
491 p=PushQuantumLongPixel(quantum_info,p,&pixel);
492 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
497 for (x=0; x < (ssize_t) number_pixels; x++)
499 p=PushQuantumPixel(quantum_info,p,&pixel);
500 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
501 p=PushQuantumPixel(quantum_info,p,&pixel);
502 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
503 p=PushQuantumPixel(quantum_info,p,&pixel);
504 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
511 range=GetQuantumRange(quantum_info->depth);
512 if (quantum_info->pack == MagickFalse)
517 for (x=0; x < (ssize_t) (3*number_pixels-1); x+=2)
519 p=PushShortPixel(quantum_info->endian,p,&pixel);
525 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
531 SetPixelGreen(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
537 SetPixelBlue(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
543 p=PushShortPixel(quantum_info->endian,p,&pixel);
549 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
555 SetPixelGreen(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
561 SetPixelBlue(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
567 p+=quantum_info->pad;
569 for (bit=0; bit < (ssize_t) (3*number_pixels % 2); bit++)
571 p=PushShortPixel(quantum_info->endian,p,&pixel);
577 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
583 SetPixelGreen(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
589 SetPixelBlue(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
595 p+=quantum_info->pad;
601 if (quantum_info->quantum == 32U)
603 for (x=0; x < (ssize_t) number_pixels; x++)
605 p=PushQuantumLongPixel(quantum_info,p,&pixel);
606 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
607 p=PushQuantumLongPixel(quantum_info,p,&pixel);
608 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
609 p=PushQuantumLongPixel(quantum_info,p,&pixel);
610 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
615 for (x=0; x < (ssize_t) number_pixels; x++)
617 p=PushQuantumPixel(quantum_info,p,&pixel);
618 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
619 p=PushQuantumPixel(quantum_info,p,&pixel);
620 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
621 p=PushQuantumPixel(quantum_info,p,&pixel);
622 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
632 if (quantum_info->format == FloatingPointQuantumFormat)
634 for (x=0; x < (ssize_t) number_pixels; x++)
636 p=PushShortPixel(quantum_info->endian,p,&pixel);
637 SetPixelRed(q,ClampToQuantum((MagickRealType) QuantumRange*
638 HalfToSinglePrecision(pixel)));
639 p=PushShortPixel(quantum_info->endian,p,&pixel);
640 SetPixelGreen(q,ClampToQuantum((MagickRealType) QuantumRange*
641 HalfToSinglePrecision(pixel)));
642 p=PushShortPixel(quantum_info->endian,p,&pixel);
643 SetPixelBlue(q,ClampToQuantum((MagickRealType) QuantumRange*
644 HalfToSinglePrecision(pixel)));
645 p+=quantum_info->pad;
650 for (x=0; x < (ssize_t) number_pixels; x++)
652 p=PushShortPixel(quantum_info->endian,p,&pixel);
653 SetPixelBlue(q,ScaleShortToQuantum(pixel));
654 p=PushShortPixel(quantum_info->endian,p,&pixel);
655 SetPixelGreen(q,ScaleShortToQuantum(pixel));
656 p=PushShortPixel(quantum_info->endian,p,&pixel);
657 SetPixelRed(q,ScaleShortToQuantum(pixel));
658 p+=quantum_info->pad;
665 if (quantum_info->format == FloatingPointQuantumFormat)
670 for (x=0; x < (ssize_t) number_pixels; x++)
672 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
673 SetPixelRed(q,ClampToQuantum(pixel));
674 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
675 SetPixelGreen(q,ClampToQuantum(pixel));
676 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
677 SetPixelBlue(q,ClampToQuantum(pixel));
678 p+=quantum_info->pad;
683 for (x=0; x < (ssize_t) number_pixels; x++)
685 p=PushLongPixel(quantum_info->endian,p,&pixel);
686 SetPixelBlue(q,ScaleLongToQuantum(pixel));
687 p=PushLongPixel(quantum_info->endian,p,&pixel);
688 SetPixelGreen(q,ScaleLongToQuantum(pixel));
689 p=PushLongPixel(quantum_info->endian,p,&pixel);
690 SetPixelRed(q,ScaleLongToQuantum(pixel));
691 p+=quantum_info->pad;
698 if (quantum_info->format == FloatingPointQuantumFormat)
703 for (x=0; x < (ssize_t) number_pixels; x++)
705 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
706 SetPixelRed(q,ClampToQuantum(pixel));
707 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
708 SetPixelGreen(q,ClampToQuantum(pixel));
709 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
710 SetPixelBlue(q,ClampToQuantum(pixel));
711 p+=quantum_info->pad;
719 if (quantum_info->format == FloatingPointQuantumFormat)
724 for (x=0; x < (ssize_t) number_pixels; x++)
726 p=PushDoublePixel(quantum_info,p,&pixel);
727 SetPixelRed(q,ClampToQuantum(pixel));
728 p=PushDoublePixel(quantum_info,p,&pixel);
729 SetPixelGreen(q,ClampToQuantum(pixel));
730 p=PushDoublePixel(quantum_info,p,&pixel);
731 SetPixelBlue(q,ClampToQuantum(pixel));
732 p+=quantum_info->pad;
740 range=GetQuantumRange(quantum_info->depth);
741 for (x=0; x < (ssize_t) number_pixels; x++)
743 p=PushQuantumPixel(quantum_info,p,&pixel);
744 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
745 p=PushQuantumPixel(quantum_info,p,&pixel);
746 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
747 p=PushQuantumPixel(quantum_info,p,&pixel);
748 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
756 static void ImportBGRAQuantum(
QuantumInfo *quantum_info,
757 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
769 switch (quantum_info->depth)
776 for (x=0; x < (ssize_t) number_pixels; x++)
778 p=PushCharPixel(p,&pixel);
779 SetPixelBlue(q,ScaleCharToQuantum(pixel));
780 p=PushCharPixel(p,&pixel);
781 SetPixelGreen(q,ScaleCharToQuantum(pixel));
782 p=PushCharPixel(p,&pixel);
783 SetPixelRed(q,ScaleCharToQuantum(pixel));
784 p=PushCharPixel(p,&pixel);
785 SetPixelAlpha(q,ScaleCharToQuantum(pixel));
786 p+=quantum_info->pad;
794 if (quantum_info->pack == MagickFalse)
807 for (x=0; x < (ssize_t) number_pixels; x++)
809 for (i=0; i < 4; i++)
815 p=PushLongPixel(quantum_info->endian,p,&pixel);
816 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
817 (((pixel >> 22) & 0x3ff) << 6)));
822 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
823 (((pixel >> 12) & 0x3ff) << 6)));
828 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
829 (((pixel >> 2) & 0x3ff) << 6)));
835 case 0: SetPixelRed(q,quantum);
break;
836 case 1: SetPixelGreen(q,quantum);
break;
837 case 2: SetPixelBlue(q,quantum);
break;
838 case 3: SetPixelAlpha(q,quantum);
break;
842 p+=quantum_info->pad;
847 for (x=0; x < (ssize_t) number_pixels; x++)
849 p=PushQuantumPixel(quantum_info,p,&pixel);
850 SetPixelRed(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
851 p=PushQuantumPixel(quantum_info,p,&pixel);
852 SetPixelGreen(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
853 p=PushQuantumPixel(quantum_info,p,&pixel);
854 SetPixelBlue(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
855 p=PushQuantumPixel(quantum_info,p,&pixel);
856 SetPixelAlpha(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
866 if (quantum_info->format == FloatingPointQuantumFormat)
868 for (x=0; x < (ssize_t) number_pixels; x++)
870 p=PushShortPixel(quantum_info->endian,p,&pixel);
871 SetPixelRed(q,ClampToQuantum((MagickRealType) QuantumRange*
872 HalfToSinglePrecision(pixel)));
873 p=PushShortPixel(quantum_info->endian,p,&pixel);
874 SetPixelGreen(q,ClampToQuantum((MagickRealType) QuantumRange*
875 HalfToSinglePrecision(pixel)));
876 p=PushShortPixel(quantum_info->endian,p,&pixel);
877 SetPixelBlue(q,ClampToQuantum((MagickRealType) QuantumRange*
878 HalfToSinglePrecision(pixel)));
879 p=PushShortPixel(quantum_info->endian,p,&pixel);
880 SetPixelAlpha(q,ClampToQuantum((MagickRealType) QuantumRange*
881 HalfToSinglePrecision(pixel)));
882 p+=quantum_info->pad;
887 for (x=0; x < (ssize_t) number_pixels; x++)
889 p=PushShortPixel(quantum_info->endian,p,&pixel);
890 SetPixelBlue(q,ScaleShortToQuantum(pixel));
891 p=PushShortPixel(quantum_info->endian,p,&pixel);
892 SetPixelGreen(q,ScaleShortToQuantum(pixel));
893 p=PushShortPixel(quantum_info->endian,p,&pixel);
894 SetPixelRed(q,ScaleShortToQuantum(pixel));
895 p=PushShortPixel(quantum_info->endian,p,&pixel);
896 SetPixelAlpha(q,ScaleShortToQuantum(pixel));
897 p+=quantum_info->pad;
904 if (quantum_info->format == FloatingPointQuantumFormat)
909 for (x=0; x < (ssize_t) number_pixels; x++)
911 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
912 SetPixelRed(q,ClampToQuantum(pixel));
913 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
914 SetPixelGreen(q,ClampToQuantum(pixel));
915 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
916 SetPixelBlue(q,ClampToQuantum(pixel));
917 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
918 SetPixelAlpha(q,ClampToQuantum(pixel));
919 p+=quantum_info->pad;
924 for (x=0; x < (ssize_t) number_pixels; x++)
926 p=PushLongPixel(quantum_info->endian,p,&pixel);
927 SetPixelBlue(q,ScaleLongToQuantum(pixel));
928 p=PushLongPixel(quantum_info->endian,p,&pixel);
929 SetPixelGreen(q,ScaleLongToQuantum(pixel));
930 p=PushLongPixel(quantum_info->endian,p,&pixel);
931 SetPixelRed(q,ScaleLongToQuantum(pixel));
932 p=PushLongPixel(quantum_info->endian,p,&pixel);
933 SetPixelAlpha(q,ScaleLongToQuantum(pixel));
934 p+=quantum_info->pad;
941 if (quantum_info->format == FloatingPointQuantumFormat)
946 for (x=0; x < (ssize_t) number_pixels; x++)
948 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
949 SetPixelRed(q,ClampToQuantum(pixel));
950 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
951 SetPixelGreen(q,ClampToQuantum(pixel));
952 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
953 SetPixelBlue(q,ClampToQuantum(pixel));
954 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
955 SetPixelAlpha(q,ClampToQuantum(pixel));
956 p+=quantum_info->pad;
964 if (quantum_info->format == FloatingPointQuantumFormat)
969 for (x=0; x < (ssize_t) number_pixels; x++)
971 p=PushDoublePixel(quantum_info,p,&pixel);
972 SetPixelRed(q,ClampToQuantum(pixel));
973 p=PushDoublePixel(quantum_info,p,&pixel);
974 SetPixelGreen(q,ClampToQuantum(pixel));
975 p=PushDoublePixel(quantum_info,p,&pixel);
976 SetPixelBlue(q,ClampToQuantum(pixel));
977 p=PushDoublePixel(quantum_info,p,&pixel);
978 SetPixelAlpha(q,ClampToQuantum(pixel));
979 p+=quantum_info->pad;
987 range=GetQuantumRange(quantum_info->depth);
988 for (x=0; x < (ssize_t) number_pixels; x++)
990 p=PushQuantumPixel(quantum_info,p,&pixel);
991 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
992 p=PushQuantumPixel(quantum_info,p,&pixel);
993 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
994 p=PushQuantumPixel(quantum_info,p,&pixel);
995 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
996 p=PushQuantumPixel(quantum_info,p,&pixel);
997 SetPixelAlpha(q,ScaleAnyToQuantum(pixel,range));
1005 static void ImportBGROQuantum(
QuantumInfo *quantum_info,
1006 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
1018 switch (quantum_info->depth)
1025 for (x=0; x < (ssize_t) number_pixels; x++)
1027 p=PushCharPixel(p,&pixel);
1028 SetPixelBlue(q,ScaleCharToQuantum(pixel));
1029 p=PushCharPixel(p,&pixel);
1030 SetPixelGreen(q,ScaleCharToQuantum(pixel));
1031 p=PushCharPixel(p,&pixel);
1032 SetPixelRed(q,ScaleCharToQuantum(pixel));
1033 p=PushCharPixel(p,&pixel);
1034 SetPixelOpacity(q,ScaleCharToQuantum(pixel));
1035 p+=quantum_info->pad;
1043 if (quantum_info->pack == MagickFalse)
1056 for (x=0; x < (ssize_t) number_pixels; x++)
1058 for (i=0; i < 4; i++)
1064 p=PushLongPixel(quantum_info->endian,p,&pixel);
1065 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
1066 (((pixel >> 22) & 0x3ff) << 6)));
1071 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
1072 (((pixel >> 12) & 0x3ff) << 6)));
1077 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
1078 (((pixel >> 2) & 0x3ff) << 6)));
1084 case 0: SetPixelRed(q,quantum);
break;
1085 case 1: SetPixelGreen(q,quantum);
break;
1086 case 2: SetPixelBlue(q,quantum);
break;
1087 case 3: SetPixelOpacity(q,quantum);
break;
1091 p+=quantum_info->pad;
1096 for (x=0; x < (ssize_t) number_pixels; x++)
1098 p=PushQuantumPixel(quantum_info,p,&pixel);
1099 SetPixelRed(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
1100 p=PushQuantumPixel(quantum_info,p,&pixel);
1101 SetPixelGreen(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
1102 p=PushQuantumPixel(quantum_info,p,&pixel);
1103 SetPixelBlue(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
1104 p=PushQuantumPixel(quantum_info,p,&pixel);
1105 SetPixelOpacity(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
1115 if (quantum_info->format == FloatingPointQuantumFormat)
1117 for (x=0; x < (ssize_t) number_pixels; x++)
1119 p=PushShortPixel(quantum_info->endian,p,&pixel);
1120 SetPixelRed(q,ClampToQuantum((MagickRealType) QuantumRange*
1121 HalfToSinglePrecision(pixel)));
1122 p=PushShortPixel(quantum_info->endian,p,&pixel);
1123 SetPixelGreen(q,ClampToQuantum((MagickRealType) QuantumRange*
1124 HalfToSinglePrecision(pixel)));
1125 p=PushShortPixel(quantum_info->endian,p,&pixel);
1126 SetPixelBlue(q,ClampToQuantum((MagickRealType) QuantumRange*
1127 HalfToSinglePrecision(pixel)));
1128 p=PushShortPixel(quantum_info->endian,p,&pixel);
1129 SetPixelOpacity(q,ClampToQuantum((MagickRealType) QuantumRange*
1130 HalfToSinglePrecision(pixel)));
1131 p+=quantum_info->pad;
1136 for (x=0; x < (ssize_t) number_pixels; x++)
1138 p=PushShortPixel(quantum_info->endian,p,&pixel);
1139 SetPixelBlue(q,ScaleShortToQuantum(pixel));
1140 p=PushShortPixel(quantum_info->endian,p,&pixel);
1141 SetPixelGreen(q,ScaleShortToQuantum(pixel));
1142 p=PushShortPixel(quantum_info->endian,p,&pixel);
1143 SetPixelRed(q,ScaleShortToQuantum(pixel));
1144 p=PushShortPixel(quantum_info->endian,p,&pixel);
1145 SetPixelOpacity(q,ScaleShortToQuantum(pixel));
1146 p+=quantum_info->pad;
1153 if (quantum_info->format == FloatingPointQuantumFormat)
1158 for (x=0; x < (ssize_t) number_pixels; x++)
1160 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1161 SetPixelRed(q,ClampToQuantum(pixel));
1162 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1163 SetPixelGreen(q,ClampToQuantum(pixel));
1164 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1165 SetPixelBlue(q,ClampToQuantum(pixel));
1166 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1167 SetPixelOpacity(q,ClampToQuantum(pixel));
1168 p+=quantum_info->pad;
1173 for (x=0; x < (ssize_t) number_pixels; x++)
1175 p=PushLongPixel(quantum_info->endian,p,&pixel);
1176 SetPixelBlue(q,ScaleLongToQuantum(pixel));
1177 p=PushLongPixel(quantum_info->endian,p,&pixel);
1178 SetPixelGreen(q,ScaleLongToQuantum(pixel));
1179 p=PushLongPixel(quantum_info->endian,p,&pixel);
1180 SetPixelRed(q,ScaleLongToQuantum(pixel));
1181 p=PushLongPixel(quantum_info->endian,p,&pixel);
1182 SetPixelOpacity(q,ScaleLongToQuantum(pixel));
1183 p+=quantum_info->pad;
1190 if (quantum_info->format == FloatingPointQuantumFormat)
1195 for (x=0; x < (ssize_t) number_pixels; x++)
1197 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1198 SetPixelRed(q,ClampToQuantum(pixel));
1199 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1200 SetPixelGreen(q,ClampToQuantum(pixel));
1201 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1202 SetPixelBlue(q,ClampToQuantum(pixel));
1203 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1204 SetPixelOpacity(q,ClampToQuantum(pixel));
1205 p+=quantum_info->pad;
1213 if (quantum_info->format == FloatingPointQuantumFormat)
1218 for (x=0; x < (ssize_t) number_pixels; x++)
1220 p=PushDoublePixel(quantum_info,p,&pixel);
1221 SetPixelRed(q,ClampToQuantum(pixel));
1222 p=PushDoublePixel(quantum_info,p,&pixel);
1223 SetPixelGreen(q,ClampToQuantum(pixel));
1224 p=PushDoublePixel(quantum_info,p,&pixel);
1225 SetPixelBlue(q,ClampToQuantum(pixel));
1226 p=PushDoublePixel(quantum_info,p,&pixel);
1227 SetPixelOpacity(q,ClampToQuantum(pixel));
1228 p+=quantum_info->pad;
1236 range=GetQuantumRange(quantum_info->depth);
1237 for (x=0; x < (ssize_t) number_pixels; x++)
1239 p=PushQuantumPixel(quantum_info,p,&pixel);
1240 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
1241 p=PushQuantumPixel(quantum_info,p,&pixel);
1242 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
1243 p=PushQuantumPixel(quantum_info,p,&pixel);
1244 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
1245 p=PushQuantumPixel(quantum_info,p,&pixel);
1246 SetPixelOpacity(q,ScaleAnyToQuantum(pixel,range));
1254 static void ImportBlackQuantum(
const Image *image,
QuantumInfo *quantum_info,
1255 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
1256 PixelPacket *magick_restrict q,IndexPacket *magick_restrict indexes,
1265 if (image->colorspace != CMYKColorspace)
1267 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1268 "ColorSeparatedImageRequired",
"`%s'",image->filename);
1271 switch (quantum_info->depth)
1278 for (x=0; x < (ssize_t) number_pixels; x++)
1280 p=PushCharPixel(p,&pixel);
1281 SetPixelIndex(indexes+x,ScaleCharToQuantum(pixel));
1282 p+=quantum_info->pad;
1291 if (quantum_info->format == FloatingPointQuantumFormat)
1293 for (x=0; x < (ssize_t) number_pixels; x++)
1295 p=PushShortPixel(quantum_info->endian,p,&pixel);
1296 SetPixelIndex(indexes+x,ClampToQuantum((MagickRealType)
1297 QuantumRange*HalfToSinglePrecision(pixel)));
1298 p+=quantum_info->pad;
1302 for (x=0; x < (ssize_t) number_pixels; x++)
1304 p=PushShortPixel(quantum_info->endian,p,&pixel);
1305 SetPixelIndex(indexes+x,ScaleShortToQuantum(pixel));
1306 p+=quantum_info->pad;
1312 if (quantum_info->format == FloatingPointQuantumFormat)
1317 for (x=0; x < (ssize_t) number_pixels; x++)
1319 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1320 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1321 p+=quantum_info->pad;
1326 for (x=0; x < (ssize_t) number_pixels; x++)
1328 p=PushLongPixel(quantum_info->endian,p,&pixel);
1329 SetPixelIndex(indexes+x,ScaleLongToQuantum(pixel));
1330 p+=quantum_info->pad;
1337 if (quantum_info->format == FloatingPointQuantumFormat)
1342 for (x=0; x < (ssize_t) number_pixels; x++)
1344 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1345 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1346 p+=quantum_info->pad;
1354 if (quantum_info->format == FloatingPointQuantumFormat)
1359 for (x=0; x < (ssize_t) number_pixels; x++)
1361 p=PushDoublePixel(quantum_info,p,&pixel);
1362 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1363 p+=quantum_info->pad;
1374 range=GetQuantumRange(quantum_info->depth);
1375 for (x=0; x < (ssize_t) number_pixels; x++)
1377 p=PushQuantumPixel(quantum_info,p,&pixel);
1378 SetPixelIndex(indexes+x,ScaleAnyToQuantum(pixel,range));
1379 p+=quantum_info->pad;
1387 static void ImportBlueQuantum(
QuantumInfo *quantum_info,
1388 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
1397 switch (quantum_info->depth)
1404 for (x=0; x < (ssize_t) number_pixels; x++)
1406 p=PushCharPixel(p,&pixel);
1407 SetPixelBlue(q,ScaleCharToQuantum(pixel));
1408 p+=quantum_info->pad;
1418 if (quantum_info->format == FloatingPointQuantumFormat)
1420 for (x=0; x < (ssize_t) number_pixels; x++)
1422 p=PushShortPixel(quantum_info->endian,p,&pixel);
1423 SetPixelBlue(q,ClampToQuantum((MagickRealType)
1424 QuantumRange*HalfToSinglePrecision(pixel)));
1425 p+=quantum_info->pad;
1430 for (x=0; x < (ssize_t) number_pixels; x++)
1432 p=PushShortPixel(quantum_info->endian,p,&pixel);
1433 SetPixelBlue(q,ScaleShortToQuantum(pixel));
1434 p+=quantum_info->pad;
1441 if (quantum_info->format == FloatingPointQuantumFormat)
1446 for (x=0; x < (ssize_t) number_pixels; x++)
1448 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1449 SetPixelBlue(q,ClampToQuantum(pixel));
1450 p+=quantum_info->pad;
1455 for (x=0; x < (ssize_t) number_pixels; x++)
1457 p=PushLongPixel(quantum_info->endian,p,&pixel);
1458 SetPixelBlue(q,ScaleLongToQuantum(pixel));
1459 p+=quantum_info->pad;
1466 if (quantum_info->format == FloatingPointQuantumFormat)
1471 for (x=0; x < (ssize_t) number_pixels; x++)
1473 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1474 SetPixelBlue(q,ClampToQuantum(pixel));
1475 p+=quantum_info->pad;
1483 if (quantum_info->format == FloatingPointQuantumFormat)
1488 for (x=0; x < (ssize_t) number_pixels; x++)
1490 p=PushDoublePixel(quantum_info,p,&pixel);
1491 SetPixelBlue(q,ClampToQuantum(pixel));
1492 p+=quantum_info->pad;
1503 range=GetQuantumRange(quantum_info->depth);
1504 for (x=0; x < (ssize_t) number_pixels; x++)
1506 p=PushQuantumPixel(quantum_info,p,&pixel);
1507 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
1508 p+=quantum_info->pad;
1516 static void ImportCbYCrYQuantum(
const Image *image,
QuantumInfo *quantum_info,
1517 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
1526 switch (quantum_info->depth)
1534 if (quantum_info->pack == MagickFalse)
1547 for (x=0; x < (ssize_t) (number_pixels-3); x+=4)
1549 for (i=0; i < 4; i++)
1555 p=PushLongPixel(quantum_info->endian,p,&pixel);
1556 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
1557 (((pixel >> 22) & 0x3ff) << 6)));
1562 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
1563 (((pixel >> 12) & 0x3ff) << 6)));
1568 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
1569 (((pixel >> 2) & 0x3ff) << 6)));
1573 cbcr[i]=(Quantum) (quantum);
1576 p+=quantum_info->pad;
1577 SetPixelRed(q,cbcr[1]);
1578 SetPixelGreen(q,cbcr[0]);
1579 SetPixelBlue(q,cbcr[2]);
1581 SetPixelRed(q,cbcr[3]);
1582 SetPixelGreen(q,cbcr[0]);
1583 SetPixelBlue(q,cbcr[2]);
1594 range=GetQuantumRange(image->depth);
1595 for (x=0; x < (ssize_t) number_pixels; x++)
1597 p=PushQuantumPixel(quantum_info,p,&pixel);
1598 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
1599 p=PushQuantumPixel(quantum_info,p,&pixel);
1600 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
1608 static void ImportCMYKQuantum(
const Image *image,
QuantumInfo *quantum_info,
1609 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
1610 PixelPacket *magick_restrict q,IndexPacket *magick_restrict indexes,
1622 if (image->colorspace != CMYKColorspace)
1624 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1625 "ColorSeparatedImageRequired",
"`%s'",image->filename);
1628 switch (quantum_info->depth)
1635 for (x=0; x < (ssize_t) number_pixels; x++)
1637 p=PushCharPixel(p,&pixel);
1638 SetPixelRed(q,ScaleCharToQuantum(pixel));
1639 p=PushCharPixel(p,&pixel);
1640 SetPixelGreen(q,ScaleCharToQuantum(pixel));
1641 p=PushCharPixel(p,&pixel);
1642 SetPixelBlue(q,ScaleCharToQuantum(pixel));
1643 p=PushCharPixel(p,&pixel);
1644 SetPixelIndex(indexes+x,ScaleCharToQuantum(pixel));
1645 p+=quantum_info->pad;
1655 if (quantum_info->format == FloatingPointQuantumFormat)
1657 for (x=0; x < (ssize_t) number_pixels; x++)
1659 p=PushShortPixel(quantum_info->endian,p,&pixel);
1660 SetPixelRed(q,ClampToQuantum((MagickRealType) QuantumRange*
1661 HalfToSinglePrecision(pixel)));
1662 p=PushShortPixel(quantum_info->endian,p,&pixel);
1663 SetPixelGreen(q,ClampToQuantum((MagickRealType) QuantumRange*
1664 HalfToSinglePrecision(pixel)));
1665 p=PushShortPixel(quantum_info->endian,p,&pixel);
1666 SetPixelBlue(q,ClampToQuantum((MagickRealType) QuantumRange*
1667 HalfToSinglePrecision(pixel)));
1668 p=PushShortPixel(quantum_info->endian,p,&pixel);
1669 SetPixelIndex(indexes+x,ClampToQuantum((MagickRealType)
1670 QuantumRange*HalfToSinglePrecision(pixel)));
1671 p+=quantum_info->pad;
1676 for (x=0; x < (ssize_t) number_pixels; x++)
1678 p=PushShortPixel(quantum_info->endian,p,&pixel);
1679 SetPixelRed(q,ScaleShortToQuantum(pixel));
1680 p=PushShortPixel(quantum_info->endian,p,&pixel);
1681 SetPixelGreen(q,ScaleShortToQuantum(pixel));
1682 p=PushShortPixel(quantum_info->endian,p,&pixel);
1683 SetPixelBlue(q,ScaleShortToQuantum(pixel));
1684 p=PushShortPixel(quantum_info->endian,p,&pixel);
1685 SetPixelIndex(indexes+x,ScaleShortToQuantum(pixel));
1686 p+=quantum_info->pad;
1693 if (quantum_info->format == FloatingPointQuantumFormat)
1698 for (x=0; x < (ssize_t) number_pixels; x++)
1700 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1701 SetPixelRed(q,ClampToQuantum(pixel));
1702 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1703 SetPixelGreen(q,ClampToQuantum(pixel));
1704 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1705 SetPixelBlue(q,ClampToQuantum(pixel));
1706 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1707 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1708 p+=quantum_info->pad;
1713 for (x=0; x < (ssize_t) number_pixels; x++)
1715 p=PushLongPixel(quantum_info->endian,p,&pixel);
1716 SetPixelRed(q,ScaleLongToQuantum(pixel));
1717 p=PushLongPixel(quantum_info->endian,p,&pixel);
1718 SetPixelGreen(q,ScaleLongToQuantum(pixel));
1719 p=PushLongPixel(quantum_info->endian,p,&pixel);
1720 SetPixelBlue(q,ScaleLongToQuantum(pixel));
1721 p=PushLongPixel(quantum_info->endian,p,&pixel);
1722 SetPixelIndex(indexes+x,ScaleLongToQuantum(pixel));
1723 p+=quantum_info->pad;
1730 if (quantum_info->format == FloatingPointQuantumFormat)
1735 for (x=0; x < (ssize_t) number_pixels; x++)
1737 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1738 SetPixelRed(q,ClampToQuantum(pixel));
1739 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1740 SetPixelGreen(q,ClampToQuantum(pixel));
1741 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1742 SetPixelBlue(q,ClampToQuantum(pixel));
1743 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1744 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1745 p+=quantum_info->pad;
1753 if (quantum_info->format == FloatingPointQuantumFormat)
1758 for (x=0; x < (ssize_t) number_pixels; x++)
1760 p=PushDoublePixel(quantum_info,p,&pixel);
1761 SetPixelRed(q,ClampToQuantum(pixel));
1762 p=PushDoublePixel(quantum_info,p,&pixel);
1763 SetPixelGreen(q,ClampToQuantum(pixel));
1764 p=PushDoublePixel(quantum_info,p,&pixel);
1765 SetPixelBlue(q,ClampToQuantum(pixel));
1766 p=PushDoublePixel(quantum_info,p,&pixel);
1767 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1768 p+=quantum_info->pad;
1776 range=GetQuantumRange(quantum_info->depth);
1777 for (x=0; x < (ssize_t) number_pixels; x++)
1779 p=PushQuantumPixel(quantum_info,p,&pixel);
1780 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
1781 p=PushQuantumPixel(quantum_info,p,&pixel);
1782 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
1783 p=PushQuantumPixel(quantum_info,p,&pixel);
1784 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
1785 p=PushQuantumPixel(quantum_info,p,&pixel);
1786 SetPixelIndex(indexes+x,ScaleAnyToQuantum(pixel,range));
1794 static void ImportCMYKAQuantum(
const Image *image,
QuantumInfo *quantum_info,
1795 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
1796 PixelPacket *magick_restrict q,IndexPacket *magick_restrict indexes,
1808 if (image->colorspace != CMYKColorspace)
1810 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1811 "ColorSeparatedImageRequired",
"`%s'",image->filename);
1814 switch (quantum_info->depth)
1821 for (x=0; x < (ssize_t) number_pixels; x++)
1823 p=PushCharPixel(p,&pixel);
1824 SetPixelRed(q,ScaleCharToQuantum(pixel));
1825 p=PushCharPixel(p,&pixel);
1826 SetPixelGreen(q,ScaleCharToQuantum(pixel));
1827 p=PushCharPixel(p,&pixel);
1828 SetPixelBlue(q,ScaleCharToQuantum(pixel));
1829 p=PushCharPixel(p,&pixel);
1830 SetPixelIndex(indexes+x,ScaleCharToQuantum(pixel));
1831 p=PushCharPixel(p,&pixel);
1832 SetPixelAlpha(q,ScaleCharToQuantum(pixel));
1833 p+=quantum_info->pad;
1843 if (quantum_info->format == FloatingPointQuantumFormat)
1845 for (x=0; x < (ssize_t) number_pixels; x++)
1847 p=PushShortPixel(quantum_info->endian,p,&pixel);
1848 SetPixelRed(q,ClampToQuantum((MagickRealType) QuantumRange*
1849 HalfToSinglePrecision(pixel)));
1850 p=PushShortPixel(quantum_info->endian,p,&pixel);
1851 SetPixelGreen(q,ClampToQuantum((MagickRealType) QuantumRange*
1852 HalfToSinglePrecision(pixel)));
1853 p=PushShortPixel(quantum_info->endian,p,&pixel);
1854 SetPixelBlue(q,ClampToQuantum((MagickRealType) QuantumRange*
1855 HalfToSinglePrecision(pixel)));
1856 p=PushShortPixel(quantum_info->endian,p,&pixel);
1857 SetPixelIndex(indexes+x,ClampToQuantum((MagickRealType)
1858 QuantumRange*HalfToSinglePrecision(pixel)));
1859 p=PushShortPixel(quantum_info->endian,p,&pixel);
1860 SetPixelAlpha(q,ClampToQuantum((MagickRealType) QuantumRange*
1861 HalfToSinglePrecision(pixel)));
1862 p+=quantum_info->pad;
1867 for (x=0; x < (ssize_t) number_pixels; x++)
1869 p=PushShortPixel(quantum_info->endian,p,&pixel);
1870 SetPixelRed(q,ScaleShortToQuantum(pixel));
1871 p=PushShortPixel(quantum_info->endian,p,&pixel);
1872 SetPixelGreen(q,ScaleShortToQuantum(pixel));
1873 p=PushShortPixel(quantum_info->endian,p,&pixel);
1874 SetPixelBlue(q,ScaleShortToQuantum(pixel));
1875 p=PushShortPixel(quantum_info->endian,p,&pixel);
1876 SetPixelIndex(indexes+x,ScaleShortToQuantum(pixel));
1877 p=PushShortPixel(quantum_info->endian,p,&pixel);
1878 SetPixelAlpha(q,ScaleShortToQuantum(pixel));
1879 p+=quantum_info->pad;
1886 if (quantum_info->format == FloatingPointQuantumFormat)
1891 for (x=0; x < (ssize_t) number_pixels; x++)
1893 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1894 SetPixelRed(q,ClampToQuantum(pixel));
1895 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1896 SetPixelGreen(q,ClampToQuantum(pixel));
1897 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1898 SetPixelBlue(q,ClampToQuantum(pixel));
1899 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1900 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1901 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1902 SetPixelAlpha(q,ClampToQuantum(pixel));
1903 p+=quantum_info->pad;
1908 for (x=0; x < (ssize_t) number_pixels; x++)
1910 p=PushLongPixel(quantum_info->endian,p,&pixel);
1911 SetPixelRed(q,ScaleLongToQuantum(pixel));
1912 p=PushLongPixel(quantum_info->endian,p,&pixel);
1913 SetPixelGreen(q,ScaleLongToQuantum(pixel));
1914 p=PushLongPixel(quantum_info->endian,p,&pixel);
1915 SetPixelBlue(q,ScaleLongToQuantum(pixel));
1916 p=PushLongPixel(quantum_info->endian,p,&pixel);
1917 SetPixelIndex(indexes+x,ScaleLongToQuantum(pixel));
1918 p=PushLongPixel(quantum_info->endian,p,&pixel);
1919 SetPixelAlpha(q,ScaleLongToQuantum(pixel));
1920 p+=quantum_info->pad;
1927 if (quantum_info->format == FloatingPointQuantumFormat)
1932 for (x=0; x < (ssize_t) number_pixels; x++)
1934 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1935 SetPixelRed(q,ClampToQuantum(pixel));
1936 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1937 SetPixelGreen(q,ClampToQuantum(pixel));
1938 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1939 SetPixelBlue(q,ClampToQuantum(pixel));
1940 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1941 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1942 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1943 SetPixelAlpha(q,ClampToQuantum(pixel));
1944 p+=quantum_info->pad;
1952 if (quantum_info->format == FloatingPointQuantumFormat)
1957 for (x=0; x < (ssize_t) number_pixels; x++)
1959 p=PushDoublePixel(quantum_info,p,&pixel);
1960 SetPixelRed(q,ClampToQuantum(pixel));
1961 p=PushDoublePixel(quantum_info,p,&pixel);
1962 SetPixelGreen(q,ClampToQuantum(pixel));
1963 p=PushDoublePixel(quantum_info,p,&pixel);
1964 SetPixelBlue(q,ClampToQuantum(pixel));
1965 p=PushDoublePixel(quantum_info,p,&pixel);
1966 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1967 p=PushDoublePixel(quantum_info,p,&pixel);
1968 SetPixelAlpha(q,ClampToQuantum(pixel));
1969 p+=quantum_info->pad;
1977 range=GetQuantumRange(image->depth);
1978 for (x=0; x < (ssize_t) number_pixels; x++)
1980 p=PushQuantumPixel(quantum_info,p,&pixel);
1981 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
1982 p=PushQuantumPixel(quantum_info,p,&pixel);
1983 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
1984 p=PushQuantumPixel(quantum_info,p,&pixel);
1985 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
1986 p=PushQuantumPixel(quantum_info,p,&pixel);
1987 SetPixelIndex(indexes+x,ScaleAnyToQuantum(pixel,range));
1988 p=PushQuantumPixel(quantum_info,p,&pixel);
1989 SetPixelAlpha(q,ScaleAnyToQuantum(pixel,range));
1997 static void ImportCMYKOQuantum(
const Image *image,
QuantumInfo *quantum_info,
1998 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
1999 PixelPacket *magick_restrict q,IndexPacket *magick_restrict indexes,
2011 if (image->colorspace != CMYKColorspace)
2013 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
2014 "ColorSeparatedImageRequired",
"`%s'",image->filename);
2017 switch (quantum_info->depth)
2024 for (x=0; x < (ssize_t) number_pixels; x++)
2026 p=PushCharPixel(p,&pixel);
2027 SetPixelRed(q,ScaleCharToQuantum(pixel));
2028 p=PushCharPixel(p,&pixel);
2029 SetPixelGreen(q,ScaleCharToQuantum(pixel));
2030 p=PushCharPixel(p,&pixel);
2031 SetPixelBlue(q,ScaleCharToQuantum(pixel));
2032 p=PushCharPixel(p,&pixel);
2033 SetPixelIndex(indexes+x,ScaleCharToQuantum(pixel));
2034 p=PushCharPixel(p,&pixel);
2035 SetPixelOpacity(q,ScaleCharToQuantum(pixel));
2036 p+=quantum_info->pad;
2046 if (quantum_info->format == FloatingPointQuantumFormat)
2048 for (x=0; x < (ssize_t) number_pixels; x++)
2050 p=PushShortPixel(quantum_info->endian,p,&pixel);
2051 SetPixelRed(q,ClampToQuantum((MagickRealType) QuantumRange*
2052 HalfToSinglePrecision(pixel)));
2053 p=PushShortPixel(quantum_info->endian,p,&pixel);
2054 SetPixelGreen(q,ClampToQuantum((MagickRealType) QuantumRange*
2055 HalfToSinglePrecision(pixel)));
2056 p=PushShortPixel(quantum_info->endian,p,&pixel);
2057 SetPixelBlue(q,ClampToQuantum((MagickRealType) QuantumRange*
2058 HalfToSinglePrecision(pixel)));
2059 p=PushShortPixel(quantum_info->endian,p,&pixel);
2060 SetPixelIndex(indexes+x,ClampToQuantum((MagickRealType)
2061 QuantumRange*HalfToSinglePrecision(pixel)));
2062 p=PushShortPixel(quantum_info->endian,p,&pixel);
2063 SetPixelOpacity(q,ClampToQuantum((MagickRealType) QuantumRange*
2064 HalfToSinglePrecision(pixel)));
2065 p+=quantum_info->pad;
2070 for (x=0; x < (ssize_t) number_pixels; x++)
2072 p=PushShortPixel(quantum_info->endian,p,&pixel);
2073 SetPixelRed(q,ScaleShortToQuantum(pixel));
2074 p=PushShortPixel(quantum_info->endian,p,&pixel);
2075 SetPixelGreen(q,ScaleShortToQuantum(pixel));
2076 p=PushShortPixel(quantum_info->endian,p,&pixel);
2077 SetPixelBlue(q,ScaleShortToQuantum(pixel));
2078 p=PushShortPixel(quantum_info->endian,p,&pixel);
2079 SetPixelIndex(indexes+x,ScaleShortToQuantum(pixel));
2080 p=PushShortPixel(quantum_info->endian,p,&pixel);
2081 SetPixelOpacity(q,ScaleShortToQuantum(pixel));
2082 p+=quantum_info->pad;
2089 if (quantum_info->format == FloatingPointQuantumFormat)
2094 for (x=0; x < (ssize_t) number_pixels; x++)
2096 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2097 SetPixelRed(q,ClampToQuantum(pixel));
2098 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2099 SetPixelGreen(q,ClampToQuantum(pixel));
2100 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2101 SetPixelBlue(q,ClampToQuantum(pixel));
2102 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2103 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
2104 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2105 SetPixelOpacity(q,ClampToQuantum(pixel));
2106 p+=quantum_info->pad;
2111 for (x=0; x < (ssize_t) number_pixels; x++)
2113 p=PushLongPixel(quantum_info->endian,p,&pixel);
2114 SetPixelRed(q,ScaleLongToQuantum(pixel));
2115 p=PushLongPixel(quantum_info->endian,p,&pixel);
2116 SetPixelGreen(q,ScaleLongToQuantum(pixel));
2117 p=PushLongPixel(quantum_info->endian,p,&pixel);
2118 SetPixelBlue(q,ScaleLongToQuantum(pixel));
2119 p=PushLongPixel(quantum_info->endian,p,&pixel);
2120 SetPixelIndex(indexes+x,ScaleLongToQuantum(pixel));
2121 p=PushLongPixel(quantum_info->endian,p,&pixel);
2122 SetPixelOpacity(q,ScaleLongToQuantum(pixel));
2123 p+=quantum_info->pad;
2130 if (quantum_info->format == FloatingPointQuantumFormat)
2135 for (x=0; x < (ssize_t) number_pixels; x++)
2137 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2138 SetPixelRed(q,ClampToQuantum(pixel));
2139 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2140 SetPixelGreen(q,ClampToQuantum(pixel));
2141 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2142 SetPixelBlue(q,ClampToQuantum(pixel));
2143 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2144 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
2145 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2146 SetPixelOpacity(q,ClampToQuantum(pixel));
2147 p+=quantum_info->pad;
2155 if (quantum_info->format == FloatingPointQuantumFormat)
2160 for (x=0; x < (ssize_t) number_pixels; x++)
2162 p=PushDoublePixel(quantum_info,p,&pixel);
2163 SetPixelRed(q,ClampToQuantum(pixel));
2164 p=PushDoublePixel(quantum_info,p,&pixel);
2165 SetPixelGreen(q,ClampToQuantum(pixel));
2166 p=PushDoublePixel(quantum_info,p,&pixel);
2167 SetPixelBlue(q,ClampToQuantum(pixel));
2168 p=PushDoublePixel(quantum_info,p,&pixel);
2169 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
2170 p=PushDoublePixel(quantum_info,p,&pixel);
2171 SetPixelOpacity(q,ClampToQuantum(pixel));
2172 p+=quantum_info->pad;
2180 range=GetQuantumRange(image->depth);
2181 for (x=0; x < (ssize_t) number_pixels; x++)
2183 p=PushQuantumPixel(quantum_info,p,&pixel);
2184 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2185 p=PushQuantumPixel(quantum_info,p,&pixel);
2186 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
2187 p=PushQuantumPixel(quantum_info,p,&pixel);
2188 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
2189 p=PushQuantumPixel(quantum_info,p,&pixel);
2190 SetPixelIndex(indexes+x,ScaleAnyToQuantum(pixel,range));
2191 p=PushQuantumPixel(quantum_info,p,&pixel);
2192 SetPixelOpacity(q,ScaleAnyToQuantum(pixel,range));
2200 static void ImportGrayQuantum(
const Image *image,
QuantumInfo *quantum_info,
2201 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
2217 switch (quantum_info->depth)
2227 if (quantum_info->min_is_white != MagickFalse)
2232 for (x=0; x < ((ssize_t) number_pixels-7); x+=8)
2234 for (bit=0; bit < 8; bit++)
2236 SetPixelRed(q,((*p) & (1 << (7-bit))) == 0 ? black : white);
2237 SetPixelGreen(q,GetPixelRed(q));
2238 SetPixelBlue(q,GetPixelRed(q));
2243 for (bit=0; bit < (ssize_t) (number_pixels % 8); bit++)
2245 SetPixelRed(q,((*p) & (0x01 << (7-bit))) == 0 ? black : white);
2246 SetPixelGreen(q,GetPixelRed(q));
2247 SetPixelBlue(q,GetPixelRed(q));
2259 range=GetQuantumRange(quantum_info->depth);
2260 for (x=0; x < ((ssize_t) number_pixels-1); x+=2)
2262 pixel=(
unsigned char) ((*p >> 4) & 0xf);
2263 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2264 SetPixelGreen(q,GetPixelRed(q));
2265 SetPixelBlue(q,GetPixelRed(q));
2267 pixel=(
unsigned char) ((*p) & 0xf);
2268 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2269 SetPixelGreen(q,GetPixelRed(q));
2270 SetPixelBlue(q,GetPixelRed(q));
2274 for (bit=0; bit < (ssize_t) (number_pixels % 2); bit++)
2276 pixel=(
unsigned char) (*p++ >> 4);
2277 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2278 SetPixelGreen(q,GetPixelRed(q));
2279 SetPixelBlue(q,GetPixelRed(q));
2289 if (quantum_info->min_is_white != MagickFalse)
2291 for (x=0; x < (ssize_t) number_pixels; x++)
2293 p=PushCharPixel(p,&pixel);
2294 SetPixelRed(q,QuantumRange-ScaleCharToQuantum(pixel));
2295 SetPixelGreen(q,GetPixelRed(q));
2296 SetPixelBlue(q,GetPixelRed(q));
2297 SetPixelOpacity(q,OpaqueOpacity);
2298 p+=quantum_info->pad;
2303 for (x=0; x < (ssize_t) number_pixels; x++)
2305 p=PushCharPixel(p,&pixel);
2306 SetPixelRed(q,ScaleCharToQuantum(pixel));
2307 SetPixelGreen(q,GetPixelRed(q));
2308 SetPixelBlue(q,GetPixelRed(q));
2309 SetPixelOpacity(q,OpaqueOpacity);
2310 p+=quantum_info->pad;
2317 range=GetQuantumRange(quantum_info->depth);
2318 if (quantum_info->pack == MagickFalse)
2320 if (image->endian == LSBEndian)
2322 for (x=0; x < (ssize_t) (number_pixels-2); x+=3)
2324 p=PushLongPixel(quantum_info->endian,p,&pixel);
2325 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range));
2326 SetPixelGreen(q,GetPixelRed(q));
2327 SetPixelBlue(q,GetPixelRed(q));
2329 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range));
2330 SetPixelGreen(q,GetPixelRed(q));
2331 SetPixelBlue(q,GetPixelRed(q));
2333 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range));
2334 SetPixelGreen(q,GetPixelRed(q));
2335 SetPixelBlue(q,GetPixelRed(q));
2336 p+=quantum_info->pad;
2339 if (x++ < (ssize_t) (number_pixels-1))
2341 p=PushLongPixel(quantum_info->endian,p,&pixel);
2342 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range));
2343 SetPixelGreen(q,GetPixelRed(q));
2344 SetPixelBlue(q,GetPixelRed(q));
2347 if (x++ < (ssize_t) number_pixels)
2349 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range));
2350 SetPixelGreen(q,GetPixelRed(q));
2351 SetPixelBlue(q,GetPixelRed(q));
2356 for (x=0; x < (ssize_t) (number_pixels-2); x+=3)
2358 p=PushLongPixel(quantum_info->endian,p,&pixel);
2359 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range));
2360 SetPixelGreen(q,GetPixelRed(q));
2361 SetPixelBlue(q,GetPixelRed(q));
2363 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range));
2364 SetPixelGreen(q,GetPixelRed(q));
2365 SetPixelBlue(q,GetPixelRed(q));
2367 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range));
2368 SetPixelGreen(q,GetPixelRed(q));
2369 SetPixelBlue(q,GetPixelRed(q));
2370 p+=quantum_info->pad;
2373 if (x++ < (ssize_t) (number_pixels-1))
2375 p=PushLongPixel(quantum_info->endian,p,&pixel);
2376 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range));
2377 SetPixelGreen(q,GetPixelRed(q));
2378 SetPixelBlue(q,GetPixelRed(q));
2381 if (x++ < (ssize_t) number_pixels)
2383 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range));
2384 SetPixelGreen(q,GetPixelRed(q));
2385 SetPixelBlue(q,GetPixelRed(q));
2390 for (x=0; x < (ssize_t) number_pixels; x++)
2392 p=PushQuantumPixel(quantum_info,p,&pixel);
2393 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2394 SetPixelGreen(q,GetPixelRed(q));
2395 SetPixelBlue(q,GetPixelRed(q));
2396 p+=quantum_info->pad;
2403 range=GetQuantumRange(quantum_info->depth);
2404 if (quantum_info->pack == MagickFalse)
2409 for (x=0; x < (ssize_t) (number_pixels-1); x+=2)
2411 p=PushShortPixel(quantum_info->endian,p,&pixel);
2412 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range));
2413 SetPixelGreen(q,GetPixelRed(q));
2414 SetPixelBlue(q,GetPixelRed(q));
2416 p=PushShortPixel(quantum_info->endian,p,&pixel);
2417 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range));
2418 SetPixelGreen(q,GetPixelRed(q));
2419 SetPixelBlue(q,GetPixelRed(q));
2420 p+=quantum_info->pad;
2423 for (bit=0; bit < (ssize_t) (number_pixels % 2); bit++)
2425 p=PushShortPixel(quantum_info->endian,p,&pixel);
2426 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny)
2427 (pixel >> 4),range));
2428 SetPixelGreen(q,GetPixelRed(q));
2429 SetPixelBlue(q,GetPixelRed(q));
2430 p+=quantum_info->pad;
2437 for (x=0; x < (ssize_t) number_pixels; x++)
2439 p=PushQuantumPixel(quantum_info,p,&pixel);
2440 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2441 SetPixelGreen(q,GetPixelRed(q));
2442 SetPixelBlue(q,GetPixelRed(q));
2443 p+=quantum_info->pad;
2453 if (quantum_info->min_is_white != MagickFalse)
2455 for (x=0; x < (ssize_t) number_pixels; x++)
2457 p=PushShortPixel(quantum_info->endian,p,&pixel);
2458 SetPixelRed(q,QuantumRange-ScaleShortToQuantum(pixel));
2459 SetPixelGreen(q,GetPixelRed(q));
2460 SetPixelBlue(q,GetPixelRed(q));
2461 p+=quantum_info->pad;
2466 if (quantum_info->format == FloatingPointQuantumFormat)
2468 for (x=0; x < (ssize_t) number_pixels; x++)
2470 p=PushShortPixel(quantum_info->endian,p,&pixel);
2471 SetPixelRed(q,ClampToQuantum((MagickRealType) QuantumRange*
2472 HalfToSinglePrecision(pixel)));
2473 SetPixelGreen(q,GetPixelRed(q));
2474 SetPixelBlue(q,GetPixelRed(q));
2475 p+=quantum_info->pad;
2480 if (quantum_info->format == SignedQuantumFormat)
2482 for (x=0; x < (ssize_t) number_pixels; x++)
2484 p=PushShortPixel(quantum_info->endian,p,&pixel);
2485 pixel=(
unsigned short) (((
unsigned int) pixel+32768) % 65536);
2486 SetPixelRed(q,ScaleShortToQuantum(pixel));
2487 SetPixelGreen(q,GetPixelRed(q));
2488 SetPixelBlue(q,GetPixelRed(q));
2489 p+=quantum_info->pad;
2494 for (x=0; x < (ssize_t) number_pixels; x++)
2496 p=PushShortPixel(quantum_info->endian,p,&pixel);
2497 SetPixelRed(q,ScaleShortToQuantum(pixel));
2498 SetPixelGreen(q,GetPixelRed(q));
2499 SetPixelBlue(q,GetPixelRed(q));
2500 p+=quantum_info->pad;
2507 if (quantum_info->format == FloatingPointQuantumFormat)
2512 for (x=0; x < (ssize_t) number_pixels; x++)
2514 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2515 SetPixelRed(q,ClampToQuantum(pixel));
2516 SetPixelGreen(q,GetPixelRed(q));
2517 SetPixelBlue(q,GetPixelRed(q));
2518 p+=quantum_info->pad;
2523 for (x=0; x < (ssize_t) number_pixels; x++)
2525 p=PushLongPixel(quantum_info->endian,p,&pixel);
2526 SetPixelRed(q,ScaleLongToQuantum(pixel));
2527 SetPixelGreen(q,GetPixelRed(q));
2528 SetPixelBlue(q,GetPixelRed(q));
2529 p+=quantum_info->pad;
2536 if (quantum_info->format == FloatingPointQuantumFormat)
2541 for (x=0; x < (ssize_t) number_pixels; x++)
2543 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2544 SetPixelRed(q,ClampToQuantum(pixel));
2545 SetPixelGreen(q,GetPixelRed(q));
2546 SetPixelBlue(q,GetPixelRed(q));
2547 p+=quantum_info->pad;
2555 if (quantum_info->format == FloatingPointQuantumFormat)
2560 for (x=0; x < (ssize_t) number_pixels; x++)
2562 p=PushDoublePixel(quantum_info,p,&pixel);
2563 SetPixelRed(q,ClampToQuantum(pixel));
2564 SetPixelGreen(q,GetPixelRed(q));
2565 SetPixelBlue(q,GetPixelRed(q));
2566 p+=quantum_info->pad;
2574 range=GetQuantumRange(quantum_info->depth);
2575 for (x=0; x < (ssize_t) number_pixels; x++)
2577 p=PushQuantumPixel(quantum_info,p,&pixel);
2578 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2579 SetPixelGreen(q,GetPixelRed(q));
2580 SetPixelBlue(q,GetPixelRed(q));
2581 p+=quantum_info->pad;
2589 static void ImportGrayAlphaQuantum(
QuantumInfo *quantum_info,
2590 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
2605 switch (quantum_info->depth)
2613 for (x=((ssize_t) number_pixels-3); x > 0; x-=4)
2615 for (bit=0; bit < 8; bit+=2)
2617 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
2618 SetPixelRed(q,pixel == 0 ? 0 : QuantumRange);
2619 SetPixelGreen(q,GetPixelRed(q));
2620 SetPixelBlue(q,GetPixelRed(q));
2621 SetPixelOpacity(q,((*p) & (1UL << (
unsigned char) (6-bit))) == 0 ?
2622 TransparentOpacity : OpaqueOpacity);
2627 if ((number_pixels % 4) != 0)
2628 for (bit=3; bit >= (ssize_t) (4-(number_pixels % 4)); bit-=2)
2630 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
2631 SetPixelRed(q,pixel != 0 ? 0 : QuantumRange);
2632 SetPixelGreen(q,GetPixelRed(q));
2633 SetPixelBlue(q,GetPixelRed(q));
2634 SetPixelOpacity(q,((*p) & (1UL << (
unsigned char) (6-bit))) == 0 ?
2635 TransparentOpacity : OpaqueOpacity);
2647 range=GetQuantumRange(quantum_info->depth);
2648 for (x=0; x < (ssize_t) number_pixels; x++)
2650 pixel=(
unsigned char) ((*p >> 4) & 0xf);
2651 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2652 SetPixelGreen(q,GetPixelRed(q));
2653 SetPixelBlue(q,GetPixelRed(q));
2654 pixel=(
unsigned char) ((*p) & 0xf);
2655 SetPixelAlpha(q,ScaleAnyToQuantum(pixel,range));
2666 for (x=0; x < (ssize_t) number_pixels; x++)
2668 p=PushCharPixel(p,&pixel);
2669 SetPixelRed(q,ScaleCharToQuantum(pixel));
2670 SetPixelGreen(q,GetPixelRed(q));
2671 SetPixelBlue(q,GetPixelRed(q));
2672 p=PushCharPixel(p,&pixel);
2673 SetPixelAlpha(q,ScaleCharToQuantum(pixel));
2674 p+=quantum_info->pad;
2681 range=GetQuantumRange(quantum_info->depth);
2682 for (x=0; x < (ssize_t) number_pixels; x++)
2684 p=PushQuantumPixel(quantum_info,p,&pixel);
2685 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2686 SetPixelGreen(q,GetPixelRed(q));
2687 SetPixelBlue(q,GetPixelRed(q));
2688 p=PushQuantumPixel(quantum_info,p,&pixel);
2689 SetPixelOpacity(q,ScaleAnyToQuantum(pixel,range));
2690 p+=quantum_info->pad;
2697 range=GetQuantumRange(quantum_info->depth);
2698 for (x=0; x < (ssize_t) number_pixels; x++)
2700 p=PushQuantumPixel(quantum_info,p,&pixel);
2701 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2702 SetPixelGreen(q,GetPixelRed(q));
2703 SetPixelBlue(q,GetPixelRed(q));
2704 p=PushQuantumPixel(quantum_info,p,&pixel);
2705 SetPixelOpacity(q,ScaleAnyToQuantum(pixel,range));
2706 p+=quantum_info->pad;
2716 if (quantum_info->format == FloatingPointQuantumFormat)
2718 for (x=0; x < (ssize_t) number_pixels; x++)
2720 p=PushShortPixel(quantum_info->endian,p,&pixel);
2721 SetPixelRed(q,ClampToQuantum((MagickRealType) QuantumRange*
2722 HalfToSinglePrecision(pixel)));
2723 SetPixelGreen(q,GetPixelRed(q));
2724 SetPixelBlue(q,GetPixelRed(q));
2725 p=PushShortPixel(quantum_info->endian,p,&pixel);
2726 SetPixelAlpha(q,ClampToQuantum((MagickRealType) QuantumRange*
2727 HalfToSinglePrecision(pixel)));
2728 p+=quantum_info->pad;
2733 for (x=0; x < (ssize_t) number_pixels; x++)
2735 p=PushShortPixel(quantum_info->endian,p,&pixel);
2736 SetPixelRed(q,ScaleShortToQuantum(pixel));
2737 SetPixelGreen(q,GetPixelRed(q));
2738 SetPixelBlue(q,GetPixelRed(q));
2739 p=PushShortPixel(quantum_info->endian,p,&pixel);
2740 SetPixelAlpha(q,ScaleShortToQuantum(pixel));
2741 p+=quantum_info->pad;
2748 if (quantum_info->format == FloatingPointQuantumFormat)
2753 for (x=0; x < (ssize_t) number_pixels; x++)
2755 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2756 SetPixelRed(q,ClampToQuantum(pixel));
2757 SetPixelGreen(q,GetPixelRed(q));
2758 SetPixelBlue(q,GetPixelRed(q));
2759 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2760 SetPixelAlpha(q,ClampToQuantum(pixel));
2761 p+=quantum_info->pad;
2766 for (x=0; x < (ssize_t) number_pixels; x++)
2768 p=PushLongPixel(quantum_info->endian,p,&pixel);
2769 SetPixelRed(q,ScaleLongToQuantum(pixel));
2770 SetPixelGreen(q,GetPixelRed(q));
2771 SetPixelBlue(q,GetPixelRed(q));
2772 p=PushLongPixel(quantum_info->endian,p,&pixel);
2773 SetPixelAlpha(q,ScaleLongToQuantum(pixel));
2774 p+=quantum_info->pad;
2781 if (quantum_info->format == FloatingPointQuantumFormat)
2786 for (x=0; x < (ssize_t) number_pixels; x++)
2788 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2789 SetPixelRed(q,ClampToQuantum(pixel));
2790 SetPixelGreen(q,GetPixelRed(q));
2791 SetPixelBlue(q,GetPixelRed(q));
2792 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2793 SetPixelAlpha(q,ClampToQuantum(pixel));
2794 p+=quantum_info->pad;
2802 if (quantum_info->format == FloatingPointQuantumFormat)
2807 for (x=0; x < (ssize_t) number_pixels; x++)
2809 p=PushDoublePixel(quantum_info,p,&pixel);
2810 SetPixelRed(q,ClampToQuantum(pixel));
2811 SetPixelGreen(q,GetPixelRed(q));
2812 SetPixelBlue(q,GetPixelRed(q));
2813 p=PushDoublePixel(quantum_info,p,&pixel);
2814 SetPixelAlpha(q,ClampToQuantum(pixel));
2815 p+=quantum_info->pad;
2826 range=GetQuantumRange(quantum_info->depth);
2827 for (x=0; x < (ssize_t) number_pixels; x++)
2829 p=PushQuantumPixel(quantum_info,p,&pixel);
2830 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2831 SetPixelGreen(q,GetPixelRed(q));
2832 SetPixelBlue(q,GetPixelRed(q));
2833 p=PushQuantumPixel(quantum_info,p,&pixel);
2834 SetPixelAlpha(q,ScaleAnyToQuantum(pixel,range));
2835 p+=quantum_info->pad;
2843 static void ImportGreenQuantum(
QuantumInfo *quantum_info,
2844 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
2853 switch (quantum_info->depth)
2860 for (x=0; x < (ssize_t) number_pixels; x++)
2862 p=PushCharPixel(p,&pixel);
2863 SetPixelGreen(q,ScaleCharToQuantum(pixel));
2864 p+=quantum_info->pad;
2874 if (quantum_info->format == FloatingPointQuantumFormat)
2876 for (x=0; x < (ssize_t) number_pixels; x++)
2878 p=PushShortPixel(quantum_info->endian,p,&pixel);
2879 SetPixelGreen(q,ClampToQuantum((MagickRealType)
2880 QuantumRange*HalfToSinglePrecision(pixel)));
2881 p+=quantum_info->pad;
2886 for (x=0; x < (ssize_t) number_pixels; x++)
2888 p=PushShortPixel(quantum_info->endian,p,&pixel);
2889 SetPixelGreen(q,ScaleShortToQuantum(pixel));
2890 p+=quantum_info->pad;
2897 if (quantum_info->format == FloatingPointQuantumFormat)
2902 for (x=0; x < (ssize_t) number_pixels; x++)
2904 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2905 SetPixelGreen(q,ClampToQuantum(pixel));
2906 p+=quantum_info->pad;
2911 for (x=0; x < (ssize_t) number_pixels; x++)
2913 p=PushLongPixel(quantum_info->endian,p,&pixel);
2914 SetPixelGreen(q,ScaleLongToQuantum(pixel));
2915 p+=quantum_info->pad;
2922 if (quantum_info->format == FloatingPointQuantumFormat)
2927 for (x=0; x < (ssize_t) number_pixels; x++)
2929 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2930 SetPixelGreen(q,ClampToQuantum(pixel));
2931 p+=quantum_info->pad;
2939 if (quantum_info->format == FloatingPointQuantumFormat)
2944 for (x=0; x < (ssize_t) number_pixels; x++)
2946 p=PushDoublePixel(quantum_info,p,&pixel);
2947 SetPixelGreen(q,ClampToQuantum(pixel));
2948 p+=quantum_info->pad;
2959 range=GetQuantumRange(quantum_info->depth);
2960 for (x=0; x < (ssize_t) number_pixels; x++)
2962 p=PushQuantumPixel(quantum_info,p,&pixel);
2963 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
2964 p+=quantum_info->pad;
2972 static void ImportIndexQuantum(
const Image *image,
QuantumInfo *quantum_info,
2973 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
2974 PixelPacket *magick_restrict q,IndexPacket *magick_restrict indexes,
2989 if (image->storage_class != PseudoClass)
2991 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
2992 "ColormappedImageRequired",
"`%s'",image->filename);
2995 range_exception=MagickFalse;
2996 switch (quantum_info->depth)
3003 for (x=0; x < ((ssize_t) number_pixels-7); x+=8)
3005 for (bit=0; bit < 8; bit++)
3007 if (quantum_info->min_is_white == MagickFalse)
3008 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) == 0 ? 0x00 : 0x01);
3010 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
3011 SetPixelIndex(indexes+x+bit,PushColormapIndex(image,pixel,
3013 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(
3019 for (bit=0; bit < (ssize_t) (number_pixels % 8); bit++)
3021 if (quantum_info->min_is_white == MagickFalse)
3022 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) == 0 ? 0x00 : 0x01);
3024 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
3025 SetPixelIndex(indexes+x+bit,PushColormapIndex(image,pixel,
3027 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x+bit));
3037 for (x=0; x < ((ssize_t) number_pixels-1); x+=2)
3039 pixel=(
unsigned char) ((*p >> 4) & 0xf);
3040 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3042 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3044 pixel=(
unsigned char) ((*p) & 0xf);
3045 SetPixelIndex(indexes+x+1,PushColormapIndex(image,pixel,
3047 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x+1));
3051 for (bit=0; bit < (ssize_t) (number_pixels % 2); bit++)
3053 pixel=(
unsigned char) ((*p++ >> 4) & 0xf);
3054 SetPixelIndex(indexes+x+bit,PushColormapIndex(image,pixel,
3056 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x+bit));
3066 for (x=0; x < (ssize_t) number_pixels; x++)
3068 p=PushCharPixel(p,&pixel);
3069 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3071 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3072 p+=quantum_info->pad;
3082 if (quantum_info->format == FloatingPointQuantumFormat)
3084 for (x=0; x < (ssize_t) number_pixels; x++)
3086 p=PushShortPixel(quantum_info->endian,p,&pixel);
3087 SetPixelIndex(indexes+x,PushColormapIndex(image,(
size_t)
3088 ClampToQuantum((MagickRealType) QuantumRange*
3089 HalfToSinglePrecision(pixel)),&range_exception));
3090 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3091 p+=quantum_info->pad;
3096 for (x=0; x < (ssize_t) number_pixels; x++)
3098 p=PushShortPixel(quantum_info->endian,p,&pixel);
3099 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3101 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3102 p+=quantum_info->pad;
3109 if (quantum_info->format == FloatingPointQuantumFormat)
3114 for (x=0; x < (ssize_t) number_pixels; x++)
3116 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3117 SetPixelIndex(indexes+x,PushColormapIndex(image,(
size_t)
3118 ClampToQuantum(pixel),&range_exception));
3119 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3120 p+=quantum_info->pad;
3125 for (x=0; x < (ssize_t) number_pixels; x++)
3127 p=PushLongPixel(quantum_info->endian,p,&pixel);
3128 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3130 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3131 p+=quantum_info->pad;
3138 if (quantum_info->format == FloatingPointQuantumFormat)
3143 for (x=0; x < (ssize_t) number_pixels; x++)
3145 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3146 SetPixelIndex(indexes+x,PushColormapIndex(image,(
size_t)
3147 ClampToQuantum(pixel),&range_exception));
3148 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3149 p+=quantum_info->pad;
3157 if (quantum_info->format == FloatingPointQuantumFormat)
3162 for (x=0; x < (ssize_t) number_pixels; x++)
3164 p=PushDoublePixel(quantum_info,p,&pixel);
3165 SetPixelIndex(indexes+x,PushColormapIndex(image,(
size_t)
3166 ClampToQuantum(pixel),&range_exception));
3167 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3168 p+=quantum_info->pad;
3176 for (x=0; x < (ssize_t) number_pixels; x++)
3178 p=PushQuantumPixel(quantum_info,p,&pixel);
3179 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3181 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3182 p+=quantum_info->pad;
3188 if (range_exception != MagickFalse)
3189 (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError,
3190 "InvalidColormapIndex",
"`%s'",image->filename);
3193 static void ImportIndexAlphaQuantum(
const Image *image,
3194 QuantumInfo *quantum_info,
const MagickSizeType number_pixels,
3195 const unsigned char *magick_restrict p,
PixelPacket *magick_restrict q,
3196 IndexPacket *magick_restrict indexes,
ExceptionInfo *exception)
3213 if (image->storage_class != PseudoClass)
3215 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
3216 "ColormappedImageRequired",
"`%s'",image->filename);
3219 range_exception=MagickFalse;
3220 switch (quantum_info->depth)
3227 for (x=((ssize_t) number_pixels-3); x > 0; x-=4)
3229 for (bit=0; bit < 8; bit+=2)
3231 if (quantum_info->min_is_white == MagickFalse)
3232 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) == 0 ? 0x00 : 0x01);
3234 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
3235 SetPixelIndex(indexes+x+bit/2,pixel == 0 ? 0 : 1);
3236 SetPixelRed(q,pixel == 0 ? 0 : QuantumRange);
3237 SetPixelGreen(q,GetPixelRed(q));
3238 SetPixelBlue(q,GetPixelRed(q));
3239 SetPixelOpacity(q,((*p) & (1UL << (
unsigned char) (6-bit))) == 0 ?
3240 TransparentOpacity : OpaqueOpacity);
3244 if ((number_pixels % 4) != 0)
3245 for (bit=0; bit < (ssize_t) (number_pixels % 4); bit+=2)
3247 if (quantum_info->min_is_white == MagickFalse)
3248 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) == 0 ? 0x00 : 0x01);
3250 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
3251 SetPixelIndex(indexes+x+bit/2,pixel == 0 ? 0 : 1);
3252 SetPixelRed(q,pixel == 0 ? 0 : QuantumRange);
3253 SetPixelGreen(q,GetPixelRed(q));
3254 SetPixelBlue(q,GetPixelRed(q));
3255 SetPixelOpacity(q,((*p) & (1UL << (
unsigned char) (6-bit))) == 0 ?
3256 TransparentOpacity : OpaqueOpacity);
3266 range=GetQuantumRange(quantum_info->depth);
3267 for (x=0; x < (ssize_t) number_pixels; x++)
3269 pixel=(
unsigned char) ((*p >> 4) & 0xf);
3270 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3272 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3273 pixel=(
unsigned char) ((*p) & 0xf);
3274 SetPixelAlpha(q,ScaleAnyToQuantum(pixel,range));
3285 for (x=0; x < (ssize_t) number_pixels; x++)
3287 p=PushCharPixel(p,&pixel);
3288 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3290 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3291 p=PushCharPixel(p,&pixel);
3292 SetPixelAlpha(q,ScaleCharToQuantum(pixel));
3293 p+=quantum_info->pad;
3303 if (quantum_info->format == FloatingPointQuantumFormat)
3305 for (x=0; x < (ssize_t) number_pixels; x++)
3307 p=PushShortPixel(quantum_info->endian,p,&pixel);
3308 SetPixelIndex(indexes+x,PushColormapIndex(image,(
size_t)
3309 ClampToQuantum((MagickRealType) QuantumRange*
3310 HalfToSinglePrecision(pixel)),&range_exception));
3311 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3312 p=PushShortPixel(quantum_info->endian,p,&pixel);
3313 SetPixelAlpha(q,ClampToQuantum((MagickRealType) QuantumRange*
3314 HalfToSinglePrecision(pixel)));
3315 p+=quantum_info->pad;
3320 for (x=0; x < (ssize_t) number_pixels; x++)
3322 p=PushShortPixel(quantum_info->endian,p,&pixel);
3323 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3325 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3326 p=PushShortPixel(quantum_info->endian,p,&pixel);
3327 SetPixelAlpha(q,ScaleShortToQuantum(pixel));
3328 p+=quantum_info->pad;
3335 if (quantum_info->format == FloatingPointQuantumFormat)
3340 for (x=0; x < (ssize_t) number_pixels; x++)
3342 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3343 SetPixelIndex(indexes+x,PushColormapIndex(image,(
size_t)
3344 ClampToQuantum(pixel),&range_exception));
3345 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3346 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3347 SetPixelAlpha(q,ClampToQuantum(pixel));
3348 p+=quantum_info->pad;
3353 for (x=0; x < (ssize_t) number_pixels; x++)
3355 p=PushLongPixel(quantum_info->endian,p,&pixel);
3356 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3358 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3359 p=PushLongPixel(quantum_info->endian,p,&pixel);
3360 SetPixelAlpha(q,ScaleLongToQuantum(pixel));
3361 p+=quantum_info->pad;
3368 if (quantum_info->format == FloatingPointQuantumFormat)
3373 for (x=0; x < (ssize_t) number_pixels; x++)
3375 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3376 SetPixelIndex(indexes+x,PushColormapIndex(image,(
size_t)
3377 ClampToQuantum(pixel),&range_exception));
3378 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3379 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3380 SetPixelAlpha(q,ClampToQuantum(pixel));
3381 p+=quantum_info->pad;
3389 if (quantum_info->format == FloatingPointQuantumFormat)
3394 for (x=0; x < (ssize_t) number_pixels; x++)
3396 p=PushDoublePixel(quantum_info,p,&pixel);
3397 SetPixelIndex(indexes+x,PushColormapIndex(image,(
size_t)
3398 ClampToQuantum(pixel),&range_exception));
3399 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3400 p=PushDoublePixel(quantum_info,p,&pixel);
3401 SetPixelAlpha(q,ClampToQuantum(pixel));
3402 p+=quantum_info->pad;
3410 range=GetQuantumRange(quantum_info->depth);
3411 for (x=0; x < (ssize_t) number_pixels; x++)
3413 p=PushQuantumPixel(quantum_info,p,&pixel);
3414 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3416 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3417 p=PushQuantumPixel(quantum_info,p,&pixel);
3418 SetPixelAlpha(q,ScaleAnyToQuantum(pixel,range));
3419 p+=quantum_info->pad;
3425 if (range_exception != MagickFalse)
3426 (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError,
3427 "InvalidColormapIndex",
"`%s'",image->filename);
3430 static void ImportRedQuantum(
QuantumInfo *quantum_info,
3431 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
3440 switch (quantum_info->depth)
3447 for (x=0; x < (ssize_t) number_pixels; x++)
3449 p=PushCharPixel(p,&pixel);
3450 SetPixelRed(q,ScaleCharToQuantum(pixel));
3451 p+=quantum_info->pad;
3461 if (quantum_info->format == FloatingPointQuantumFormat)
3463 for (x=0; x < (ssize_t) number_pixels; x++)
3465 p=PushShortPixel(quantum_info->endian,p,&pixel);
3466 SetPixelRed(q,ClampToQuantum((MagickRealType)
3467 QuantumRange*HalfToSinglePrecision(pixel)));
3468 p+=quantum_info->pad;
3473 for (x=0; x < (ssize_t) number_pixels; x++)
3475 p=PushShortPixel(quantum_info->endian,p,&pixel);
3476 SetPixelRed(q,ScaleShortToQuantum(pixel));
3477 p+=quantum_info->pad;
3484 if (quantum_info->format == FloatingPointQuantumFormat)
3489 for (x=0; x < (ssize_t) number_pixels; x++)
3491 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3492 SetPixelRed(q,ClampToQuantum(pixel));
3493 p+=quantum_info->pad;
3498 for (x=0; x < (ssize_t) number_pixels; x++)
3500 p=PushLongPixel(quantum_info->endian,p,&pixel);
3501 SetPixelRed(q,ScaleLongToQuantum(pixel));
3502 p+=quantum_info->pad;
3509 if (quantum_info->format == FloatingPointQuantumFormat)
3514 for (x=0; x < (ssize_t) number_pixels; x++)
3516 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3517 SetPixelRed(q,ClampToQuantum(pixel));
3518 p+=quantum_info->pad;
3526 if (quantum_info->format == FloatingPointQuantumFormat)
3531 for (x=0; x < (ssize_t) number_pixels; x++)
3533 p=PushDoublePixel(quantum_info,p,&pixel);
3534 SetPixelRed(q,ClampToQuantum(pixel));
3535 p+=quantum_info->pad;
3546 range=GetQuantumRange(quantum_info->depth);
3547 for (x=0; x < (ssize_t) number_pixels; x++)
3549 p=PushQuantumPixel(quantum_info,p,&pixel);
3550 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
3551 p+=quantum_info->pad;
3559 static void ImportRGBQuantum(
QuantumInfo *quantum_info,
3560 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
3575 switch (quantum_info->depth)
3582 for (x=0; x < (ssize_t) number_pixels; x++)
3584 p=PushCharPixel(p,&pixel);
3585 SetPixelRed(q,ScaleCharToQuantum(pixel));
3586 p=PushCharPixel(p,&pixel);
3587 SetPixelGreen(q,ScaleCharToQuantum(pixel));
3588 p=PushCharPixel(p,&pixel);
3589 SetPixelBlue(q,ScaleCharToQuantum(pixel));
3590 SetPixelOpacity(q,OpaqueOpacity);
3591 p+=quantum_info->pad;
3598 range=GetQuantumRange(quantum_info->depth);
3599 if (quantum_info->pack == MagickFalse)
3601 for (x=0; x < (ssize_t) number_pixels; x++)
3603 p=PushLongPixel(quantum_info->endian,p,&pixel);
3604 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range));
3605 SetPixelGreen(q,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range));
3606 SetPixelBlue(q,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range));
3607 p+=quantum_info->pad;
3612 if (quantum_info->quantum == 32U)
3614 for (x=0; x < (ssize_t) number_pixels; x++)
3616 p=PushQuantumLongPixel(quantum_info,p,&pixel);
3617 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
3618 p=PushQuantumLongPixel(quantum_info,p,&pixel);
3619 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
3620 p=PushQuantumLongPixel(quantum_info,p,&pixel);
3621 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
3626 for (x=0; x < (ssize_t) number_pixels; x++)
3628 p=PushQuantumPixel(quantum_info,p,&pixel);
3629 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
3630 p=PushQuantumPixel(quantum_info,p,&pixel);
3631 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
3632 p=PushQuantumPixel(quantum_info,p,&pixel);
3633 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
3640 range=GetQuantumRange(quantum_info->depth);
3641 if (quantum_info->pack == MagickFalse)
3646 for (x=0; x < (ssize_t) (3*number_pixels-1); x+=2)
3648 p=PushShortPixel(quantum_info->endian,p,&pixel);
3654 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3660 SetPixelGreen(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3666 SetPixelBlue(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3672 p=PushShortPixel(quantum_info->endian,p,&pixel);
3678 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3684 SetPixelGreen(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3690 SetPixelBlue(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3696 p+=quantum_info->pad;
3698 for (bit=0; bit < (ssize_t) (3*number_pixels % 2); bit++)
3700 p=PushShortPixel(quantum_info->endian,p,&pixel);
3701 switch ((x+bit) % 3)
3706 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3712 SetPixelGreen(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3718 SetPixelBlue(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3724 p+=quantum_info->pad;
3730 if (quantum_info->quantum == 32U)
3732 for (x=0; x < (ssize_t) number_pixels; x++)
3734 p=PushQuantumLongPixel(quantum_info,p,&pixel);
3735 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
3736 p=PushQuantumLongPixel(quantum_info,p,&pixel);
3737 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
3738 p=PushQuantumLongPixel(quantum_info,p,&pixel);
3739 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
3744 for (x=0; x < (ssize_t) number_pixels; x++)
3746 p=PushQuantumPixel(quantum_info,p,&pixel);
3747 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
3748 p=PushQuantumPixel(quantum_info,p,&pixel);
3749 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
3750 p=PushQuantumPixel(quantum_info,p,&pixel);
3751 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
3761 if (quantum_info->format == FloatingPointQuantumFormat)
3763 for (x=0; x < (ssize_t) number_pixels; x++)
3765 p=PushShortPixel(quantum_info->endian,p,&pixel);
3766 SetPixelRed(q,ClampToQuantum((MagickRealType) QuantumRange*
3767 HalfToSinglePrecision(pixel)));
3768 p=PushShortPixel(quantum_info->endian,p,&pixel);
3769 SetPixelGreen(q,ClampToQuantum((MagickRealType) QuantumRange*
3770 HalfToSinglePrecision(pixel)));
3771 p=PushShortPixel(quantum_info->endian,p,&pixel);
3772 SetPixelBlue(q,ClampToQuantum((MagickRealType) QuantumRange*
3773 HalfToSinglePrecision(pixel)));
3774 p+=quantum_info->pad;
3779 for (x=0; x < (ssize_t) number_pixels; x++)
3781 p=PushShortPixel(quantum_info->endian,p,&pixel);
3782 SetPixelRed(q,ScaleShortToQuantum(pixel));
3783 p=PushShortPixel(quantum_info->endian,p,&pixel);
3784 SetPixelGreen(q,ScaleShortToQuantum(pixel));
3785 p=PushShortPixel(quantum_info->endian,p,&pixel);
3786 SetPixelBlue(q,ScaleShortToQuantum(pixel));
3787 p+=quantum_info->pad;
3794 if (quantum_info->format == FloatingPointQuantumFormat)
3799 for (x=0; x < (ssize_t) number_pixels; x++)
3801 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3802 SetPixelRed(q,ClampToQuantum(pixel));
3803 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3804 SetPixelGreen(q,ClampToQuantum(pixel));
3805 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3806 SetPixelBlue(q,ClampToQuantum(pixel));
3807 p+=quantum_info->pad;
3812 for (x=0; x < (ssize_t) number_pixels; x++)
3814 p=PushLongPixel(quantum_info->endian,p,&pixel);
3815 SetPixelRed(q,ScaleLongToQuantum(pixel));
3816 p=PushLongPixel(quantum_info->endian,p,&pixel);
3817 SetPixelGreen(q,ScaleLongToQuantum(pixel));
3818 p=PushLongPixel(quantum_info->endian,p,&pixel);
3819 SetPixelBlue(q,ScaleLongToQuantum(pixel));
3820 p+=quantum_info->pad;
3827 if (quantum_info->format == FloatingPointQuantumFormat)
3832 for (x=0; x < (ssize_t) number_pixels; x++)
3834 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3835 SetPixelRed(q,ClampToQuantum(pixel));
3836 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3837 SetPixelGreen(q,ClampToQuantum(pixel));
3838 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3839 SetPixelBlue(q,ClampToQuantum(pixel));
3840 p+=quantum_info->pad;
3848 if (quantum_info->format == FloatingPointQuantumFormat)
3853 for (x=0; x < (ssize_t) number_pixels; x++)
3855 p=PushDoublePixel(quantum_info,p,&pixel);
3856 SetPixelRed(q,ClampToQuantum(pixel));
3857 p=PushDoublePixel(quantum_info,p,&pixel);
3858 SetPixelGreen(q,ClampToQuantum(pixel));
3859 p=PushDoublePixel(quantum_info,p,&pixel);
3860 SetPixelBlue(q,ClampToQuantum(pixel));
3861 p+=quantum_info->pad;
3869 range=GetQuantumRange(quantum_info->depth);
3870 for (x=0; x < (ssize_t) number_pixels; x++)
3872 p=PushQuantumPixel(quantum_info,p,&pixel);
3873 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
3874 p=PushQuantumPixel(quantum_info,p,&pixel);
3875 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
3876 p=PushQuantumPixel(quantum_info,p,&pixel);
3877 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
3885 static void ImportRGBAQuantum(
QuantumInfo *quantum_info,
3886 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
3898 switch (quantum_info->depth)
3905 for (x=0; x < (ssize_t) number_pixels; x++)
3907 p=PushCharPixel(p,&pixel);
3908 SetPixelRed(q,ScaleCharToQuantum(pixel));
3909 p=PushCharPixel(p,&pixel);
3910 SetPixelGreen(q,ScaleCharToQuantum(pixel));
3911 p=PushCharPixel(p,&pixel);
3912 SetPixelBlue(q,ScaleCharToQuantum(pixel));
3913 p=PushCharPixel(p,&pixel);
3914 SetPixelAlpha(q,ScaleCharToQuantum(pixel));
3915 p+=quantum_info->pad;
3923 if (quantum_info->pack == MagickFalse)
3936 for (x=0; x < (ssize_t) number_pixels; x++)
3938 for (i=0; i < 4; i++)
3944 p=PushLongPixel(quantum_info->endian,p,&pixel);
3945 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
3946 (((pixel >> 22) & 0x3ff) << 6)));
3951 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
3952 (((pixel >> 12) & 0x3ff) << 6)));
3957 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
3958 (((pixel >> 2) & 0x3ff) << 6)));
3964 case 0: SetPixelRed(q,quantum);
break;
3965 case 1: SetPixelGreen(q,quantum);
break;
3966 case 2: SetPixelBlue(q,quantum);
break;
3967 case 3: SetPixelAlpha(q,quantum);
break;
3971 p+=quantum_info->pad;
3976 for (x=0; x < (ssize_t) number_pixels; x++)
3978 p=PushQuantumPixel(quantum_info,p,&pixel);
3979 SetPixelRed(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
3980 p=PushQuantumPixel(quantum_info,p,&pixel);
3981 SetPixelGreen(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
3982 p=PushQuantumPixel(quantum_info,p,&pixel);
3983 SetPixelBlue(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
3984 p=PushQuantumPixel(quantum_info,p,&pixel);
3985 SetPixelAlpha(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
3995 if (quantum_info->format == FloatingPointQuantumFormat)
3997 for (x=0; x < (ssize_t) number_pixels; x++)
3999 p=PushShortPixel(quantum_info->endian,p,&pixel);
4000 SetPixelRed(q,ClampToQuantum((MagickRealType) QuantumRange*
4001 HalfToSinglePrecision(pixel)));
4002 p=PushShortPixel(quantum_info->endian,p,&pixel);
4003 SetPixelGreen(q,ClampToQuantum((MagickRealType) QuantumRange*
4004 HalfToSinglePrecision(pixel)));
4005 p=PushShortPixel(quantum_info->endian,p,&pixel);
4006 SetPixelBlue(q,ClampToQuantum((MagickRealType) QuantumRange*
4007 HalfToSinglePrecision(pixel)));
4008 p=PushShortPixel(quantum_info->endian,p,&pixel);
4009 SetPixelAlpha(q,ClampToQuantum((MagickRealType) QuantumRange*
4010 HalfToSinglePrecision(pixel)));
4011 p+=quantum_info->pad;
4016 for (x=0; x < (ssize_t) number_pixels; x++)
4018 p=PushShortPixel(quantum_info->endian,p,&pixel);
4019 SetPixelRed(q,ScaleShortToQuantum(pixel));
4020 p=PushShortPixel(quantum_info->endian,p,&pixel);
4021 SetPixelGreen(q,ScaleShortToQuantum(pixel));
4022 p=PushShortPixel(quantum_info->endian,p,&pixel);
4023 SetPixelBlue(q,ScaleShortToQuantum(pixel));
4024 p=PushShortPixel(quantum_info->endian,p,&pixel);
4025 SetPixelAlpha(q,ScaleShortToQuantum(pixel));
4026 p+=quantum_info->pad;
4033 if (quantum_info->format == FloatingPointQuantumFormat)
4038 for (x=0; x < (ssize_t) number_pixels; x++)
4040 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4041 SetPixelRed(q,ClampToQuantum(pixel));
4042 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4043 SetPixelGreen(q,ClampToQuantum(pixel));
4044 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4045 SetPixelBlue(q,ClampToQuantum(pixel));
4046 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4047 SetPixelAlpha(q,ClampToQuantum(pixel));
4048 p+=quantum_info->pad;
4053 for (x=0; x < (ssize_t) number_pixels; x++)
4055 p=PushLongPixel(quantum_info->endian,p,&pixel);
4056 SetPixelRed(q,ScaleLongToQuantum(pixel));
4057 p=PushLongPixel(quantum_info->endian,p,&pixel);
4058 SetPixelGreen(q,ScaleLongToQuantum(pixel));
4059 p=PushLongPixel(quantum_info->endian,p,&pixel);
4060 SetPixelBlue(q,ScaleLongToQuantum(pixel));
4061 p=PushLongPixel(quantum_info->endian,p,&pixel);
4062 SetPixelAlpha(q,ScaleLongToQuantum(pixel));
4063 p+=quantum_info->pad;
4070 if (quantum_info->format == FloatingPointQuantumFormat)
4075 for (x=0; x < (ssize_t) number_pixels; x++)
4077 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4078 SetPixelRed(q,ClampToQuantum(pixel));
4079 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4080 SetPixelGreen(q,ClampToQuantum(pixel));
4081 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4082 SetPixelBlue(q,ClampToQuantum(pixel));
4083 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4084 SetPixelAlpha(q,ClampToQuantum(pixel));
4085 p+=quantum_info->pad;
4093 if (quantum_info->format == FloatingPointQuantumFormat)
4098 for (x=0; x < (ssize_t) number_pixels; x++)
4100 p=PushDoublePixel(quantum_info,p,&pixel);
4101 SetPixelRed(q,ClampToQuantum(pixel));
4102 p=PushDoublePixel(quantum_info,p,&pixel);
4103 SetPixelGreen(q,ClampToQuantum(pixel));
4104 p=PushDoublePixel(quantum_info,p,&pixel);
4105 SetPixelBlue(q,ClampToQuantum(pixel));
4106 p=PushDoublePixel(quantum_info,p,&pixel);
4107 SetPixelAlpha(q,ClampToQuantum(pixel));
4108 p+=quantum_info->pad;
4116 range=GetQuantumRange(quantum_info->depth);
4117 for (x=0; x < (ssize_t) number_pixels; x++)
4119 p=PushQuantumPixel(quantum_info,p,&pixel);
4120 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
4121 p=PushQuantumPixel(quantum_info,p,&pixel);
4122 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
4123 p=PushQuantumPixel(quantum_info,p,&pixel);
4124 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
4125 p=PushQuantumPixel(quantum_info,p,&pixel);
4126 SetPixelAlpha(q,ScaleAnyToQuantum(pixel,range));
4134 static void ImportRGBOQuantum(
QuantumInfo *quantum_info,
4135 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
4147 switch (quantum_info->depth)
4154 for (x=0; x < (ssize_t) number_pixels; x++)
4156 p=PushCharPixel(p,&pixel);
4157 SetPixelRed(q,ScaleCharToQuantum(pixel));
4158 p=PushCharPixel(p,&pixel);
4159 SetPixelGreen(q,ScaleCharToQuantum(pixel));
4160 p=PushCharPixel(p,&pixel);
4161 SetPixelBlue(q,ScaleCharToQuantum(pixel));
4162 p=PushCharPixel(p,&pixel);
4163 SetPixelOpacity(q,ScaleCharToQuantum(pixel));
4164 p+=quantum_info->pad;
4172 if (quantum_info->pack == MagickFalse)
4185 for (x=0; x < (ssize_t) number_pixels; x++)
4187 for (i=0; i < 4; i++)
4193 p=PushLongPixel(quantum_info->endian,p,&pixel);
4194 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
4195 (((pixel >> 22) & 0x3ff) << 6)));
4200 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
4201 (((pixel >> 12) & 0x3ff) << 6)));
4206 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
4207 (((pixel >> 2) & 0x3ff) << 6)));
4213 case 0: SetPixelRed(q,quantum);
break;
4214 case 1: SetPixelGreen(q,quantum);
break;
4215 case 2: SetPixelBlue(q,quantum);
break;
4216 case 3: SetPixelOpacity(q,quantum);
break;
4220 p+=quantum_info->pad;
4225 for (x=0; x < (ssize_t) number_pixels; x++)
4227 p=PushQuantumPixel(quantum_info,p,&pixel);
4228 SetPixelRed(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
4229 p=PushQuantumPixel(quantum_info,p,&pixel);
4230 SetPixelGreen(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
4231 p=PushQuantumPixel(quantum_info,p,&pixel);
4232 SetPixelBlue(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
4233 p=PushQuantumPixel(quantum_info,p,&pixel);
4234 SetPixelOpacity(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
4244 if (quantum_info->format == FloatingPointQuantumFormat)
4246 for (x=0; x < (ssize_t) number_pixels; x++)
4248 p=PushShortPixel(quantum_info->endian,p,&pixel);
4249 SetPixelRed(q,ClampToQuantum((MagickRealType) QuantumRange*
4250 HalfToSinglePrecision(pixel)));
4251 p=PushShortPixel(quantum_info->endian,p,&pixel);
4252 SetPixelGreen(q,ClampToQuantum((MagickRealType) QuantumRange*
4253 HalfToSinglePrecision(pixel)));
4254 p=PushShortPixel(quantum_info->endian,p,&pixel);
4255 SetPixelBlue(q,ClampToQuantum((MagickRealType) QuantumRange*
4256 HalfToSinglePrecision(pixel)));
4257 p=PushShortPixel(quantum_info->endian,p,&pixel);
4258 SetPixelOpacity(q,ClampToQuantum((MagickRealType) QuantumRange*
4259 HalfToSinglePrecision(pixel)));
4260 p+=quantum_info->pad;
4265 for (x=0; x < (ssize_t) number_pixels; x++)
4267 p=PushShortPixel(quantum_info->endian,p,&pixel);
4268 SetPixelRed(q,ScaleShortToQuantum(pixel));
4269 p=PushShortPixel(quantum_info->endian,p,&pixel);
4270 SetPixelGreen(q,ScaleShortToQuantum(pixel));
4271 p=PushShortPixel(quantum_info->endian,p,&pixel);
4272 SetPixelBlue(q,ScaleShortToQuantum(pixel));
4273 p=PushShortPixel(quantum_info->endian,p,&pixel);
4274 SetPixelOpacity(q,ScaleShortToQuantum(pixel));
4275 p+=quantum_info->pad;
4282 if (quantum_info->format == FloatingPointQuantumFormat)
4287 for (x=0; x < (ssize_t) number_pixels; x++)
4289 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4290 SetPixelRed(q,ClampToQuantum(pixel));
4291 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4292 SetPixelGreen(q,ClampToQuantum(pixel));
4293 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4294 SetPixelBlue(q,ClampToQuantum(pixel));
4295 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4296 SetPixelOpacity(q,ClampToQuantum(pixel));
4297 p+=quantum_info->pad;
4302 for (x=0; x < (ssize_t) number_pixels; x++)
4304 p=PushLongPixel(quantum_info->endian,p,&pixel);
4305 SetPixelRed(q,ScaleLongToQuantum(pixel));
4306 p=PushLongPixel(quantum_info->endian,p,&pixel);
4307 SetPixelGreen(q,ScaleLongToQuantum(pixel));
4308 p=PushLongPixel(quantum_info->endian,p,&pixel);
4309 SetPixelBlue(q,ScaleLongToQuantum(pixel));
4310 p=PushLongPixel(quantum_info->endian,p,&pixel);
4311 SetPixelOpacity(q,ScaleLongToQuantum(pixel));
4312 p+=quantum_info->pad;
4319 if (quantum_info->format == FloatingPointQuantumFormat)
4324 for (x=0; x < (ssize_t) number_pixels; x++)
4326 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4327 SetPixelRed(q,ClampToQuantum(pixel));
4328 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4329 SetPixelGreen(q,ClampToQuantum(pixel));
4330 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4331 SetPixelBlue(q,ClampToQuantum(pixel));
4332 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4333 SetPixelOpacity(q,ClampToQuantum(pixel));
4334 p+=quantum_info->pad;
4342 if (quantum_info->format == FloatingPointQuantumFormat)
4347 for (x=0; x < (ssize_t) number_pixels; x++)
4349 p=PushDoublePixel(quantum_info,p,&pixel);
4350 SetPixelRed(q,ClampToQuantum(pixel));
4351 p=PushDoublePixel(quantum_info,p,&pixel);
4352 SetPixelGreen(q,ClampToQuantum(pixel));
4353 p=PushDoublePixel(quantum_info,p,&pixel);
4354 SetPixelBlue(q,ClampToQuantum(pixel));
4355 p=PushDoublePixel(quantum_info,p,&pixel);
4356 SetPixelOpacity(q,ClampToQuantum(pixel));
4357 p+=quantum_info->pad;
4365 range=GetQuantumRange(quantum_info->depth);
4366 for (x=0; x < (ssize_t) number_pixels; x++)
4368 p=PushQuantumPixel(quantum_info,p,&pixel);
4369 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
4370 p=PushQuantumPixel(quantum_info,p,&pixel);
4371 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
4372 p=PushQuantumPixel(quantum_info,p,&pixel);
4373 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
4374 p=PushQuantumPixel(quantum_info,p,&pixel);
4375 SetPixelOpacity(q,ScaleAnyToQuantum(pixel,range));
4383 MagickExport
size_t ImportQuantumPixels(
Image *image,
CacheView *image_view,
4384 const QuantumInfo *quantum_info,
const QuantumType quantum_type,
4385 const unsigned char *magick_restrict pixels,
ExceptionInfo *exception)
4394 *magick_restrict indexes;
4405 assert(image != (
Image *) NULL);
4406 assert(image->signature == MagickCoreSignature);
4408 assert(quantum_info->signature == MagickCoreSignature);
4409 if (IsEventLogging() != MagickFalse)
4410 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
4411 if (pixels == (
const unsigned char *) NULL)
4412 pixels=GetQuantumPixels(quantum_info);
4417 number_pixels=GetImageExtent(image);
4418 q=GetAuthenticPixelQueue(image);
4419 indexes=GetAuthenticIndexQueue(image);
4423 number_pixels=GetCacheViewExtent(image_view);
4424 q=GetCacheViewAuthenticPixelQueue(image_view);
4425 indexes=GetCacheViewAuthenticIndexQueue(image_view);
4428 extent=GetQuantumExtent(image,quantum_info,quantum_type);
4429 switch (quantum_type)
4433 ImportAlphaQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4438 ImportBGRQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4443 ImportBGRAQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4448 ImportBGROQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4453 ImportBlackQuantum(image,(
QuantumInfo *) quantum_info,number_pixels,p,q,
4460 ImportBlueQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4465 ImportCbYCrYQuantum(image,(
QuantumInfo *) quantum_info,number_pixels,p,
4471 ImportCMYKQuantum(image,(
QuantumInfo *) quantum_info,number_pixels,p,q,
4477 ImportCMYKAQuantum(image,(
QuantumInfo *) quantum_info,number_pixels,p,q,
4483 ImportCMYKOQuantum(image,(
QuantumInfo *) quantum_info,number_pixels,p,q,
4489 ImportGrayQuantum(image,(
QuantumInfo *) quantum_info,number_pixels,p,q);
4492 case GrayAlphaQuantum:
4494 ImportGrayAlphaQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4498 case MagentaQuantum:
4500 ImportGreenQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4505 ImportIndexQuantum(image,(
QuantumInfo *) quantum_info,number_pixels,p,q,
4509 case IndexAlphaQuantum:
4511 ImportIndexAlphaQuantum(image,(
QuantumInfo *) quantum_info,number_pixels,
4512 p,q,indexes,exception);
4518 ImportRedQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4524 ImportRGBQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4530 ImportRGBAQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4535 ImportRGBOQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4541 if ((quantum_type == CbYCrQuantum) || (quantum_type == CbYCrAQuantum))
4549 q=GetAuthenticPixelQueue(image);
4551 q=GetCacheViewAuthenticPixelQueue(image_view);
4552 for (x=0; x < (ssize_t) number_pixels; x++)
4554 quantum=GetPixelRed(q);
4555 SetPixelRed(q,GetPixelGreen(q));
4556 SetPixelGreen(q,quantum);
4560 if (quantum_info->alpha_type == AssociatedQuantumAlpha)
4571 q=GetAuthenticPixelQueue(image);
4573 q=GetCacheViewAuthenticPixelQueue(image_view);
4574 indexes=GetAuthenticIndexQueue(image);
4575 for (x=0; x < (ssize_t) number_pixels; x++)
4577 alpha=QuantumScale*GetPixelAlpha(q);
4578 alpha=PerceptibleReciprocal(alpha);
4579 SetPixelRed(q,ClampToQuantum(alpha*GetPixelRed(q)));
4580 SetPixelGreen(q,ClampToQuantum(alpha*GetPixelGreen(q)));
4581 SetPixelBlue(q,ClampToQuantum(alpha*GetPixelBlue(q)));
4582 if (image->colorspace == CMYKColorspace)
4583 SetPixelBlack(indexes+x,ClampToQuantum(alpha*GetPixelBlack(