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 if (quantum_bits < 64)
265 *quantum=(
unsigned int) (((MagickSizeType) *quantum << quantum_bits) |
266 ((quantum_info->state.pixel >> quantum_info->state.bits) &~
267 ((~0UL) << quantum_bits)));
272 static inline const unsigned char *PushQuantumLongPixel(
273 QuantumInfo *quantum_info,
const unsigned char *magick_restrict pixels,
274 unsigned int *quantum)
283 for (i=(ssize_t) quantum_info->depth; i > 0; )
285 if (quantum_info->state.bits == 0)
287 pixels=PushLongPixel(quantum_info->endian,pixels,
288 &quantum_info->state.pixel);
289 quantum_info->state.bits=32U;
291 quantum_bits=(size_t) i;
292 if (quantum_bits > quantum_info->state.bits)
293 quantum_bits=quantum_info->state.bits;
294 *quantum|=(((quantum_info->state.pixel >> (32U-quantum_info->state.bits)) &
295 quantum_info->state.mask[quantum_bits]) << (quantum_info->depth-i));
296 i-=(ssize_t) quantum_bits;
297 quantum_info->state.bits-=quantum_bits;
302 static void ImportAlphaQuantum(
QuantumInfo *quantum_info,
303 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
312 switch (quantum_info->depth)
319 for (x=0; x < (ssize_t) number_pixels; x++)
321 p=PushCharPixel(p,&pixel);
322 SetPixelAlpha(q,ScaleCharToQuantum(pixel));
323 p+=quantum_info->pad;
333 if (quantum_info->format == FloatingPointQuantumFormat)
335 for (x=0; x < (ssize_t) number_pixels; x++)
337 p=PushShortPixel(quantum_info->endian,p,&pixel);
338 SetPixelAlpha(q,ClampToQuantum((MagickRealType)
339 QuantumRange*HalfToSinglePrecision(pixel)));
340 p+=quantum_info->pad;
345 for (x=0; x < (ssize_t) number_pixels; x++)
347 p=PushShortPixel(quantum_info->endian,p,&pixel);
348 SetPixelAlpha(q,ScaleShortToQuantum(pixel));
349 p+=quantum_info->pad;
356 if (quantum_info->format == FloatingPointQuantumFormat)
361 for (x=0; x < (ssize_t) number_pixels; x++)
363 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
364 SetPixelAlpha(q,ClampToQuantum(pixel));
365 p+=quantum_info->pad;
370 for (x=0; x < (ssize_t) number_pixels; x++)
372 p=PushLongPixel(quantum_info->endian,p,&pixel);
373 SetPixelAlpha(q,ScaleLongToQuantum(pixel));
374 p+=quantum_info->pad;
381 if (quantum_info->format == FloatingPointQuantumFormat)
386 for (x=0; x < (ssize_t) number_pixels; x++)
388 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
389 SetPixelAlpha(q,ClampToQuantum(pixel));
390 p+=quantum_info->pad;
398 if (quantum_info->format == FloatingPointQuantumFormat)
403 for (x=0; x < (ssize_t) number_pixels; x++)
405 p=PushDoublePixel(quantum_info,p,&pixel);
406 SetPixelAlpha(q,ClampToQuantum(pixel));
407 p+=quantum_info->pad;
418 range=GetQuantumRange(quantum_info->depth);
419 for (x=0; x < (ssize_t) number_pixels; x++)
421 p=PushQuantumPixel(quantum_info,p,&pixel);
422 SetPixelAlpha(q,ScaleAnyToQuantum(pixel,range));
423 p+=quantum_info->pad;
431 static void ImportBGRQuantum(
QuantumInfo *quantum_info,
432 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
447 switch (quantum_info->depth)
454 for (x=0; x < (ssize_t) number_pixels; x++)
456 p=PushCharPixel(p,&pixel);
457 SetPixelBlue(q,ScaleCharToQuantum(pixel));
458 p=PushCharPixel(p,&pixel);
459 SetPixelGreen(q,ScaleCharToQuantum(pixel));
460 p=PushCharPixel(p,&pixel);
461 SetPixelRed(q,ScaleCharToQuantum(pixel));
462 SetPixelOpacity(q,OpaqueOpacity);
463 p+=quantum_info->pad;
470 range=GetQuantumRange(quantum_info->depth);
471 if (quantum_info->pack == MagickFalse)
473 for (x=0; x < (ssize_t) number_pixels; x++)
475 p=PushLongPixel(quantum_info->endian,p,&pixel);
476 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range));
477 SetPixelGreen(q,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range));
478 SetPixelBlue(q,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range));
479 p+=quantum_info->pad;
484 if (quantum_info->quantum == 32U)
486 for (x=0; x < (ssize_t) number_pixels; x++)
488 p=PushQuantumLongPixel(quantum_info,p,&pixel);
489 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
490 p=PushQuantumLongPixel(quantum_info,p,&pixel);
491 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
492 p=PushQuantumLongPixel(quantum_info,p,&pixel);
493 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
498 for (x=0; x < (ssize_t) number_pixels; x++)
500 p=PushQuantumPixel(quantum_info,p,&pixel);
501 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
502 p=PushQuantumPixel(quantum_info,p,&pixel);
503 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
504 p=PushQuantumPixel(quantum_info,p,&pixel);
505 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
512 range=GetQuantumRange(quantum_info->depth);
513 if (quantum_info->pack == MagickFalse)
518 for (x=0; x < (ssize_t) (3*number_pixels-1); x+=2)
520 p=PushShortPixel(quantum_info->endian,p,&pixel);
526 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
532 SetPixelGreen(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
538 SetPixelBlue(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
544 p=PushShortPixel(quantum_info->endian,p,&pixel);
550 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
556 SetPixelGreen(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
562 SetPixelBlue(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
568 p+=quantum_info->pad;
570 for (bit=0; bit < (ssize_t) (3*number_pixels % 2); bit++)
572 p=PushShortPixel(quantum_info->endian,p,&pixel);
578 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
584 SetPixelGreen(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
590 SetPixelBlue(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
596 p+=quantum_info->pad;
602 if (quantum_info->quantum == 32U)
604 for (x=0; x < (ssize_t) number_pixels; x++)
606 p=PushQuantumLongPixel(quantum_info,p,&pixel);
607 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
608 p=PushQuantumLongPixel(quantum_info,p,&pixel);
609 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
610 p=PushQuantumLongPixel(quantum_info,p,&pixel);
611 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
616 for (x=0; x < (ssize_t) number_pixels; x++)
618 p=PushQuantumPixel(quantum_info,p,&pixel);
619 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
620 p=PushQuantumPixel(quantum_info,p,&pixel);
621 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
622 p=PushQuantumPixel(quantum_info,p,&pixel);
623 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
633 if (quantum_info->format == FloatingPointQuantumFormat)
635 for (x=0; x < (ssize_t) number_pixels; x++)
637 p=PushShortPixel(quantum_info->endian,p,&pixel);
638 SetPixelRed(q,ClampToQuantum((MagickRealType) QuantumRange*
639 HalfToSinglePrecision(pixel)));
640 p=PushShortPixel(quantum_info->endian,p,&pixel);
641 SetPixelGreen(q,ClampToQuantum((MagickRealType) QuantumRange*
642 HalfToSinglePrecision(pixel)));
643 p=PushShortPixel(quantum_info->endian,p,&pixel);
644 SetPixelBlue(q,ClampToQuantum((MagickRealType) QuantumRange*
645 HalfToSinglePrecision(pixel)));
646 p+=quantum_info->pad;
651 for (x=0; x < (ssize_t) number_pixels; x++)
653 p=PushShortPixel(quantum_info->endian,p,&pixel);
654 SetPixelBlue(q,ScaleShortToQuantum(pixel));
655 p=PushShortPixel(quantum_info->endian,p,&pixel);
656 SetPixelGreen(q,ScaleShortToQuantum(pixel));
657 p=PushShortPixel(quantum_info->endian,p,&pixel);
658 SetPixelRed(q,ScaleShortToQuantum(pixel));
659 p+=quantum_info->pad;
666 if (quantum_info->format == FloatingPointQuantumFormat)
671 for (x=0; x < (ssize_t) number_pixels; x++)
673 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
674 SetPixelRed(q,ClampToQuantum(pixel));
675 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
676 SetPixelGreen(q,ClampToQuantum(pixel));
677 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
678 SetPixelBlue(q,ClampToQuantum(pixel));
679 p+=quantum_info->pad;
684 for (x=0; x < (ssize_t) number_pixels; x++)
686 p=PushLongPixel(quantum_info->endian,p,&pixel);
687 SetPixelBlue(q,ScaleLongToQuantum(pixel));
688 p=PushLongPixel(quantum_info->endian,p,&pixel);
689 SetPixelGreen(q,ScaleLongToQuantum(pixel));
690 p=PushLongPixel(quantum_info->endian,p,&pixel);
691 SetPixelRed(q,ScaleLongToQuantum(pixel));
692 p+=quantum_info->pad;
699 if (quantum_info->format == FloatingPointQuantumFormat)
704 for (x=0; x < (ssize_t) number_pixels; x++)
706 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
707 SetPixelRed(q,ClampToQuantum(pixel));
708 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
709 SetPixelGreen(q,ClampToQuantum(pixel));
710 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
711 SetPixelBlue(q,ClampToQuantum(pixel));
712 p+=quantum_info->pad;
720 if (quantum_info->format == FloatingPointQuantumFormat)
725 for (x=0; x < (ssize_t) number_pixels; x++)
727 p=PushDoublePixel(quantum_info,p,&pixel);
728 SetPixelRed(q,ClampToQuantum(pixel));
729 p=PushDoublePixel(quantum_info,p,&pixel);
730 SetPixelGreen(q,ClampToQuantum(pixel));
731 p=PushDoublePixel(quantum_info,p,&pixel);
732 SetPixelBlue(q,ClampToQuantum(pixel));
733 p+=quantum_info->pad;
741 range=GetQuantumRange(quantum_info->depth);
742 for (x=0; x < (ssize_t) number_pixels; x++)
744 p=PushQuantumPixel(quantum_info,p,&pixel);
745 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
746 p=PushQuantumPixel(quantum_info,p,&pixel);
747 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
748 p=PushQuantumPixel(quantum_info,p,&pixel);
749 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
757 static void ImportBGRAQuantum(
QuantumInfo *quantum_info,
758 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
770 switch (quantum_info->depth)
777 for (x=0; x < (ssize_t) number_pixels; x++)
779 p=PushCharPixel(p,&pixel);
780 SetPixelBlue(q,ScaleCharToQuantum(pixel));
781 p=PushCharPixel(p,&pixel);
782 SetPixelGreen(q,ScaleCharToQuantum(pixel));
783 p=PushCharPixel(p,&pixel);
784 SetPixelRed(q,ScaleCharToQuantum(pixel));
785 p=PushCharPixel(p,&pixel);
786 SetPixelAlpha(q,ScaleCharToQuantum(pixel));
787 p+=quantum_info->pad;
795 if (quantum_info->pack == MagickFalse)
808 for (x=0; x < (ssize_t) number_pixels; x++)
810 for (i=0; i < 4; i++)
816 p=PushLongPixel(quantum_info->endian,p,&pixel);
817 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
818 (((pixel >> 22) & 0x3ff) << 6)));
823 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
824 (((pixel >> 12) & 0x3ff) << 6)));
829 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
830 (((pixel >> 2) & 0x3ff) << 6)));
836 case 0: SetPixelRed(q,quantum);
break;
837 case 1: SetPixelGreen(q,quantum);
break;
838 case 2: SetPixelBlue(q,quantum);
break;
839 case 3: SetPixelAlpha(q,quantum);
break;
843 p+=quantum_info->pad;
848 for (x=0; x < (ssize_t) number_pixels; x++)
850 p=PushQuantumPixel(quantum_info,p,&pixel);
851 SetPixelRed(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
852 p=PushQuantumPixel(quantum_info,p,&pixel);
853 SetPixelGreen(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
854 p=PushQuantumPixel(quantum_info,p,&pixel);
855 SetPixelBlue(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
856 p=PushQuantumPixel(quantum_info,p,&pixel);
857 SetPixelAlpha(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
867 if (quantum_info->format == FloatingPointQuantumFormat)
869 for (x=0; x < (ssize_t) number_pixels; x++)
871 p=PushShortPixel(quantum_info->endian,p,&pixel);
872 SetPixelRed(q,ClampToQuantum((MagickRealType) QuantumRange*
873 HalfToSinglePrecision(pixel)));
874 p=PushShortPixel(quantum_info->endian,p,&pixel);
875 SetPixelGreen(q,ClampToQuantum((MagickRealType) QuantumRange*
876 HalfToSinglePrecision(pixel)));
877 p=PushShortPixel(quantum_info->endian,p,&pixel);
878 SetPixelBlue(q,ClampToQuantum((MagickRealType) QuantumRange*
879 HalfToSinglePrecision(pixel)));
880 p=PushShortPixel(quantum_info->endian,p,&pixel);
881 SetPixelAlpha(q,ClampToQuantum((MagickRealType) QuantumRange*
882 HalfToSinglePrecision(pixel)));
883 p+=quantum_info->pad;
888 for (x=0; x < (ssize_t) number_pixels; x++)
890 p=PushShortPixel(quantum_info->endian,p,&pixel);
891 SetPixelBlue(q,ScaleShortToQuantum(pixel));
892 p=PushShortPixel(quantum_info->endian,p,&pixel);
893 SetPixelGreen(q,ScaleShortToQuantum(pixel));
894 p=PushShortPixel(quantum_info->endian,p,&pixel);
895 SetPixelRed(q,ScaleShortToQuantum(pixel));
896 p=PushShortPixel(quantum_info->endian,p,&pixel);
897 SetPixelAlpha(q,ScaleShortToQuantum(pixel));
898 p+=quantum_info->pad;
905 if (quantum_info->format == FloatingPointQuantumFormat)
910 for (x=0; x < (ssize_t) number_pixels; x++)
912 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
913 SetPixelRed(q,ClampToQuantum(pixel));
914 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
915 SetPixelGreen(q,ClampToQuantum(pixel));
916 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
917 SetPixelBlue(q,ClampToQuantum(pixel));
918 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
919 SetPixelAlpha(q,ClampToQuantum(pixel));
920 p+=quantum_info->pad;
925 for (x=0; x < (ssize_t) number_pixels; x++)
927 p=PushLongPixel(quantum_info->endian,p,&pixel);
928 SetPixelBlue(q,ScaleLongToQuantum(pixel));
929 p=PushLongPixel(quantum_info->endian,p,&pixel);
930 SetPixelGreen(q,ScaleLongToQuantum(pixel));
931 p=PushLongPixel(quantum_info->endian,p,&pixel);
932 SetPixelRed(q,ScaleLongToQuantum(pixel));
933 p=PushLongPixel(quantum_info->endian,p,&pixel);
934 SetPixelAlpha(q,ScaleLongToQuantum(pixel));
935 p+=quantum_info->pad;
942 if (quantum_info->format == FloatingPointQuantumFormat)
947 for (x=0; x < (ssize_t) number_pixels; x++)
949 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
950 SetPixelRed(q,ClampToQuantum(pixel));
951 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
952 SetPixelGreen(q,ClampToQuantum(pixel));
953 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
954 SetPixelBlue(q,ClampToQuantum(pixel));
955 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
956 SetPixelAlpha(q,ClampToQuantum(pixel));
957 p+=quantum_info->pad;
965 if (quantum_info->format == FloatingPointQuantumFormat)
970 for (x=0; x < (ssize_t) number_pixels; x++)
972 p=PushDoublePixel(quantum_info,p,&pixel);
973 SetPixelRed(q,ClampToQuantum(pixel));
974 p=PushDoublePixel(quantum_info,p,&pixel);
975 SetPixelGreen(q,ClampToQuantum(pixel));
976 p=PushDoublePixel(quantum_info,p,&pixel);
977 SetPixelBlue(q,ClampToQuantum(pixel));
978 p=PushDoublePixel(quantum_info,p,&pixel);
979 SetPixelAlpha(q,ClampToQuantum(pixel));
980 p+=quantum_info->pad;
988 range=GetQuantumRange(quantum_info->depth);
989 for (x=0; x < (ssize_t) number_pixels; x++)
991 p=PushQuantumPixel(quantum_info,p,&pixel);
992 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
993 p=PushQuantumPixel(quantum_info,p,&pixel);
994 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
995 p=PushQuantumPixel(quantum_info,p,&pixel);
996 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
997 p=PushQuantumPixel(quantum_info,p,&pixel);
998 SetPixelAlpha(q,ScaleAnyToQuantum(pixel,range));
1006 static void ImportBGROQuantum(
QuantumInfo *quantum_info,
1007 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
1019 switch (quantum_info->depth)
1026 for (x=0; x < (ssize_t) number_pixels; x++)
1028 p=PushCharPixel(p,&pixel);
1029 SetPixelBlue(q,ScaleCharToQuantum(pixel));
1030 p=PushCharPixel(p,&pixel);
1031 SetPixelGreen(q,ScaleCharToQuantum(pixel));
1032 p=PushCharPixel(p,&pixel);
1033 SetPixelRed(q,ScaleCharToQuantum(pixel));
1034 p=PushCharPixel(p,&pixel);
1035 SetPixelOpacity(q,ScaleCharToQuantum(pixel));
1036 p+=quantum_info->pad;
1044 if (quantum_info->pack == MagickFalse)
1057 for (x=0; x < (ssize_t) number_pixels; x++)
1059 for (i=0; i < 4; i++)
1065 p=PushLongPixel(quantum_info->endian,p,&pixel);
1066 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
1067 (((pixel >> 22) & 0x3ff) << 6)));
1072 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
1073 (((pixel >> 12) & 0x3ff) << 6)));
1078 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
1079 (((pixel >> 2) & 0x3ff) << 6)));
1085 case 0: SetPixelRed(q,quantum);
break;
1086 case 1: SetPixelGreen(q,quantum);
break;
1087 case 2: SetPixelBlue(q,quantum);
break;
1088 case 3: SetPixelOpacity(q,quantum);
break;
1092 p+=quantum_info->pad;
1097 for (x=0; x < (ssize_t) number_pixels; x++)
1099 p=PushQuantumPixel(quantum_info,p,&pixel);
1100 SetPixelRed(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
1101 p=PushQuantumPixel(quantum_info,p,&pixel);
1102 SetPixelGreen(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
1103 p=PushQuantumPixel(quantum_info,p,&pixel);
1104 SetPixelBlue(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
1105 p=PushQuantumPixel(quantum_info,p,&pixel);
1106 SetPixelOpacity(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
1116 if (quantum_info->format == FloatingPointQuantumFormat)
1118 for (x=0; x < (ssize_t) number_pixels; x++)
1120 p=PushShortPixel(quantum_info->endian,p,&pixel);
1121 SetPixelRed(q,ClampToQuantum((MagickRealType) QuantumRange*
1122 HalfToSinglePrecision(pixel)));
1123 p=PushShortPixel(quantum_info->endian,p,&pixel);
1124 SetPixelGreen(q,ClampToQuantum((MagickRealType) QuantumRange*
1125 HalfToSinglePrecision(pixel)));
1126 p=PushShortPixel(quantum_info->endian,p,&pixel);
1127 SetPixelBlue(q,ClampToQuantum((MagickRealType) QuantumRange*
1128 HalfToSinglePrecision(pixel)));
1129 p=PushShortPixel(quantum_info->endian,p,&pixel);
1130 SetPixelOpacity(q,ClampToQuantum((MagickRealType) QuantumRange*
1131 HalfToSinglePrecision(pixel)));
1132 p+=quantum_info->pad;
1137 for (x=0; x < (ssize_t) number_pixels; x++)
1139 p=PushShortPixel(quantum_info->endian,p,&pixel);
1140 SetPixelBlue(q,ScaleShortToQuantum(pixel));
1141 p=PushShortPixel(quantum_info->endian,p,&pixel);
1142 SetPixelGreen(q,ScaleShortToQuantum(pixel));
1143 p=PushShortPixel(quantum_info->endian,p,&pixel);
1144 SetPixelRed(q,ScaleShortToQuantum(pixel));
1145 p=PushShortPixel(quantum_info->endian,p,&pixel);
1146 SetPixelOpacity(q,ScaleShortToQuantum(pixel));
1147 p+=quantum_info->pad;
1154 if (quantum_info->format == FloatingPointQuantumFormat)
1159 for (x=0; x < (ssize_t) number_pixels; x++)
1161 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1162 SetPixelRed(q,ClampToQuantum(pixel));
1163 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1164 SetPixelGreen(q,ClampToQuantum(pixel));
1165 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1166 SetPixelBlue(q,ClampToQuantum(pixel));
1167 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1168 SetPixelOpacity(q,ClampToQuantum(pixel));
1169 p+=quantum_info->pad;
1174 for (x=0; x < (ssize_t) number_pixels; x++)
1176 p=PushLongPixel(quantum_info->endian,p,&pixel);
1177 SetPixelBlue(q,ScaleLongToQuantum(pixel));
1178 p=PushLongPixel(quantum_info->endian,p,&pixel);
1179 SetPixelGreen(q,ScaleLongToQuantum(pixel));
1180 p=PushLongPixel(quantum_info->endian,p,&pixel);
1181 SetPixelRed(q,ScaleLongToQuantum(pixel));
1182 p=PushLongPixel(quantum_info->endian,p,&pixel);
1183 SetPixelOpacity(q,ScaleLongToQuantum(pixel));
1184 p+=quantum_info->pad;
1191 if (quantum_info->format == FloatingPointQuantumFormat)
1196 for (x=0; x < (ssize_t) number_pixels; x++)
1198 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1199 SetPixelRed(q,ClampToQuantum(pixel));
1200 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1201 SetPixelGreen(q,ClampToQuantum(pixel));
1202 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1203 SetPixelBlue(q,ClampToQuantum(pixel));
1204 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1205 SetPixelOpacity(q,ClampToQuantum(pixel));
1206 p+=quantum_info->pad;
1214 if (quantum_info->format == FloatingPointQuantumFormat)
1219 for (x=0; x < (ssize_t) number_pixels; x++)
1221 p=PushDoublePixel(quantum_info,p,&pixel);
1222 SetPixelRed(q,ClampToQuantum(pixel));
1223 p=PushDoublePixel(quantum_info,p,&pixel);
1224 SetPixelGreen(q,ClampToQuantum(pixel));
1225 p=PushDoublePixel(quantum_info,p,&pixel);
1226 SetPixelBlue(q,ClampToQuantum(pixel));
1227 p=PushDoublePixel(quantum_info,p,&pixel);
1228 SetPixelOpacity(q,ClampToQuantum(pixel));
1229 p+=quantum_info->pad;
1237 range=GetQuantumRange(quantum_info->depth);
1238 for (x=0; x < (ssize_t) number_pixels; x++)
1240 p=PushQuantumPixel(quantum_info,p,&pixel);
1241 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
1242 p=PushQuantumPixel(quantum_info,p,&pixel);
1243 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
1244 p=PushQuantumPixel(quantum_info,p,&pixel);
1245 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
1246 p=PushQuantumPixel(quantum_info,p,&pixel);
1247 SetPixelOpacity(q,ScaleAnyToQuantum(pixel,range));
1255 static void ImportBlackQuantum(
const Image *image,
QuantumInfo *quantum_info,
1256 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
1257 PixelPacket *magick_restrict q,IndexPacket *magick_restrict indexes,
1266 if (image->colorspace != CMYKColorspace)
1268 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1269 "ColorSeparatedImageRequired",
"`%s'",image->filename);
1272 switch (quantum_info->depth)
1279 for (x=0; x < (ssize_t) number_pixels; x++)
1281 p=PushCharPixel(p,&pixel);
1282 SetPixelIndex(indexes+x,ScaleCharToQuantum(pixel));
1283 p+=quantum_info->pad;
1292 if (quantum_info->format == FloatingPointQuantumFormat)
1294 for (x=0; x < (ssize_t) number_pixels; x++)
1296 p=PushShortPixel(quantum_info->endian,p,&pixel);
1297 SetPixelIndex(indexes+x,ClampToQuantum((MagickRealType)
1298 QuantumRange*HalfToSinglePrecision(pixel)));
1299 p+=quantum_info->pad;
1303 for (x=0; x < (ssize_t) number_pixels; x++)
1305 p=PushShortPixel(quantum_info->endian,p,&pixel);
1306 SetPixelIndex(indexes+x,ScaleShortToQuantum(pixel));
1307 p+=quantum_info->pad;
1313 if (quantum_info->format == FloatingPointQuantumFormat)
1318 for (x=0; x < (ssize_t) number_pixels; x++)
1320 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1321 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1322 p+=quantum_info->pad;
1327 for (x=0; x < (ssize_t) number_pixels; x++)
1329 p=PushLongPixel(quantum_info->endian,p,&pixel);
1330 SetPixelIndex(indexes+x,ScaleLongToQuantum(pixel));
1331 p+=quantum_info->pad;
1338 if (quantum_info->format == FloatingPointQuantumFormat)
1343 for (x=0; x < (ssize_t) number_pixels; x++)
1345 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1346 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1347 p+=quantum_info->pad;
1355 if (quantum_info->format == FloatingPointQuantumFormat)
1360 for (x=0; x < (ssize_t) number_pixels; x++)
1362 p=PushDoublePixel(quantum_info,p,&pixel);
1363 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1364 p+=quantum_info->pad;
1375 range=GetQuantumRange(quantum_info->depth);
1376 for (x=0; x < (ssize_t) number_pixels; x++)
1378 p=PushQuantumPixel(quantum_info,p,&pixel);
1379 SetPixelIndex(indexes+x,ScaleAnyToQuantum(pixel,range));
1380 p+=quantum_info->pad;
1388 static void ImportBlueQuantum(
QuantumInfo *quantum_info,
1389 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
1398 switch (quantum_info->depth)
1405 for (x=0; x < (ssize_t) number_pixels; x++)
1407 p=PushCharPixel(p,&pixel);
1408 SetPixelBlue(q,ScaleCharToQuantum(pixel));
1409 p+=quantum_info->pad;
1419 if (quantum_info->format == FloatingPointQuantumFormat)
1421 for (x=0; x < (ssize_t) number_pixels; x++)
1423 p=PushShortPixel(quantum_info->endian,p,&pixel);
1424 SetPixelBlue(q,ClampToQuantum((MagickRealType)
1425 QuantumRange*HalfToSinglePrecision(pixel)));
1426 p+=quantum_info->pad;
1431 for (x=0; x < (ssize_t) number_pixels; x++)
1433 p=PushShortPixel(quantum_info->endian,p,&pixel);
1434 SetPixelBlue(q,ScaleShortToQuantum(pixel));
1435 p+=quantum_info->pad;
1442 if (quantum_info->format == FloatingPointQuantumFormat)
1447 for (x=0; x < (ssize_t) number_pixels; x++)
1449 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1450 SetPixelBlue(q,ClampToQuantum(pixel));
1451 p+=quantum_info->pad;
1456 for (x=0; x < (ssize_t) number_pixels; x++)
1458 p=PushLongPixel(quantum_info->endian,p,&pixel);
1459 SetPixelBlue(q,ScaleLongToQuantum(pixel));
1460 p+=quantum_info->pad;
1467 if (quantum_info->format == FloatingPointQuantumFormat)
1472 for (x=0; x < (ssize_t) number_pixels; x++)
1474 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1475 SetPixelBlue(q,ClampToQuantum(pixel));
1476 p+=quantum_info->pad;
1484 if (quantum_info->format == FloatingPointQuantumFormat)
1489 for (x=0; x < (ssize_t) number_pixels; x++)
1491 p=PushDoublePixel(quantum_info,p,&pixel);
1492 SetPixelBlue(q,ClampToQuantum(pixel));
1493 p+=quantum_info->pad;
1504 range=GetQuantumRange(quantum_info->depth);
1505 for (x=0; x < (ssize_t) number_pixels; x++)
1507 p=PushQuantumPixel(quantum_info,p,&pixel);
1508 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
1509 p+=quantum_info->pad;
1517 static void ImportCbYCrYQuantum(
const Image *image,
QuantumInfo *quantum_info,
1518 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
1527 switch (quantum_info->depth)
1535 if (quantum_info->pack == MagickFalse)
1548 for (x=0; x < (ssize_t) (number_pixels-3); x+=4)
1550 for (i=0; i < 4; i++)
1556 p=PushLongPixel(quantum_info->endian,p,&pixel);
1557 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
1558 (((pixel >> 22) & 0x3ff) << 6)));
1563 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
1564 (((pixel >> 12) & 0x3ff) << 6)));
1569 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
1570 (((pixel >> 2) & 0x3ff) << 6)));
1574 cbcr[i]=(Quantum) (quantum);
1577 p+=quantum_info->pad;
1578 SetPixelRed(q,cbcr[1]);
1579 SetPixelGreen(q,cbcr[0]);
1580 SetPixelBlue(q,cbcr[2]);
1582 SetPixelRed(q,cbcr[3]);
1583 SetPixelGreen(q,cbcr[0]);
1584 SetPixelBlue(q,cbcr[2]);
1595 range=GetQuantumRange(image->depth);
1596 for (x=0; x < (ssize_t) number_pixels; x++)
1598 p=PushQuantumPixel(quantum_info,p,&pixel);
1599 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
1600 p=PushQuantumPixel(quantum_info,p,&pixel);
1601 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
1609 static void ImportCMYKQuantum(
const Image *image,
QuantumInfo *quantum_info,
1610 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
1611 PixelPacket *magick_restrict q,IndexPacket *magick_restrict indexes,
1623 if (image->colorspace != CMYKColorspace)
1625 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1626 "ColorSeparatedImageRequired",
"`%s'",image->filename);
1629 switch (quantum_info->depth)
1636 for (x=0; x < (ssize_t) number_pixels; x++)
1638 p=PushCharPixel(p,&pixel);
1639 SetPixelRed(q,ScaleCharToQuantum(pixel));
1640 p=PushCharPixel(p,&pixel);
1641 SetPixelGreen(q,ScaleCharToQuantum(pixel));
1642 p=PushCharPixel(p,&pixel);
1643 SetPixelBlue(q,ScaleCharToQuantum(pixel));
1644 p=PushCharPixel(p,&pixel);
1645 SetPixelIndex(indexes+x,ScaleCharToQuantum(pixel));
1646 p+=quantum_info->pad;
1656 if (quantum_info->format == FloatingPointQuantumFormat)
1658 for (x=0; x < (ssize_t) number_pixels; x++)
1660 p=PushShortPixel(quantum_info->endian,p,&pixel);
1661 SetPixelRed(q,ClampToQuantum((MagickRealType) QuantumRange*
1662 HalfToSinglePrecision(pixel)));
1663 p=PushShortPixel(quantum_info->endian,p,&pixel);
1664 SetPixelGreen(q,ClampToQuantum((MagickRealType) QuantumRange*
1665 HalfToSinglePrecision(pixel)));
1666 p=PushShortPixel(quantum_info->endian,p,&pixel);
1667 SetPixelBlue(q,ClampToQuantum((MagickRealType) QuantumRange*
1668 HalfToSinglePrecision(pixel)));
1669 p=PushShortPixel(quantum_info->endian,p,&pixel);
1670 SetPixelIndex(indexes+x,ClampToQuantum((MagickRealType)
1671 QuantumRange*HalfToSinglePrecision(pixel)));
1672 p+=quantum_info->pad;
1677 for (x=0; x < (ssize_t) number_pixels; x++)
1679 p=PushShortPixel(quantum_info->endian,p,&pixel);
1680 SetPixelRed(q,ScaleShortToQuantum(pixel));
1681 p=PushShortPixel(quantum_info->endian,p,&pixel);
1682 SetPixelGreen(q,ScaleShortToQuantum(pixel));
1683 p=PushShortPixel(quantum_info->endian,p,&pixel);
1684 SetPixelBlue(q,ScaleShortToQuantum(pixel));
1685 p=PushShortPixel(quantum_info->endian,p,&pixel);
1686 SetPixelIndex(indexes+x,ScaleShortToQuantum(pixel));
1687 p+=quantum_info->pad;
1694 if (quantum_info->format == FloatingPointQuantumFormat)
1699 for (x=0; x < (ssize_t) number_pixels; x++)
1701 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1702 SetPixelRed(q,ClampToQuantum(pixel));
1703 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1704 SetPixelGreen(q,ClampToQuantum(pixel));
1705 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1706 SetPixelBlue(q,ClampToQuantum(pixel));
1707 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1708 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1709 p+=quantum_info->pad;
1714 for (x=0; x < (ssize_t) number_pixels; x++)
1716 p=PushLongPixel(quantum_info->endian,p,&pixel);
1717 SetPixelRed(q,ScaleLongToQuantum(pixel));
1718 p=PushLongPixel(quantum_info->endian,p,&pixel);
1719 SetPixelGreen(q,ScaleLongToQuantum(pixel));
1720 p=PushLongPixel(quantum_info->endian,p,&pixel);
1721 SetPixelBlue(q,ScaleLongToQuantum(pixel));
1722 p=PushLongPixel(quantum_info->endian,p,&pixel);
1723 SetPixelIndex(indexes+x,ScaleLongToQuantum(pixel));
1724 p+=quantum_info->pad;
1731 if (quantum_info->format == FloatingPointQuantumFormat)
1736 for (x=0; x < (ssize_t) number_pixels; x++)
1738 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1739 SetPixelRed(q,ClampToQuantum(pixel));
1740 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1741 SetPixelGreen(q,ClampToQuantum(pixel));
1742 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1743 SetPixelBlue(q,ClampToQuantum(pixel));
1744 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1745 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1746 p+=quantum_info->pad;
1754 if (quantum_info->format == FloatingPointQuantumFormat)
1759 for (x=0; x < (ssize_t) number_pixels; x++)
1761 p=PushDoublePixel(quantum_info,p,&pixel);
1762 SetPixelRed(q,ClampToQuantum(pixel));
1763 p=PushDoublePixel(quantum_info,p,&pixel);
1764 SetPixelGreen(q,ClampToQuantum(pixel));
1765 p=PushDoublePixel(quantum_info,p,&pixel);
1766 SetPixelBlue(q,ClampToQuantum(pixel));
1767 p=PushDoublePixel(quantum_info,p,&pixel);
1768 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1769 p+=quantum_info->pad;
1777 range=GetQuantumRange(quantum_info->depth);
1778 for (x=0; x < (ssize_t) number_pixels; x++)
1780 p=PushQuantumPixel(quantum_info,p,&pixel);
1781 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
1782 p=PushQuantumPixel(quantum_info,p,&pixel);
1783 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
1784 p=PushQuantumPixel(quantum_info,p,&pixel);
1785 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
1786 p=PushQuantumPixel(quantum_info,p,&pixel);
1787 SetPixelIndex(indexes+x,ScaleAnyToQuantum(pixel,range));
1795 static void ImportCMYKAQuantum(
const Image *image,
QuantumInfo *quantum_info,
1796 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
1797 PixelPacket *magick_restrict q,IndexPacket *magick_restrict indexes,
1809 if (image->colorspace != CMYKColorspace)
1811 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1812 "ColorSeparatedImageRequired",
"`%s'",image->filename);
1815 switch (quantum_info->depth)
1822 for (x=0; x < (ssize_t) number_pixels; x++)
1824 p=PushCharPixel(p,&pixel);
1825 SetPixelRed(q,ScaleCharToQuantum(pixel));
1826 p=PushCharPixel(p,&pixel);
1827 SetPixelGreen(q,ScaleCharToQuantum(pixel));
1828 p=PushCharPixel(p,&pixel);
1829 SetPixelBlue(q,ScaleCharToQuantum(pixel));
1830 p=PushCharPixel(p,&pixel);
1831 SetPixelIndex(indexes+x,ScaleCharToQuantum(pixel));
1832 p=PushCharPixel(p,&pixel);
1833 SetPixelAlpha(q,ScaleCharToQuantum(pixel));
1834 p+=quantum_info->pad;
1844 if (quantum_info->format == FloatingPointQuantumFormat)
1846 for (x=0; x < (ssize_t) number_pixels; x++)
1848 p=PushShortPixel(quantum_info->endian,p,&pixel);
1849 SetPixelRed(q,ClampToQuantum((MagickRealType) QuantumRange*
1850 HalfToSinglePrecision(pixel)));
1851 p=PushShortPixel(quantum_info->endian,p,&pixel);
1852 SetPixelGreen(q,ClampToQuantum((MagickRealType) QuantumRange*
1853 HalfToSinglePrecision(pixel)));
1854 p=PushShortPixel(quantum_info->endian,p,&pixel);
1855 SetPixelBlue(q,ClampToQuantum((MagickRealType) QuantumRange*
1856 HalfToSinglePrecision(pixel)));
1857 p=PushShortPixel(quantum_info->endian,p,&pixel);
1858 SetPixelIndex(indexes+x,ClampToQuantum((MagickRealType)
1859 QuantumRange*HalfToSinglePrecision(pixel)));
1860 p=PushShortPixel(quantum_info->endian,p,&pixel);
1861 SetPixelAlpha(q,ClampToQuantum((MagickRealType) QuantumRange*
1862 HalfToSinglePrecision(pixel)));
1863 p+=quantum_info->pad;
1868 for (x=0; x < (ssize_t) number_pixels; x++)
1870 p=PushShortPixel(quantum_info->endian,p,&pixel);
1871 SetPixelRed(q,ScaleShortToQuantum(pixel));
1872 p=PushShortPixel(quantum_info->endian,p,&pixel);
1873 SetPixelGreen(q,ScaleShortToQuantum(pixel));
1874 p=PushShortPixel(quantum_info->endian,p,&pixel);
1875 SetPixelBlue(q,ScaleShortToQuantum(pixel));
1876 p=PushShortPixel(quantum_info->endian,p,&pixel);
1877 SetPixelIndex(indexes+x,ScaleShortToQuantum(pixel));
1878 p=PushShortPixel(quantum_info->endian,p,&pixel);
1879 SetPixelAlpha(q,ScaleShortToQuantum(pixel));
1880 p+=quantum_info->pad;
1887 if (quantum_info->format == FloatingPointQuantumFormat)
1892 for (x=0; x < (ssize_t) number_pixels; x++)
1894 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1895 SetPixelRed(q,ClampToQuantum(pixel));
1896 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1897 SetPixelGreen(q,ClampToQuantum(pixel));
1898 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1899 SetPixelBlue(q,ClampToQuantum(pixel));
1900 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1901 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1902 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1903 SetPixelAlpha(q,ClampToQuantum(pixel));
1904 p+=quantum_info->pad;
1909 for (x=0; x < (ssize_t) number_pixels; x++)
1911 p=PushLongPixel(quantum_info->endian,p,&pixel);
1912 SetPixelRed(q,ScaleLongToQuantum(pixel));
1913 p=PushLongPixel(quantum_info->endian,p,&pixel);
1914 SetPixelGreen(q,ScaleLongToQuantum(pixel));
1915 p=PushLongPixel(quantum_info->endian,p,&pixel);
1916 SetPixelBlue(q,ScaleLongToQuantum(pixel));
1917 p=PushLongPixel(quantum_info->endian,p,&pixel);
1918 SetPixelIndex(indexes+x,ScaleLongToQuantum(pixel));
1919 p=PushLongPixel(quantum_info->endian,p,&pixel);
1920 SetPixelAlpha(q,ScaleLongToQuantum(pixel));
1921 p+=quantum_info->pad;
1928 if (quantum_info->format == FloatingPointQuantumFormat)
1933 for (x=0; x < (ssize_t) number_pixels; x++)
1935 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1936 SetPixelRed(q,ClampToQuantum(pixel));
1937 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1938 SetPixelGreen(q,ClampToQuantum(pixel));
1939 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1940 SetPixelBlue(q,ClampToQuantum(pixel));
1941 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1942 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1943 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1944 SetPixelAlpha(q,ClampToQuantum(pixel));
1945 p+=quantum_info->pad;
1953 if (quantum_info->format == FloatingPointQuantumFormat)
1958 for (x=0; x < (ssize_t) number_pixels; x++)
1960 p=PushDoublePixel(quantum_info,p,&pixel);
1961 SetPixelRed(q,ClampToQuantum(pixel));
1962 p=PushDoublePixel(quantum_info,p,&pixel);
1963 SetPixelGreen(q,ClampToQuantum(pixel));
1964 p=PushDoublePixel(quantum_info,p,&pixel);
1965 SetPixelBlue(q,ClampToQuantum(pixel));
1966 p=PushDoublePixel(quantum_info,p,&pixel);
1967 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1968 p=PushDoublePixel(quantum_info,p,&pixel);
1969 SetPixelAlpha(q,ClampToQuantum(pixel));
1970 p+=quantum_info->pad;
1978 range=GetQuantumRange(image->depth);
1979 for (x=0; x < (ssize_t) number_pixels; x++)
1981 p=PushQuantumPixel(quantum_info,p,&pixel);
1982 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
1983 p=PushQuantumPixel(quantum_info,p,&pixel);
1984 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
1985 p=PushQuantumPixel(quantum_info,p,&pixel);
1986 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
1987 p=PushQuantumPixel(quantum_info,p,&pixel);
1988 SetPixelIndex(indexes+x,ScaleAnyToQuantum(pixel,range));
1989 p=PushQuantumPixel(quantum_info,p,&pixel);
1990 SetPixelAlpha(q,ScaleAnyToQuantum(pixel,range));
1998 static void ImportCMYKOQuantum(
const Image *image,
QuantumInfo *quantum_info,
1999 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
2000 PixelPacket *magick_restrict q,IndexPacket *magick_restrict indexes,
2012 if (image->colorspace != CMYKColorspace)
2014 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
2015 "ColorSeparatedImageRequired",
"`%s'",image->filename);
2018 switch (quantum_info->depth)
2025 for (x=0; x < (ssize_t) number_pixels; x++)
2027 p=PushCharPixel(p,&pixel);
2028 SetPixelRed(q,ScaleCharToQuantum(pixel));
2029 p=PushCharPixel(p,&pixel);
2030 SetPixelGreen(q,ScaleCharToQuantum(pixel));
2031 p=PushCharPixel(p,&pixel);
2032 SetPixelBlue(q,ScaleCharToQuantum(pixel));
2033 p=PushCharPixel(p,&pixel);
2034 SetPixelIndex(indexes+x,ScaleCharToQuantum(pixel));
2035 p=PushCharPixel(p,&pixel);
2036 SetPixelOpacity(q,ScaleCharToQuantum(pixel));
2037 p+=quantum_info->pad;
2047 if (quantum_info->format == FloatingPointQuantumFormat)
2049 for (x=0; x < (ssize_t) number_pixels; x++)
2051 p=PushShortPixel(quantum_info->endian,p,&pixel);
2052 SetPixelRed(q,ClampToQuantum((MagickRealType) QuantumRange*
2053 HalfToSinglePrecision(pixel)));
2054 p=PushShortPixel(quantum_info->endian,p,&pixel);
2055 SetPixelGreen(q,ClampToQuantum((MagickRealType) QuantumRange*
2056 HalfToSinglePrecision(pixel)));
2057 p=PushShortPixel(quantum_info->endian,p,&pixel);
2058 SetPixelBlue(q,ClampToQuantum((MagickRealType) QuantumRange*
2059 HalfToSinglePrecision(pixel)));
2060 p=PushShortPixel(quantum_info->endian,p,&pixel);
2061 SetPixelIndex(indexes+x,ClampToQuantum((MagickRealType)
2062 QuantumRange*HalfToSinglePrecision(pixel)));
2063 p=PushShortPixel(quantum_info->endian,p,&pixel);
2064 SetPixelOpacity(q,ClampToQuantum((MagickRealType) QuantumRange*
2065 HalfToSinglePrecision(pixel)));
2066 p+=quantum_info->pad;
2071 for (x=0; x < (ssize_t) number_pixels; x++)
2073 p=PushShortPixel(quantum_info->endian,p,&pixel);
2074 SetPixelRed(q,ScaleShortToQuantum(pixel));
2075 p=PushShortPixel(quantum_info->endian,p,&pixel);
2076 SetPixelGreen(q,ScaleShortToQuantum(pixel));
2077 p=PushShortPixel(quantum_info->endian,p,&pixel);
2078 SetPixelBlue(q,ScaleShortToQuantum(pixel));
2079 p=PushShortPixel(quantum_info->endian,p,&pixel);
2080 SetPixelIndex(indexes+x,ScaleShortToQuantum(pixel));
2081 p=PushShortPixel(quantum_info->endian,p,&pixel);
2082 SetPixelOpacity(q,ScaleShortToQuantum(pixel));
2083 p+=quantum_info->pad;
2090 if (quantum_info->format == FloatingPointQuantumFormat)
2095 for (x=0; x < (ssize_t) number_pixels; x++)
2097 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2098 SetPixelRed(q,ClampToQuantum(pixel));
2099 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2100 SetPixelGreen(q,ClampToQuantum(pixel));
2101 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2102 SetPixelBlue(q,ClampToQuantum(pixel));
2103 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2104 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
2105 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2106 SetPixelOpacity(q,ClampToQuantum(pixel));
2107 p+=quantum_info->pad;
2112 for (x=0; x < (ssize_t) number_pixels; x++)
2114 p=PushLongPixel(quantum_info->endian,p,&pixel);
2115 SetPixelRed(q,ScaleLongToQuantum(pixel));
2116 p=PushLongPixel(quantum_info->endian,p,&pixel);
2117 SetPixelGreen(q,ScaleLongToQuantum(pixel));
2118 p=PushLongPixel(quantum_info->endian,p,&pixel);
2119 SetPixelBlue(q,ScaleLongToQuantum(pixel));
2120 p=PushLongPixel(quantum_info->endian,p,&pixel);
2121 SetPixelIndex(indexes+x,ScaleLongToQuantum(pixel));
2122 p=PushLongPixel(quantum_info->endian,p,&pixel);
2123 SetPixelOpacity(q,ScaleLongToQuantum(pixel));
2124 p+=quantum_info->pad;
2131 if (quantum_info->format == FloatingPointQuantumFormat)
2136 for (x=0; x < (ssize_t) number_pixels; x++)
2138 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2139 SetPixelRed(q,ClampToQuantum(pixel));
2140 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2141 SetPixelGreen(q,ClampToQuantum(pixel));
2142 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2143 SetPixelBlue(q,ClampToQuantum(pixel));
2144 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2145 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
2146 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2147 SetPixelOpacity(q,ClampToQuantum(pixel));
2148 p+=quantum_info->pad;
2156 if (quantum_info->format == FloatingPointQuantumFormat)
2161 for (x=0; x < (ssize_t) number_pixels; x++)
2163 p=PushDoublePixel(quantum_info,p,&pixel);
2164 SetPixelRed(q,ClampToQuantum(pixel));
2165 p=PushDoublePixel(quantum_info,p,&pixel);
2166 SetPixelGreen(q,ClampToQuantum(pixel));
2167 p=PushDoublePixel(quantum_info,p,&pixel);
2168 SetPixelBlue(q,ClampToQuantum(pixel));
2169 p=PushDoublePixel(quantum_info,p,&pixel);
2170 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
2171 p=PushDoublePixel(quantum_info,p,&pixel);
2172 SetPixelOpacity(q,ClampToQuantum(pixel));
2173 p+=quantum_info->pad;
2181 range=GetQuantumRange(image->depth);
2182 for (x=0; x < (ssize_t) number_pixels; x++)
2184 p=PushQuantumPixel(quantum_info,p,&pixel);
2185 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2186 p=PushQuantumPixel(quantum_info,p,&pixel);
2187 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
2188 p=PushQuantumPixel(quantum_info,p,&pixel);
2189 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
2190 p=PushQuantumPixel(quantum_info,p,&pixel);
2191 SetPixelIndex(indexes+x,ScaleAnyToQuantum(pixel,range));
2192 p=PushQuantumPixel(quantum_info,p,&pixel);
2193 SetPixelOpacity(q,ScaleAnyToQuantum(pixel,range));
2201 static void ImportGrayQuantum(
const Image *image,
QuantumInfo *quantum_info,
2202 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
2218 switch (quantum_info->depth)
2228 if (quantum_info->min_is_white != MagickFalse)
2233 for (x=0; x < ((ssize_t) number_pixels-7); x+=8)
2235 for (bit=0; bit < 8; bit++)
2237 SetPixelRed(q,((*p) & (1 << (7-bit))) == 0 ? black : white);
2238 SetPixelGreen(q,GetPixelRed(q));
2239 SetPixelBlue(q,GetPixelRed(q));
2244 for (bit=0; bit < (ssize_t) (number_pixels % 8); bit++)
2246 SetPixelRed(q,((*p) & (0x01 << (7-bit))) == 0 ? black : white);
2247 SetPixelGreen(q,GetPixelRed(q));
2248 SetPixelBlue(q,GetPixelRed(q));
2260 range=GetQuantumRange(quantum_info->depth);
2261 for (x=0; x < ((ssize_t) number_pixels-1); x+=2)
2263 pixel=(
unsigned char) ((*p >> 4) & 0xf);
2264 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2265 SetPixelGreen(q,GetPixelRed(q));
2266 SetPixelBlue(q,GetPixelRed(q));
2268 pixel=(
unsigned char) ((*p) & 0xf);
2269 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2270 SetPixelGreen(q,GetPixelRed(q));
2271 SetPixelBlue(q,GetPixelRed(q));
2275 for (bit=0; bit < (ssize_t) (number_pixels % 2); bit++)
2277 pixel=(
unsigned char) (*p++ >> 4);
2278 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2279 SetPixelGreen(q,GetPixelRed(q));
2280 SetPixelBlue(q,GetPixelRed(q));
2290 if (quantum_info->min_is_white != MagickFalse)
2292 for (x=0; x < (ssize_t) number_pixels; x++)
2294 p=PushCharPixel(p,&pixel);
2295 SetPixelRed(q,QuantumRange-ScaleCharToQuantum(pixel));
2296 SetPixelGreen(q,GetPixelRed(q));
2297 SetPixelBlue(q,GetPixelRed(q));
2298 SetPixelOpacity(q,OpaqueOpacity);
2299 p+=quantum_info->pad;
2304 for (x=0; x < (ssize_t) number_pixels; x++)
2306 p=PushCharPixel(p,&pixel);
2307 SetPixelRed(q,ScaleCharToQuantum(pixel));
2308 SetPixelGreen(q,GetPixelRed(q));
2309 SetPixelBlue(q,GetPixelRed(q));
2310 SetPixelOpacity(q,OpaqueOpacity);
2311 p+=quantum_info->pad;
2318 range=GetQuantumRange(quantum_info->depth);
2319 if (quantum_info->pack == MagickFalse)
2321 if (image->endian == LSBEndian)
2323 for (x=0; x < (ssize_t) (number_pixels-2); x+=3)
2325 p=PushLongPixel(quantum_info->endian,p,&pixel);
2326 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range));
2327 SetPixelGreen(q,GetPixelRed(q));
2328 SetPixelBlue(q,GetPixelRed(q));
2330 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range));
2331 SetPixelGreen(q,GetPixelRed(q));
2332 SetPixelBlue(q,GetPixelRed(q));
2334 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range));
2335 SetPixelGreen(q,GetPixelRed(q));
2336 SetPixelBlue(q,GetPixelRed(q));
2337 p+=quantum_info->pad;
2340 if (x++ < (ssize_t) (number_pixels-1))
2342 p=PushLongPixel(quantum_info->endian,p,&pixel);
2343 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range));
2344 SetPixelGreen(q,GetPixelRed(q));
2345 SetPixelBlue(q,GetPixelRed(q));
2348 if (x++ < (ssize_t) number_pixels)
2350 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range));
2351 SetPixelGreen(q,GetPixelRed(q));
2352 SetPixelBlue(q,GetPixelRed(q));
2357 for (x=0; x < (ssize_t) (number_pixels-2); x+=3)
2359 p=PushLongPixel(quantum_info->endian,p,&pixel);
2360 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range));
2361 SetPixelGreen(q,GetPixelRed(q));
2362 SetPixelBlue(q,GetPixelRed(q));
2364 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range));
2365 SetPixelGreen(q,GetPixelRed(q));
2366 SetPixelBlue(q,GetPixelRed(q));
2368 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range));
2369 SetPixelGreen(q,GetPixelRed(q));
2370 SetPixelBlue(q,GetPixelRed(q));
2371 p+=quantum_info->pad;
2374 if (x++ < (ssize_t) (number_pixels-1))
2376 p=PushLongPixel(quantum_info->endian,p,&pixel);
2377 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range));
2378 SetPixelGreen(q,GetPixelRed(q));
2379 SetPixelBlue(q,GetPixelRed(q));
2382 if (x++ < (ssize_t) number_pixels)
2384 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range));
2385 SetPixelGreen(q,GetPixelRed(q));
2386 SetPixelBlue(q,GetPixelRed(q));
2391 for (x=0; x < (ssize_t) number_pixels; x++)
2393 p=PushQuantumPixel(quantum_info,p,&pixel);
2394 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2395 SetPixelGreen(q,GetPixelRed(q));
2396 SetPixelBlue(q,GetPixelRed(q));
2397 p+=quantum_info->pad;
2404 range=GetQuantumRange(quantum_info->depth);
2405 if (quantum_info->pack == MagickFalse)
2410 for (x=0; x < (ssize_t) (number_pixels-1); x+=2)
2412 p=PushShortPixel(quantum_info->endian,p,&pixel);
2413 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range));
2414 SetPixelGreen(q,GetPixelRed(q));
2415 SetPixelBlue(q,GetPixelRed(q));
2417 p=PushShortPixel(quantum_info->endian,p,&pixel);
2418 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range));
2419 SetPixelGreen(q,GetPixelRed(q));
2420 SetPixelBlue(q,GetPixelRed(q));
2421 p+=quantum_info->pad;
2424 for (bit=0; bit < (ssize_t) (number_pixels % 2); bit++)
2426 p=PushShortPixel(quantum_info->endian,p,&pixel);
2427 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny)
2428 (pixel >> 4),range));
2429 SetPixelGreen(q,GetPixelRed(q));
2430 SetPixelBlue(q,GetPixelRed(q));
2431 p+=quantum_info->pad;
2438 for (x=0; x < (ssize_t) number_pixels; x++)
2440 p=PushQuantumPixel(quantum_info,p,&pixel);
2441 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2442 SetPixelGreen(q,GetPixelRed(q));
2443 SetPixelBlue(q,GetPixelRed(q));
2444 p+=quantum_info->pad;
2454 if (quantum_info->min_is_white != MagickFalse)
2456 for (x=0; x < (ssize_t) number_pixels; x++)
2458 p=PushShortPixel(quantum_info->endian,p,&pixel);
2459 SetPixelRed(q,QuantumRange-ScaleShortToQuantum(pixel));
2460 SetPixelGreen(q,GetPixelRed(q));
2461 SetPixelBlue(q,GetPixelRed(q));
2462 p+=quantum_info->pad;
2467 if (quantum_info->format == FloatingPointQuantumFormat)
2469 for (x=0; x < (ssize_t) number_pixels; x++)
2471 p=PushShortPixel(quantum_info->endian,p,&pixel);
2472 SetPixelRed(q,ClampToQuantum((MagickRealType) QuantumRange*
2473 HalfToSinglePrecision(pixel)));
2474 SetPixelGreen(q,GetPixelRed(q));
2475 SetPixelBlue(q,GetPixelRed(q));
2476 p+=quantum_info->pad;
2481 if (quantum_info->format == SignedQuantumFormat)
2483 for (x=0; x < (ssize_t) number_pixels; x++)
2485 p=PushShortPixel(quantum_info->endian,p,&pixel);
2486 pixel=(
unsigned short) (((
unsigned int) pixel+32768) % 65536);
2487 SetPixelRed(q,ScaleShortToQuantum(pixel));
2488 SetPixelGreen(q,GetPixelRed(q));
2489 SetPixelBlue(q,GetPixelRed(q));
2490 p+=quantum_info->pad;
2495 for (x=0; x < (ssize_t) number_pixels; x++)
2497 p=PushShortPixel(quantum_info->endian,p,&pixel);
2498 SetPixelRed(q,ScaleShortToQuantum(pixel));
2499 SetPixelGreen(q,GetPixelRed(q));
2500 SetPixelBlue(q,GetPixelRed(q));
2501 p+=quantum_info->pad;
2508 if (quantum_info->format == FloatingPointQuantumFormat)
2513 for (x=0; x < (ssize_t) number_pixels; x++)
2515 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2516 SetPixelRed(q,ClampToQuantum(pixel));
2517 SetPixelGreen(q,GetPixelRed(q));
2518 SetPixelBlue(q,GetPixelRed(q));
2519 p+=quantum_info->pad;
2524 for (x=0; x < (ssize_t) number_pixels; x++)
2526 p=PushLongPixel(quantum_info->endian,p,&pixel);
2527 SetPixelRed(q,ScaleLongToQuantum(pixel));
2528 SetPixelGreen(q,GetPixelRed(q));
2529 SetPixelBlue(q,GetPixelRed(q));
2530 p+=quantum_info->pad;
2537 if (quantum_info->format == FloatingPointQuantumFormat)
2542 for (x=0; x < (ssize_t) number_pixels; x++)
2544 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2545 SetPixelRed(q,ClampToQuantum(pixel));
2546 SetPixelGreen(q,GetPixelRed(q));
2547 SetPixelBlue(q,GetPixelRed(q));
2548 p+=quantum_info->pad;
2556 if (quantum_info->format == FloatingPointQuantumFormat)
2561 for (x=0; x < (ssize_t) number_pixels; x++)
2563 p=PushDoublePixel(quantum_info,p,&pixel);
2564 SetPixelRed(q,ClampToQuantum(pixel));
2565 SetPixelGreen(q,GetPixelRed(q));
2566 SetPixelBlue(q,GetPixelRed(q));
2567 p+=quantum_info->pad;
2575 range=GetQuantumRange(quantum_info->depth);
2576 for (x=0; x < (ssize_t) number_pixels; x++)
2578 p=PushQuantumPixel(quantum_info,p,&pixel);
2579 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2580 SetPixelGreen(q,GetPixelRed(q));
2581 SetPixelBlue(q,GetPixelRed(q));
2582 p+=quantum_info->pad;
2590 static void ImportGrayAlphaQuantum(
QuantumInfo *quantum_info,
2591 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
2606 switch (quantum_info->depth)
2614 for (x=((ssize_t) number_pixels-3); x > 0; x-=4)
2616 for (bit=0; bit < 8; bit+=2)
2618 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
2619 SetPixelRed(q,pixel == 0 ? 0 : QuantumRange);
2620 SetPixelGreen(q,GetPixelRed(q));
2621 SetPixelBlue(q,GetPixelRed(q));
2622 SetPixelOpacity(q,((*p) & (1UL << (
unsigned char) (6-bit))) == 0 ?
2623 TransparentOpacity : OpaqueOpacity);
2628 if ((number_pixels % 4) != 0)
2629 for (bit=3; bit >= (ssize_t) (4-(number_pixels % 4)); bit-=2)
2631 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
2632 SetPixelRed(q,pixel != 0 ? 0 : QuantumRange);
2633 SetPixelGreen(q,GetPixelRed(q));
2634 SetPixelBlue(q,GetPixelRed(q));
2635 SetPixelOpacity(q,((*p) & (1UL << (
unsigned char) (6-bit))) == 0 ?
2636 TransparentOpacity : OpaqueOpacity);
2648 range=GetQuantumRange(quantum_info->depth);
2649 for (x=0; x < (ssize_t) number_pixels; x++)
2651 pixel=(
unsigned char) ((*p >> 4) & 0xf);
2652 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2653 SetPixelGreen(q,GetPixelRed(q));
2654 SetPixelBlue(q,GetPixelRed(q));
2655 pixel=(
unsigned char) ((*p) & 0xf);
2656 SetPixelAlpha(q,ScaleAnyToQuantum(pixel,range));
2667 for (x=0; x < (ssize_t) number_pixels; x++)
2669 p=PushCharPixel(p,&pixel);
2670 SetPixelRed(q,ScaleCharToQuantum(pixel));
2671 SetPixelGreen(q,GetPixelRed(q));
2672 SetPixelBlue(q,GetPixelRed(q));
2673 p=PushCharPixel(p,&pixel);
2674 SetPixelAlpha(q,ScaleCharToQuantum(pixel));
2675 p+=quantum_info->pad;
2682 range=GetQuantumRange(quantum_info->depth);
2683 for (x=0; x < (ssize_t) number_pixels; x++)
2685 p=PushQuantumPixel(quantum_info,p,&pixel);
2686 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2687 SetPixelGreen(q,GetPixelRed(q));
2688 SetPixelBlue(q,GetPixelRed(q));
2689 p=PushQuantumPixel(quantum_info,p,&pixel);
2690 SetPixelOpacity(q,ScaleAnyToQuantum(pixel,range));
2691 p+=quantum_info->pad;
2698 range=GetQuantumRange(quantum_info->depth);
2699 for (x=0; x < (ssize_t) number_pixels; x++)
2701 p=PushQuantumPixel(quantum_info,p,&pixel);
2702 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2703 SetPixelGreen(q,GetPixelRed(q));
2704 SetPixelBlue(q,GetPixelRed(q));
2705 p=PushQuantumPixel(quantum_info,p,&pixel);
2706 SetPixelOpacity(q,ScaleAnyToQuantum(pixel,range));
2707 p+=quantum_info->pad;
2717 if (quantum_info->format == FloatingPointQuantumFormat)
2719 for (x=0; x < (ssize_t) number_pixels; x++)
2721 p=PushShortPixel(quantum_info->endian,p,&pixel);
2722 SetPixelRed(q,ClampToQuantum((MagickRealType) QuantumRange*
2723 HalfToSinglePrecision(pixel)));
2724 SetPixelGreen(q,GetPixelRed(q));
2725 SetPixelBlue(q,GetPixelRed(q));
2726 p=PushShortPixel(quantum_info->endian,p,&pixel);
2727 SetPixelAlpha(q,ClampToQuantum((MagickRealType) QuantumRange*
2728 HalfToSinglePrecision(pixel)));
2729 p+=quantum_info->pad;
2734 for (x=0; x < (ssize_t) number_pixels; x++)
2736 p=PushShortPixel(quantum_info->endian,p,&pixel);
2737 SetPixelRed(q,ScaleShortToQuantum(pixel));
2738 SetPixelGreen(q,GetPixelRed(q));
2739 SetPixelBlue(q,GetPixelRed(q));
2740 p=PushShortPixel(quantum_info->endian,p,&pixel);
2741 SetPixelAlpha(q,ScaleShortToQuantum(pixel));
2742 p+=quantum_info->pad;
2749 if (quantum_info->format == FloatingPointQuantumFormat)
2754 for (x=0; x < (ssize_t) number_pixels; x++)
2756 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2757 SetPixelRed(q,ClampToQuantum(pixel));
2758 SetPixelGreen(q,GetPixelRed(q));
2759 SetPixelBlue(q,GetPixelRed(q));
2760 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2761 SetPixelAlpha(q,ClampToQuantum(pixel));
2762 p+=quantum_info->pad;
2767 for (x=0; x < (ssize_t) number_pixels; x++)
2769 p=PushLongPixel(quantum_info->endian,p,&pixel);
2770 SetPixelRed(q,ScaleLongToQuantum(pixel));
2771 SetPixelGreen(q,GetPixelRed(q));
2772 SetPixelBlue(q,GetPixelRed(q));
2773 p=PushLongPixel(quantum_info->endian,p,&pixel);
2774 SetPixelAlpha(q,ScaleLongToQuantum(pixel));
2775 p+=quantum_info->pad;
2782 if (quantum_info->format == FloatingPointQuantumFormat)
2787 for (x=0; x < (ssize_t) number_pixels; x++)
2789 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2790 SetPixelRed(q,ClampToQuantum(pixel));
2791 SetPixelGreen(q,GetPixelRed(q));
2792 SetPixelBlue(q,GetPixelRed(q));
2793 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2794 SetPixelAlpha(q,ClampToQuantum(pixel));
2795 p+=quantum_info->pad;
2803 if (quantum_info->format == FloatingPointQuantumFormat)
2808 for (x=0; x < (ssize_t) number_pixels; x++)
2810 p=PushDoublePixel(quantum_info,p,&pixel);
2811 SetPixelRed(q,ClampToQuantum(pixel));
2812 SetPixelGreen(q,GetPixelRed(q));
2813 SetPixelBlue(q,GetPixelRed(q));
2814 p=PushDoublePixel(quantum_info,p,&pixel);
2815 SetPixelAlpha(q,ClampToQuantum(pixel));
2816 p+=quantum_info->pad;
2827 range=GetQuantumRange(quantum_info->depth);
2828 for (x=0; x < (ssize_t) number_pixels; x++)
2830 p=PushQuantumPixel(quantum_info,p,&pixel);
2831 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2832 SetPixelGreen(q,GetPixelRed(q));
2833 SetPixelBlue(q,GetPixelRed(q));
2834 p=PushQuantumPixel(quantum_info,p,&pixel);
2835 SetPixelAlpha(q,ScaleAnyToQuantum(pixel,range));
2836 p+=quantum_info->pad;
2844 static void ImportGreenQuantum(
QuantumInfo *quantum_info,
2845 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
2854 switch (quantum_info->depth)
2861 for (x=0; x < (ssize_t) number_pixels; x++)
2863 p=PushCharPixel(p,&pixel);
2864 SetPixelGreen(q,ScaleCharToQuantum(pixel));
2865 p+=quantum_info->pad;
2875 if (quantum_info->format == FloatingPointQuantumFormat)
2877 for (x=0; x < (ssize_t) number_pixels; x++)
2879 p=PushShortPixel(quantum_info->endian,p,&pixel);
2880 SetPixelGreen(q,ClampToQuantum((MagickRealType)
2881 QuantumRange*HalfToSinglePrecision(pixel)));
2882 p+=quantum_info->pad;
2887 for (x=0; x < (ssize_t) number_pixels; x++)
2889 p=PushShortPixel(quantum_info->endian,p,&pixel);
2890 SetPixelGreen(q,ScaleShortToQuantum(pixel));
2891 p+=quantum_info->pad;
2898 if (quantum_info->format == FloatingPointQuantumFormat)
2903 for (x=0; x < (ssize_t) number_pixels; x++)
2905 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2906 SetPixelGreen(q,ClampToQuantum(pixel));
2907 p+=quantum_info->pad;
2912 for (x=0; x < (ssize_t) number_pixels; x++)
2914 p=PushLongPixel(quantum_info->endian,p,&pixel);
2915 SetPixelGreen(q,ScaleLongToQuantum(pixel));
2916 p+=quantum_info->pad;
2923 if (quantum_info->format == FloatingPointQuantumFormat)
2928 for (x=0; x < (ssize_t) number_pixels; x++)
2930 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2931 SetPixelGreen(q,ClampToQuantum(pixel));
2932 p+=quantum_info->pad;
2940 if (quantum_info->format == FloatingPointQuantumFormat)
2945 for (x=0; x < (ssize_t) number_pixels; x++)
2947 p=PushDoublePixel(quantum_info,p,&pixel);
2948 SetPixelGreen(q,ClampToQuantum(pixel));
2949 p+=quantum_info->pad;
2960 range=GetQuantumRange(quantum_info->depth);
2961 for (x=0; x < (ssize_t) number_pixels; x++)
2963 p=PushQuantumPixel(quantum_info,p,&pixel);
2964 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
2965 p+=quantum_info->pad;
2973 static void ImportIndexQuantum(
const Image *image,
QuantumInfo *quantum_info,
2974 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
2975 PixelPacket *magick_restrict q,IndexPacket *magick_restrict indexes,
2990 if (image->storage_class != PseudoClass)
2992 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
2993 "ColormappedImageRequired",
"`%s'",image->filename);
2996 range_exception=MagickFalse;
2997 switch (quantum_info->depth)
3004 for (x=0; x < ((ssize_t) number_pixels-7); x+=8)
3006 for (bit=0; bit < 8; bit++)
3008 if (quantum_info->min_is_white == MagickFalse)
3009 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) == 0 ? 0x00 : 0x01);
3011 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
3012 SetPixelIndex(indexes+x+bit,PushColormapIndex(image,pixel,
3014 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(
3020 for (bit=0; bit < (ssize_t) (number_pixels % 8); bit++)
3022 if (quantum_info->min_is_white == MagickFalse)
3023 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) == 0 ? 0x00 : 0x01);
3025 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
3026 SetPixelIndex(indexes+x+bit,PushColormapIndex(image,pixel,
3028 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x+bit));
3038 for (x=0; x < ((ssize_t) number_pixels-1); x+=2)
3040 pixel=(
unsigned char) ((*p >> 4) & 0xf);
3041 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3043 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3045 pixel=(
unsigned char) ((*p) & 0xf);
3046 SetPixelIndex(indexes+x+1,PushColormapIndex(image,pixel,
3048 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x+1));
3052 for (bit=0; bit < (ssize_t) (number_pixels % 2); bit++)
3054 pixel=(
unsigned char) ((*p++ >> 4) & 0xf);
3055 SetPixelIndex(indexes+x+bit,PushColormapIndex(image,pixel,
3057 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x+bit));
3067 for (x=0; x < (ssize_t) number_pixels; x++)
3069 p=PushCharPixel(p,&pixel);
3070 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3072 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3073 p+=quantum_info->pad;
3083 if (quantum_info->format == FloatingPointQuantumFormat)
3085 for (x=0; x < (ssize_t) number_pixels; x++)
3087 p=PushShortPixel(quantum_info->endian,p,&pixel);
3088 SetPixelIndex(indexes+x,PushColormapIndex(image,(
size_t)
3089 ClampToQuantum((MagickRealType) QuantumRange*
3090 HalfToSinglePrecision(pixel)),&range_exception));
3091 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3092 p+=quantum_info->pad;
3097 for (x=0; x < (ssize_t) number_pixels; x++)
3099 p=PushShortPixel(quantum_info->endian,p,&pixel);
3100 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3102 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3103 p+=quantum_info->pad;
3110 if (quantum_info->format == FloatingPointQuantumFormat)
3115 for (x=0; x < (ssize_t) number_pixels; x++)
3117 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3118 SetPixelIndex(indexes+x,PushColormapIndex(image,(
size_t)
3119 ClampToQuantum(pixel),&range_exception));
3120 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3121 p+=quantum_info->pad;
3126 for (x=0; x < (ssize_t) number_pixels; x++)
3128 p=PushLongPixel(quantum_info->endian,p,&pixel);
3129 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3131 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3132 p+=quantum_info->pad;
3139 if (quantum_info->format == FloatingPointQuantumFormat)
3144 for (x=0; x < (ssize_t) number_pixels; x++)
3146 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3147 SetPixelIndex(indexes+x,PushColormapIndex(image,(
size_t)
3148 ClampToQuantum(pixel),&range_exception));
3149 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3150 p+=quantum_info->pad;
3158 if (quantum_info->format == FloatingPointQuantumFormat)
3163 for (x=0; x < (ssize_t) number_pixels; x++)
3165 p=PushDoublePixel(quantum_info,p,&pixel);
3166 SetPixelIndex(indexes+x,PushColormapIndex(image,(
size_t)
3167 ClampToQuantum(pixel),&range_exception));
3168 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3169 p+=quantum_info->pad;
3177 for (x=0; x < (ssize_t) number_pixels; x++)
3179 p=PushQuantumPixel(quantum_info,p,&pixel);
3180 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3182 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3183 p+=quantum_info->pad;
3189 if (range_exception != MagickFalse)
3190 (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError,
3191 "InvalidColormapIndex",
"`%s'",image->filename);
3194 static void ImportIndexAlphaQuantum(
const Image *image,
3195 QuantumInfo *quantum_info,
const MagickSizeType number_pixels,
3196 const unsigned char *magick_restrict p,
PixelPacket *magick_restrict q,
3197 IndexPacket *magick_restrict indexes,
ExceptionInfo *exception)
3214 if (image->storage_class != PseudoClass)
3216 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
3217 "ColormappedImageRequired",
"`%s'",image->filename);
3220 range_exception=MagickFalse;
3221 switch (quantum_info->depth)
3228 for (x=((ssize_t) number_pixels-3); x > 0; x-=4)
3230 for (bit=0; bit < 8; bit+=2)
3232 if (quantum_info->min_is_white == MagickFalse)
3233 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) == 0 ? 0x00 : 0x01);
3235 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
3236 SetPixelIndex(indexes+x+bit/2,pixel == 0 ? 0 : 1);
3237 SetPixelRed(q,pixel == 0 ? 0 : QuantumRange);
3238 SetPixelGreen(q,GetPixelRed(q));
3239 SetPixelBlue(q,GetPixelRed(q));
3240 SetPixelOpacity(q,((*p) & (1UL << (
unsigned char) (6-bit))) == 0 ?
3241 TransparentOpacity : OpaqueOpacity);
3245 if ((number_pixels % 4) != 0)
3246 for (bit=0; bit < (ssize_t) (number_pixels % 4); bit+=2)
3248 if (quantum_info->min_is_white == MagickFalse)
3249 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) == 0 ? 0x00 : 0x01);
3251 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
3252 SetPixelIndex(indexes+x+bit/2,pixel == 0 ? 0 : 1);
3253 SetPixelRed(q,pixel == 0 ? 0 : QuantumRange);
3254 SetPixelGreen(q,GetPixelRed(q));
3255 SetPixelBlue(q,GetPixelRed(q));
3256 SetPixelOpacity(q,((*p) & (1UL << (
unsigned char) (6-bit))) == 0 ?
3257 TransparentOpacity : OpaqueOpacity);
3267 range=GetQuantumRange(quantum_info->depth);
3268 for (x=0; x < (ssize_t) number_pixels; x++)
3270 pixel=(
unsigned char) ((*p >> 4) & 0xf);
3271 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3273 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3274 pixel=(
unsigned char) ((*p) & 0xf);
3275 SetPixelAlpha(q,ScaleAnyToQuantum(pixel,range));
3286 for (x=0; x < (ssize_t) number_pixels; x++)
3288 p=PushCharPixel(p,&pixel);
3289 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3291 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3292 p=PushCharPixel(p,&pixel);
3293 SetPixelAlpha(q,ScaleCharToQuantum(pixel));
3294 p+=quantum_info->pad;
3304 if (quantum_info->format == FloatingPointQuantumFormat)
3306 for (x=0; x < (ssize_t) number_pixels; x++)
3308 p=PushShortPixel(quantum_info->endian,p,&pixel);
3309 SetPixelIndex(indexes+x,PushColormapIndex(image,(
size_t)
3310 ClampToQuantum((MagickRealType) QuantumRange*
3311 HalfToSinglePrecision(pixel)),&range_exception));
3312 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3313 p=PushShortPixel(quantum_info->endian,p,&pixel);
3314 SetPixelAlpha(q,ClampToQuantum((MagickRealType) QuantumRange*
3315 HalfToSinglePrecision(pixel)));
3316 p+=quantum_info->pad;
3321 for (x=0; x < (ssize_t) number_pixels; x++)
3323 p=PushShortPixel(quantum_info->endian,p,&pixel);
3324 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3326 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3327 p=PushShortPixel(quantum_info->endian,p,&pixel);
3328 SetPixelAlpha(q,ScaleShortToQuantum(pixel));
3329 p+=quantum_info->pad;
3336 if (quantum_info->format == FloatingPointQuantumFormat)
3341 for (x=0; x < (ssize_t) number_pixels; x++)
3343 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3344 SetPixelIndex(indexes+x,PushColormapIndex(image,(
size_t)
3345 ClampToQuantum(pixel),&range_exception));
3346 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3347 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3348 SetPixelAlpha(q,ClampToQuantum(pixel));
3349 p+=quantum_info->pad;
3354 for (x=0; x < (ssize_t) number_pixels; x++)
3356 p=PushLongPixel(quantum_info->endian,p,&pixel);
3357 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3359 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3360 p=PushLongPixel(quantum_info->endian,p,&pixel);
3361 SetPixelAlpha(q,ScaleLongToQuantum(pixel));
3362 p+=quantum_info->pad;
3369 if (quantum_info->format == FloatingPointQuantumFormat)
3374 for (x=0; x < (ssize_t) number_pixels; x++)
3376 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3377 SetPixelIndex(indexes+x,PushColormapIndex(image,(
size_t)
3378 ClampToQuantum(pixel),&range_exception));
3379 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3380 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3381 SetPixelAlpha(q,ClampToQuantum(pixel));
3382 p+=quantum_info->pad;
3390 if (quantum_info->format == FloatingPointQuantumFormat)
3395 for (x=0; x < (ssize_t) number_pixels; x++)
3397 p=PushDoublePixel(quantum_info,p,&pixel);
3398 SetPixelIndex(indexes+x,PushColormapIndex(image,(
size_t)
3399 ClampToQuantum(pixel),&range_exception));
3400 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3401 p=PushDoublePixel(quantum_info,p,&pixel);
3402 SetPixelAlpha(q,ClampToQuantum(pixel));
3403 p+=quantum_info->pad;
3411 range=GetQuantumRange(quantum_info->depth);
3412 for (x=0; x < (ssize_t) number_pixels; x++)
3414 p=PushQuantumPixel(quantum_info,p,&pixel);
3415 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3417 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3418 p=PushQuantumPixel(quantum_info,p,&pixel);
3419 SetPixelAlpha(q,ScaleAnyToQuantum(pixel,range));
3420 p+=quantum_info->pad;
3426 if (range_exception != MagickFalse)
3427 (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError,
3428 "InvalidColormapIndex",
"`%s'",image->filename);
3431 static void ImportRedQuantum(
QuantumInfo *quantum_info,
3432 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
3441 switch (quantum_info->depth)
3448 for (x=0; x < (ssize_t) number_pixels; x++)
3450 p=PushCharPixel(p,&pixel);
3451 SetPixelRed(q,ScaleCharToQuantum(pixel));
3452 p+=quantum_info->pad;
3462 if (quantum_info->format == FloatingPointQuantumFormat)
3464 for (x=0; x < (ssize_t) number_pixels; x++)
3466 p=PushShortPixel(quantum_info->endian,p,&pixel);
3467 SetPixelRed(q,ClampToQuantum((MagickRealType)
3468 QuantumRange*HalfToSinglePrecision(pixel)));
3469 p+=quantum_info->pad;
3474 for (x=0; x < (ssize_t) number_pixels; x++)
3476 p=PushShortPixel(quantum_info->endian,p,&pixel);
3477 SetPixelRed(q,ScaleShortToQuantum(pixel));
3478 p+=quantum_info->pad;
3485 if (quantum_info->format == FloatingPointQuantumFormat)
3490 for (x=0; x < (ssize_t) number_pixels; x++)
3492 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3493 SetPixelRed(q,ClampToQuantum(pixel));
3494 p+=quantum_info->pad;
3499 for (x=0; x < (ssize_t) number_pixels; x++)
3501 p=PushLongPixel(quantum_info->endian,p,&pixel);
3502 SetPixelRed(q,ScaleLongToQuantum(pixel));
3503 p+=quantum_info->pad;
3510 if (quantum_info->format == FloatingPointQuantumFormat)
3515 for (x=0; x < (ssize_t) number_pixels; x++)
3517 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3518 SetPixelRed(q,ClampToQuantum(pixel));
3519 p+=quantum_info->pad;
3527 if (quantum_info->format == FloatingPointQuantumFormat)
3532 for (x=0; x < (ssize_t) number_pixels; x++)
3534 p=PushDoublePixel(quantum_info,p,&pixel);
3535 SetPixelRed(q,ClampToQuantum(pixel));
3536 p+=quantum_info->pad;
3547 range=GetQuantumRange(quantum_info->depth);
3548 for (x=0; x < (ssize_t) number_pixels; x++)
3550 p=PushQuantumPixel(quantum_info,p,&pixel);
3551 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
3552 p+=quantum_info->pad;
3560 static void ImportRGBQuantum(
QuantumInfo *quantum_info,
3561 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
3576 switch (quantum_info->depth)
3583 for (x=0; x < (ssize_t) number_pixels; x++)
3585 p=PushCharPixel(p,&pixel);
3586 SetPixelRed(q,ScaleCharToQuantum(pixel));
3587 p=PushCharPixel(p,&pixel);
3588 SetPixelGreen(q,ScaleCharToQuantum(pixel));
3589 p=PushCharPixel(p,&pixel);
3590 SetPixelBlue(q,ScaleCharToQuantum(pixel));
3591 SetPixelOpacity(q,OpaqueOpacity);
3592 p+=quantum_info->pad;
3599 range=GetQuantumRange(quantum_info->depth);
3600 if (quantum_info->pack == MagickFalse)
3602 for (x=0; x < (ssize_t) number_pixels; x++)
3604 p=PushLongPixel(quantum_info->endian,p,&pixel);
3605 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range));
3606 SetPixelGreen(q,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range));
3607 SetPixelBlue(q,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range));
3608 p+=quantum_info->pad;
3613 if (quantum_info->quantum == 32U)
3615 for (x=0; x < (ssize_t) number_pixels; x++)
3617 p=PushQuantumLongPixel(quantum_info,p,&pixel);
3618 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
3619 p=PushQuantumLongPixel(quantum_info,p,&pixel);
3620 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
3621 p=PushQuantumLongPixel(quantum_info,p,&pixel);
3622 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
3627 for (x=0; x < (ssize_t) number_pixels; x++)
3629 p=PushQuantumPixel(quantum_info,p,&pixel);
3630 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
3631 p=PushQuantumPixel(quantum_info,p,&pixel);
3632 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
3633 p=PushQuantumPixel(quantum_info,p,&pixel);
3634 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
3641 range=GetQuantumRange(quantum_info->depth);
3642 if (quantum_info->pack == MagickFalse)
3647 for (x=0; x < (ssize_t) (3*number_pixels-1); x+=2)
3649 p=PushShortPixel(quantum_info->endian,p,&pixel);
3655 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3661 SetPixelGreen(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3667 SetPixelBlue(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3673 p=PushShortPixel(quantum_info->endian,p,&pixel);
3679 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3685 SetPixelGreen(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3691 SetPixelBlue(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3697 p+=quantum_info->pad;
3699 for (bit=0; bit < (ssize_t) (3*number_pixels % 2); bit++)
3701 p=PushShortPixel(quantum_info->endian,p,&pixel);
3702 switch ((x+bit) % 3)
3707 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3713 SetPixelGreen(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3719 SetPixelBlue(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3725 p+=quantum_info->pad;
3731 if (quantum_info->quantum == 32U)
3733 for (x=0; x < (ssize_t) number_pixels; x++)
3735 p=PushQuantumLongPixel(quantum_info,p,&pixel);
3736 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
3737 p=PushQuantumLongPixel(quantum_info,p,&pixel);
3738 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
3739 p=PushQuantumLongPixel(quantum_info,p,&pixel);
3740 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
3745 for (x=0; x < (ssize_t) number_pixels; x++)
3747 p=PushQuantumPixel(quantum_info,p,&pixel);
3748 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
3749 p=PushQuantumPixel(quantum_info,p,&pixel);
3750 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
3751 p=PushQuantumPixel(quantum_info,p,&pixel);
3752 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
3762 if (quantum_info->format == FloatingPointQuantumFormat)
3764 for (x=0; x < (ssize_t) number_pixels; x++)
3766 p=PushShortPixel(quantum_info->endian,p,&pixel);
3767 SetPixelRed(q,ClampToQuantum((MagickRealType) QuantumRange*
3768 HalfToSinglePrecision(pixel)));
3769 p=PushShortPixel(quantum_info->endian,p,&pixel);
3770 SetPixelGreen(q,ClampToQuantum((MagickRealType) QuantumRange*
3771 HalfToSinglePrecision(pixel)));
3772 p=PushShortPixel(quantum_info->endian,p,&pixel);
3773 SetPixelBlue(q,ClampToQuantum((MagickRealType) QuantumRange*
3774 HalfToSinglePrecision(pixel)));
3775 p+=quantum_info->pad;
3780 for (x=0; x < (ssize_t) number_pixels; x++)
3782 p=PushShortPixel(quantum_info->endian,p,&pixel);
3783 SetPixelRed(q,ScaleShortToQuantum(pixel));
3784 p=PushShortPixel(quantum_info->endian,p,&pixel);
3785 SetPixelGreen(q,ScaleShortToQuantum(pixel));
3786 p=PushShortPixel(quantum_info->endian,p,&pixel);
3787 SetPixelBlue(q,ScaleShortToQuantum(pixel));
3788 p+=quantum_info->pad;
3795 if (quantum_info->format == FloatingPointQuantumFormat)
3800 for (x=0; x < (ssize_t) number_pixels; x++)
3802 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3803 SetPixelRed(q,ClampToQuantum(pixel));
3804 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3805 SetPixelGreen(q,ClampToQuantum(pixel));
3806 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3807 SetPixelBlue(q,ClampToQuantum(pixel));
3808 p+=quantum_info->pad;
3813 for (x=0; x < (ssize_t) number_pixels; x++)
3815 p=PushLongPixel(quantum_info->endian,p,&pixel);
3816 SetPixelRed(q,ScaleLongToQuantum(pixel));
3817 p=PushLongPixel(quantum_info->endian,p,&pixel);
3818 SetPixelGreen(q,ScaleLongToQuantum(pixel));
3819 p=PushLongPixel(quantum_info->endian,p,&pixel);
3820 SetPixelBlue(q,ScaleLongToQuantum(pixel));
3821 p+=quantum_info->pad;
3828 if (quantum_info->format == FloatingPointQuantumFormat)
3833 for (x=0; x < (ssize_t) number_pixels; x++)
3835 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3836 SetPixelRed(q,ClampToQuantum(pixel));
3837 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3838 SetPixelGreen(q,ClampToQuantum(pixel));
3839 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3840 SetPixelBlue(q,ClampToQuantum(pixel));
3841 p+=quantum_info->pad;
3849 if (quantum_info->format == FloatingPointQuantumFormat)
3854 for (x=0; x < (ssize_t) number_pixels; x++)
3856 p=PushDoublePixel(quantum_info,p,&pixel);
3857 SetPixelRed(q,ClampToQuantum(pixel));
3858 p=PushDoublePixel(quantum_info,p,&pixel);
3859 SetPixelGreen(q,ClampToQuantum(pixel));
3860 p=PushDoublePixel(quantum_info,p,&pixel);
3861 SetPixelBlue(q,ClampToQuantum(pixel));
3862 p+=quantum_info->pad;
3870 range=GetQuantumRange(quantum_info->depth);
3871 for (x=0; x < (ssize_t) number_pixels; x++)
3873 p=PushQuantumPixel(quantum_info,p,&pixel);
3874 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
3875 p=PushQuantumPixel(quantum_info,p,&pixel);
3876 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
3877 p=PushQuantumPixel(quantum_info,p,&pixel);
3878 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
3886 static void ImportRGBAQuantum(
QuantumInfo *quantum_info,
3887 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
3899 switch (quantum_info->depth)
3906 for (x=0; x < (ssize_t) number_pixels; x++)
3908 p=PushCharPixel(p,&pixel);
3909 SetPixelRed(q,ScaleCharToQuantum(pixel));
3910 p=PushCharPixel(p,&pixel);
3911 SetPixelGreen(q,ScaleCharToQuantum(pixel));
3912 p=PushCharPixel(p,&pixel);
3913 SetPixelBlue(q,ScaleCharToQuantum(pixel));
3914 p=PushCharPixel(p,&pixel);
3915 SetPixelAlpha(q,ScaleCharToQuantum(pixel));
3916 p+=quantum_info->pad;
3924 if (quantum_info->pack == MagickFalse)
3937 for (x=0; x < (ssize_t) number_pixels; x++)
3939 for (i=0; i < 4; i++)
3945 p=PushLongPixel(quantum_info->endian,p,&pixel);
3946 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
3947 (((pixel >> 22) & 0x3ff) << 6)));
3952 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
3953 (((pixel >> 12) & 0x3ff) << 6)));
3958 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
3959 (((pixel >> 2) & 0x3ff) << 6)));
3965 case 0: SetPixelRed(q,quantum);
break;
3966 case 1: SetPixelGreen(q,quantum);
break;
3967 case 2: SetPixelBlue(q,quantum);
break;
3968 case 3: SetPixelAlpha(q,quantum);
break;
3972 p+=quantum_info->pad;
3977 for (x=0; x < (ssize_t) number_pixels; x++)
3979 p=PushQuantumPixel(quantum_info,p,&pixel);
3980 SetPixelRed(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
3981 p=PushQuantumPixel(quantum_info,p,&pixel);
3982 SetPixelGreen(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
3983 p=PushQuantumPixel(quantum_info,p,&pixel);
3984 SetPixelBlue(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
3985 p=PushQuantumPixel(quantum_info,p,&pixel);
3986 SetPixelAlpha(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
3996 if (quantum_info->format == FloatingPointQuantumFormat)
3998 for (x=0; x < (ssize_t) number_pixels; x++)
4000 p=PushShortPixel(quantum_info->endian,p,&pixel);
4001 SetPixelRed(q,ClampToQuantum((MagickRealType) QuantumRange*
4002 HalfToSinglePrecision(pixel)));
4003 p=PushShortPixel(quantum_info->endian,p,&pixel);
4004 SetPixelGreen(q,ClampToQuantum((MagickRealType) QuantumRange*
4005 HalfToSinglePrecision(pixel)));
4006 p=PushShortPixel(quantum_info->endian,p,&pixel);
4007 SetPixelBlue(q,ClampToQuantum((MagickRealType) QuantumRange*
4008 HalfToSinglePrecision(pixel)));
4009 p=PushShortPixel(quantum_info->endian,p,&pixel);
4010 SetPixelAlpha(q,ClampToQuantum((MagickRealType) QuantumRange*
4011 HalfToSinglePrecision(pixel)));
4012 p+=quantum_info->pad;
4017 for (x=0; x < (ssize_t) number_pixels; x++)
4019 p=PushShortPixel(quantum_info->endian,p,&pixel);
4020 SetPixelRed(q,ScaleShortToQuantum(pixel));
4021 p=PushShortPixel(quantum_info->endian,p,&pixel);
4022 SetPixelGreen(q,ScaleShortToQuantum(pixel));
4023 p=PushShortPixel(quantum_info->endian,p,&pixel);
4024 SetPixelBlue(q,ScaleShortToQuantum(pixel));
4025 p=PushShortPixel(quantum_info->endian,p,&pixel);
4026 SetPixelAlpha(q,ScaleShortToQuantum(pixel));
4027 p+=quantum_info->pad;
4034 if (quantum_info->format == FloatingPointQuantumFormat)
4039 for (x=0; x < (ssize_t) number_pixels; x++)
4041 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4042 SetPixelRed(q,ClampToQuantum(pixel));
4043 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4044 SetPixelGreen(q,ClampToQuantum(pixel));
4045 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4046 SetPixelBlue(q,ClampToQuantum(pixel));
4047 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4048 SetPixelAlpha(q,ClampToQuantum(pixel));
4049 p+=quantum_info->pad;
4054 for (x=0; x < (ssize_t) number_pixels; x++)
4056 p=PushLongPixel(quantum_info->endian,p,&pixel);
4057 SetPixelRed(q,ScaleLongToQuantum(pixel));
4058 p=PushLongPixel(quantum_info->endian,p,&pixel);
4059 SetPixelGreen(q,ScaleLongToQuantum(pixel));
4060 p=PushLongPixel(quantum_info->endian,p,&pixel);
4061 SetPixelBlue(q,ScaleLongToQuantum(pixel));
4062 p=PushLongPixel(quantum_info->endian,p,&pixel);
4063 SetPixelAlpha(q,ScaleLongToQuantum(pixel));
4064 p+=quantum_info->pad;
4071 if (quantum_info->format == FloatingPointQuantumFormat)
4076 for (x=0; x < (ssize_t) number_pixels; x++)
4078 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4079 SetPixelRed(q,ClampToQuantum(pixel));
4080 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4081 SetPixelGreen(q,ClampToQuantum(pixel));
4082 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4083 SetPixelBlue(q,ClampToQuantum(pixel));
4084 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4085 SetPixelAlpha(q,ClampToQuantum(pixel));
4086 p+=quantum_info->pad;
4094 if (quantum_info->format == FloatingPointQuantumFormat)
4099 for (x=0; x < (ssize_t) number_pixels; x++)
4101 p=PushDoublePixel(quantum_info,p,&pixel);
4102 SetPixelRed(q,ClampToQuantum(pixel));
4103 p=PushDoublePixel(quantum_info,p,&pixel);
4104 SetPixelGreen(q,ClampToQuantum(pixel));
4105 p=PushDoublePixel(quantum_info,p,&pixel);
4106 SetPixelBlue(q,ClampToQuantum(pixel));
4107 p=PushDoublePixel(quantum_info,p,&pixel);
4108 SetPixelAlpha(q,ClampToQuantum(pixel));
4109 p+=quantum_info->pad;
4117 range=GetQuantumRange(quantum_info->depth);
4118 for (x=0; x < (ssize_t) number_pixels; x++)
4120 p=PushQuantumPixel(quantum_info,p,&pixel);
4121 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
4122 p=PushQuantumPixel(quantum_info,p,&pixel);
4123 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
4124 p=PushQuantumPixel(quantum_info,p,&pixel);
4125 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
4126 p=PushQuantumPixel(quantum_info,p,&pixel);
4127 SetPixelAlpha(q,ScaleAnyToQuantum(pixel,range));
4135 static void ImportRGBOQuantum(
QuantumInfo *quantum_info,
4136 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
4148 switch (quantum_info->depth)
4155 for (x=0; x < (ssize_t) number_pixels; x++)
4157 p=PushCharPixel(p,&pixel);
4158 SetPixelRed(q,ScaleCharToQuantum(pixel));
4159 p=PushCharPixel(p,&pixel);
4160 SetPixelGreen(q,ScaleCharToQuantum(pixel));
4161 p=PushCharPixel(p,&pixel);
4162 SetPixelBlue(q,ScaleCharToQuantum(pixel));
4163 p=PushCharPixel(p,&pixel);
4164 SetPixelOpacity(q,ScaleCharToQuantum(pixel));
4165 p+=quantum_info->pad;
4173 if (quantum_info->pack == MagickFalse)
4186 for (x=0; x < (ssize_t) number_pixels; x++)
4188 for (i=0; i < 4; i++)
4194 p=PushLongPixel(quantum_info->endian,p,&pixel);
4195 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
4196 (((pixel >> 22) & 0x3ff) << 6)));
4201 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
4202 (((pixel >> 12) & 0x3ff) << 6)));
4207 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
4208 (((pixel >> 2) & 0x3ff) << 6)));
4214 case 0: SetPixelRed(q,quantum);
break;
4215 case 1: SetPixelGreen(q,quantum);
break;
4216 case 2: SetPixelBlue(q,quantum);
break;
4217 case 3: SetPixelOpacity(q,quantum);
break;
4221 p+=quantum_info->pad;
4226 for (x=0; x < (ssize_t) number_pixels; x++)
4228 p=PushQuantumPixel(quantum_info,p,&pixel);
4229 SetPixelRed(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
4230 p=PushQuantumPixel(quantum_info,p,&pixel);
4231 SetPixelGreen(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
4232 p=PushQuantumPixel(quantum_info,p,&pixel);
4233 SetPixelBlue(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
4234 p=PushQuantumPixel(quantum_info,p,&pixel);
4235 SetPixelOpacity(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
4245 if (quantum_info->format == FloatingPointQuantumFormat)
4247 for (x=0; x < (ssize_t) number_pixels; x++)
4249 p=PushShortPixel(quantum_info->endian,p,&pixel);
4250 SetPixelRed(q,ClampToQuantum((MagickRealType) QuantumRange*
4251 HalfToSinglePrecision(pixel)));
4252 p=PushShortPixel(quantum_info->endian,p,&pixel);
4253 SetPixelGreen(q,ClampToQuantum((MagickRealType) QuantumRange*
4254 HalfToSinglePrecision(pixel)));
4255 p=PushShortPixel(quantum_info->endian,p,&pixel);
4256 SetPixelBlue(q,ClampToQuantum((MagickRealType) QuantumRange*
4257 HalfToSinglePrecision(pixel)));
4258 p=PushShortPixel(quantum_info->endian,p,&pixel);
4259 SetPixelOpacity(q,ClampToQuantum((MagickRealType) QuantumRange*
4260 HalfToSinglePrecision(pixel)));
4261 p+=quantum_info->pad;
4266 for (x=0; x < (ssize_t) number_pixels; x++)
4268 p=PushShortPixel(quantum_info->endian,p,&pixel);
4269 SetPixelRed(q,ScaleShortToQuantum(pixel));
4270 p=PushShortPixel(quantum_info->endian,p,&pixel);
4271 SetPixelGreen(q,ScaleShortToQuantum(pixel));
4272 p=PushShortPixel(quantum_info->endian,p,&pixel);
4273 SetPixelBlue(q,ScaleShortToQuantum(pixel));
4274 p=PushShortPixel(quantum_info->endian,p,&pixel);
4275 SetPixelOpacity(q,ScaleShortToQuantum(pixel));
4276 p+=quantum_info->pad;
4283 if (quantum_info->format == FloatingPointQuantumFormat)
4288 for (x=0; x < (ssize_t) number_pixels; x++)
4290 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4291 SetPixelRed(q,ClampToQuantum(pixel));
4292 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4293 SetPixelGreen(q,ClampToQuantum(pixel));
4294 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4295 SetPixelBlue(q,ClampToQuantum(pixel));
4296 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4297 SetPixelOpacity(q,ClampToQuantum(pixel));
4298 p+=quantum_info->pad;
4303 for (x=0; x < (ssize_t) number_pixels; x++)
4305 p=PushLongPixel(quantum_info->endian,p,&pixel);
4306 SetPixelRed(q,ScaleLongToQuantum(pixel));
4307 p=PushLongPixel(quantum_info->endian,p,&pixel);
4308 SetPixelGreen(q,ScaleLongToQuantum(pixel));
4309 p=PushLongPixel(quantum_info->endian,p,&pixel);
4310 SetPixelBlue(q,ScaleLongToQuantum(pixel));
4311 p=PushLongPixel(quantum_info->endian,p,&pixel);
4312 SetPixelOpacity(q,ScaleLongToQuantum(pixel));
4313 p+=quantum_info->pad;
4320 if (quantum_info->format == FloatingPointQuantumFormat)
4325 for (x=0; x < (ssize_t) number_pixels; x++)
4327 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4328 SetPixelRed(q,ClampToQuantum(pixel));
4329 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4330 SetPixelGreen(q,ClampToQuantum(pixel));
4331 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4332 SetPixelBlue(q,ClampToQuantum(pixel));
4333 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4334 SetPixelOpacity(q,ClampToQuantum(pixel));
4335 p+=quantum_info->pad;
4343 if (quantum_info->format == FloatingPointQuantumFormat)
4348 for (x=0; x < (ssize_t) number_pixels; x++)
4350 p=PushDoublePixel(quantum_info,p,&pixel);
4351 SetPixelRed(q,ClampToQuantum(pixel));
4352 p=PushDoublePixel(quantum_info,p,&pixel);
4353 SetPixelGreen(q,ClampToQuantum(pixel));
4354 p=PushDoublePixel(quantum_info,p,&pixel);
4355 SetPixelBlue(q,ClampToQuantum(pixel));
4356 p=PushDoublePixel(quantum_info,p,&pixel);
4357 SetPixelOpacity(q,ClampToQuantum(pixel));
4358 p+=quantum_info->pad;
4366 range=GetQuantumRange(quantum_info->depth);
4367 for (x=0; x < (ssize_t) number_pixels; x++)
4369 p=PushQuantumPixel(quantum_info,p,&pixel);
4370 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
4371 p=PushQuantumPixel(quantum_info,p,&pixel);
4372 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
4373 p=PushQuantumPixel(quantum_info,p,&pixel);
4374 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
4375 p=PushQuantumPixel(quantum_info,p,&pixel);
4376 SetPixelOpacity(q,ScaleAnyToQuantum(pixel,range));
4384 MagickExport
size_t ImportQuantumPixels(
Image *image,
CacheView *image_view,
4385 const QuantumInfo *quantum_info,
const QuantumType quantum_type,
4386 const unsigned char *magick_restrict pixels,
ExceptionInfo *exception)
4395 *magick_restrict indexes;
4406 assert(image != (
Image *) NULL);
4407 assert(image->signature == MagickCoreSignature);
4409 assert(quantum_info->signature == MagickCoreSignature);
4410 if (IsEventLogging() != MagickFalse)
4411 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
4412 if (pixels == (
const unsigned char *) NULL)
4413 pixels=GetQuantumPixels(quantum_info);
4418 number_pixels=GetImageExtent(image);
4419 q=GetAuthenticPixelQueue(image);
4420 indexes=GetAuthenticIndexQueue(image);
4424 number_pixels=GetCacheViewExtent(image_view);
4425 q=GetCacheViewAuthenticPixelQueue(image_view);
4426 indexes=GetCacheViewAuthenticIndexQueue(image_view);
4429 extent=GetQuantumExtent(image,quantum_info,quantum_type);
4430 switch (quantum_type)
4434 ImportAlphaQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4439 ImportBGRQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4444 ImportBGRAQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4449 ImportBGROQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4454 ImportBlackQuantum(image,(
QuantumInfo *) quantum_info,number_pixels,p,q,
4461 ImportBlueQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4466 ImportCbYCrYQuantum(image,(
QuantumInfo *) quantum_info,number_pixels,p,
4472 ImportCMYKQuantum(image,(
QuantumInfo *) quantum_info,number_pixels,p,q,
4478 ImportCMYKAQuantum(image,(
QuantumInfo *) quantum_info,number_pixels,p,q,
4484 ImportCMYKOQuantum(image,(
QuantumInfo *) quantum_info,number_pixels,p,q,
4490 ImportGrayQuantum(image,(
QuantumInfo *) quantum_info,number_pixels,p,q);
4493 case GrayAlphaQuantum:
4495 ImportGrayAlphaQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4499 case MagentaQuantum:
4501 ImportGreenQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4506 ImportIndexQuantum(image,(
QuantumInfo *) quantum_info,number_pixels,p,q,
4510 case IndexAlphaQuantum:
4512 ImportIndexAlphaQuantum(image,(
QuantumInfo *) quantum_info,number_pixels,
4513 p,q,indexes,exception);
4519 ImportRedQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4525 ImportRGBQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4531 ImportRGBAQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4536 ImportRGBOQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4542 if ((quantum_type == CbYCrQuantum) || (quantum_type == CbYCrAQuantum))
4550 q=GetAuthenticPixelQueue(image);
4552 q=GetCacheViewAuthenticPixelQueue(image_view);
4553 for (x=0; x < (ssize_t) number_pixels; x++)
4555 quantum=GetPixelRed(q);
4556 SetPixelRed(q,GetPixelGreen(q));
4557 SetPixelGreen(q,quantum);
4561 if (quantum_info->alpha_type == AssociatedQuantumAlpha)
4572 q=GetAuthenticPixelQueue(image);
4574 q=GetCacheViewAuthenticPixelQueue(image_view);
4575 indexes=GetAuthenticIndexQueue(image);
4576 for (x=0; x < (ssize_t) number_pixels; x++)
4578 alpha=QuantumScale*GetPixelAlpha(q);
4579 alpha=PerceptibleReciprocal(alpha);
4580 SetPixelRed(q,ClampToQuantum(alpha*GetPixelRed(q)));
4581 SetPixelGreen(q,ClampToQuantum(alpha*GetPixelGreen(q)));
4582 SetPixelBlue(q,ClampToQuantum(alpha*GetPixelBlue(q)));
4583 if (image->colorspace == CMYKColorspace)
4584 SetPixelBlack(indexes+x,ClampToQuantum(alpha*GetPixelBlack(