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"
113static 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);
122static 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;
161static 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 < (
double) -FLT_MAX)
172 if (pixel > (
double) FLT_MAX)
177static 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);
202static 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);
242static 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)));
272static 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;
302static 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((
double) QuantumRange*(
double)
339 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;
399 if (quantum_info->format == FloatingPointQuantumFormat)
404 for (x=0; x < (ssize_t) number_pixels; x++)
406 p=PushDoublePixel(quantum_info,p,&pixel);
407 SetPixelAlpha(q,ClampToQuantum(pixel));
408 p+=quantum_info->pad;
420 range=GetQuantumRange(quantum_info->depth);
421 for (x=0; x < (ssize_t) number_pixels; x++)
423 p=PushQuantumPixel(quantum_info,p,&pixel);
424 SetPixelAlpha(q,ScaleAnyToQuantum(pixel,range));
425 p+=quantum_info->pad;
433static void ImportBGRQuantum(
QuantumInfo *quantum_info,
434 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
449 switch (quantum_info->depth)
456 for (x=0; x < (ssize_t) number_pixels; x++)
458 p=PushCharPixel(p,&pixel);
459 SetPixelBlue(q,ScaleCharToQuantum(pixel));
460 p=PushCharPixel(p,&pixel);
461 SetPixelGreen(q,ScaleCharToQuantum(pixel));
462 p=PushCharPixel(p,&pixel);
463 SetPixelRed(q,ScaleCharToQuantum(pixel));
464 SetPixelOpacity(q,OpaqueOpacity);
465 p+=quantum_info->pad;
472 range=GetQuantumRange(quantum_info->depth);
473 if (quantum_info->pack == MagickFalse)
475 for (x=0; x < (ssize_t) number_pixels; x++)
477 p=PushLongPixel(quantum_info->endian,p,&pixel);
478 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range));
479 SetPixelGreen(q,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range));
480 SetPixelBlue(q,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range));
481 p+=quantum_info->pad;
486 if (quantum_info->quantum == 32U)
488 for (x=0; x < (ssize_t) number_pixels; x++)
490 p=PushQuantumLongPixel(quantum_info,p,&pixel);
491 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
492 p=PushQuantumLongPixel(quantum_info,p,&pixel);
493 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
494 p=PushQuantumLongPixel(quantum_info,p,&pixel);
495 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
500 for (x=0; x < (ssize_t) number_pixels; x++)
502 p=PushQuantumPixel(quantum_info,p,&pixel);
503 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
504 p=PushQuantumPixel(quantum_info,p,&pixel);
505 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
506 p=PushQuantumPixel(quantum_info,p,&pixel);
507 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
514 range=GetQuantumRange(quantum_info->depth);
515 if (quantum_info->pack == MagickFalse)
520 for (x=0; x < (ssize_t) (3*number_pixels-1); x+=2)
522 p=PushShortPixel(quantum_info->endian,p,&pixel);
528 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
534 SetPixelGreen(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
540 SetPixelBlue(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
546 p=PushShortPixel(quantum_info->endian,p,&pixel);
552 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
558 SetPixelGreen(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
564 SetPixelBlue(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
570 p+=quantum_info->pad;
572 for (bit=0; bit < (ssize_t) (3*number_pixels % 2); bit++)
574 p=PushShortPixel(quantum_info->endian,p,&pixel);
580 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
586 SetPixelGreen(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
592 SetPixelBlue(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
598 p+=quantum_info->pad;
604 if (quantum_info->quantum == 32U)
606 for (x=0; x < (ssize_t) number_pixels; x++)
608 p=PushQuantumLongPixel(quantum_info,p,&pixel);
609 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
610 p=PushQuantumLongPixel(quantum_info,p,&pixel);
611 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
612 p=PushQuantumLongPixel(quantum_info,p,&pixel);
613 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
618 for (x=0; x < (ssize_t) number_pixels; x++)
620 p=PushQuantumPixel(quantum_info,p,&pixel);
621 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
622 p=PushQuantumPixel(quantum_info,p,&pixel);
623 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
624 p=PushQuantumPixel(quantum_info,p,&pixel);
625 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
635 if (quantum_info->format == FloatingPointQuantumFormat)
637 for (x=0; x < (ssize_t) number_pixels; x++)
639 p=PushShortPixel(quantum_info->endian,p,&pixel);
640 SetPixelRed(q,ClampToQuantum((
double) QuantumRange*(
double)
641 HalfToSinglePrecision(pixel)));
642 p=PushShortPixel(quantum_info->endian,p,&pixel);
643 SetPixelGreen(q,ClampToQuantum((
double) QuantumRange*(
double)
644 HalfToSinglePrecision(pixel)));
645 p=PushShortPixel(quantum_info->endian,p,&pixel);
646 SetPixelBlue(q,ClampToQuantum((
double) QuantumRange*(
double)
647 HalfToSinglePrecision(pixel)));
648 p+=quantum_info->pad;
653 for (x=0; x < (ssize_t) number_pixels; x++)
655 p=PushShortPixel(quantum_info->endian,p,&pixel);
656 SetPixelBlue(q,ScaleShortToQuantum(pixel));
657 p=PushShortPixel(quantum_info->endian,p,&pixel);
658 SetPixelGreen(q,ScaleShortToQuantum(pixel));
659 p=PushShortPixel(quantum_info->endian,p,&pixel);
660 SetPixelRed(q,ScaleShortToQuantum(pixel));
661 p+=quantum_info->pad;
668 if (quantum_info->format == FloatingPointQuantumFormat)
673 for (x=0; x < (ssize_t) number_pixels; x++)
675 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
676 SetPixelRed(q,ClampToQuantum(pixel));
677 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
678 SetPixelGreen(q,ClampToQuantum(pixel));
679 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
680 SetPixelBlue(q,ClampToQuantum(pixel));
681 p+=quantum_info->pad;
686 for (x=0; x < (ssize_t) number_pixels; x++)
688 p=PushLongPixel(quantum_info->endian,p,&pixel);
689 SetPixelBlue(q,ScaleLongToQuantum(pixel));
690 p=PushLongPixel(quantum_info->endian,p,&pixel);
691 SetPixelGreen(q,ScaleLongToQuantum(pixel));
692 p=PushLongPixel(quantum_info->endian,p,&pixel);
693 SetPixelRed(q,ScaleLongToQuantum(pixel));
694 p+=quantum_info->pad;
701 if (quantum_info->format == FloatingPointQuantumFormat)
706 for (x=0; x < (ssize_t) number_pixels; x++)
708 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
709 SetPixelRed(q,ClampToQuantum(pixel));
710 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
711 SetPixelGreen(q,ClampToQuantum(pixel));
712 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
713 SetPixelBlue(q,ClampToQuantum(pixel));
714 p+=quantum_info->pad;
723 if (quantum_info->format == FloatingPointQuantumFormat)
728 for (x=0; x < (ssize_t) number_pixels; x++)
730 p=PushDoublePixel(quantum_info,p,&pixel);
731 SetPixelRed(q,ClampToQuantum(pixel));
732 p=PushDoublePixel(quantum_info,p,&pixel);
733 SetPixelGreen(q,ClampToQuantum(pixel));
734 p=PushDoublePixel(quantum_info,p,&pixel);
735 SetPixelBlue(q,ClampToQuantum(pixel));
736 p+=quantum_info->pad;
745 range=GetQuantumRange(quantum_info->depth);
746 for (x=0; x < (ssize_t) number_pixels; x++)
748 p=PushQuantumPixel(quantum_info,p,&pixel);
749 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
750 p=PushQuantumPixel(quantum_info,p,&pixel);
751 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
752 p=PushQuantumPixel(quantum_info,p,&pixel);
753 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
761static void ImportBGRAQuantum(
QuantumInfo *quantum_info,
762 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
774 switch (quantum_info->depth)
781 for (x=0; x < (ssize_t) number_pixels; x++)
783 p=PushCharPixel(p,&pixel);
784 SetPixelBlue(q,ScaleCharToQuantum(pixel));
785 p=PushCharPixel(p,&pixel);
786 SetPixelGreen(q,ScaleCharToQuantum(pixel));
787 p=PushCharPixel(p,&pixel);
788 SetPixelRed(q,ScaleCharToQuantum(pixel));
789 p=PushCharPixel(p,&pixel);
790 SetPixelAlpha(q,ScaleCharToQuantum(pixel));
791 p+=quantum_info->pad;
799 if (quantum_info->pack == MagickFalse)
812 for (x=0; x < (ssize_t) number_pixels; x++)
814 for (i=0; i < 4; i++)
820 p=PushLongPixel(quantum_info->endian,p,&pixel);
821 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
822 (((pixel >> 22) & 0x3ff) << 6)));
827 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
828 (((pixel >> 12) & 0x3ff) << 6)));
833 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
834 (((pixel >> 2) & 0x3ff) << 6)));
840 case 0: SetPixelRed(q,quantum);
break;
841 case 1: SetPixelGreen(q,quantum);
break;
842 case 2: SetPixelBlue(q,quantum);
break;
843 case 3: SetPixelAlpha(q,quantum);
break;
847 p+=quantum_info->pad;
852 for (x=0; x < (ssize_t) number_pixels; x++)
854 p=PushQuantumPixel(quantum_info,p,&pixel);
855 SetPixelRed(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
856 p=PushQuantumPixel(quantum_info,p,&pixel);
857 SetPixelGreen(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
858 p=PushQuantumPixel(quantum_info,p,&pixel);
859 SetPixelBlue(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
860 p=PushQuantumPixel(quantum_info,p,&pixel);
861 SetPixelAlpha(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
871 if (quantum_info->format == FloatingPointQuantumFormat)
873 for (x=0; x < (ssize_t) number_pixels; x++)
875 p=PushShortPixel(quantum_info->endian,p,&pixel);
876 SetPixelRed(q,ClampToQuantum((
double) QuantumRange*(
double)
877 HalfToSinglePrecision(pixel)));
878 p=PushShortPixel(quantum_info->endian,p,&pixel);
879 SetPixelGreen(q,ClampToQuantum((
double) QuantumRange*(
double)
880 HalfToSinglePrecision(pixel)));
881 p=PushShortPixel(quantum_info->endian,p,&pixel);
882 SetPixelBlue(q,ClampToQuantum((
double) QuantumRange*(
double)
883 HalfToSinglePrecision(pixel)));
884 p=PushShortPixel(quantum_info->endian,p,&pixel);
885 SetPixelAlpha(q,ClampToQuantum((
double) QuantumRange*(
double)
886 HalfToSinglePrecision(pixel)));
887 p+=quantum_info->pad;
892 for (x=0; x < (ssize_t) number_pixels; x++)
894 p=PushShortPixel(quantum_info->endian,p,&pixel);
895 SetPixelBlue(q,ScaleShortToQuantum(pixel));
896 p=PushShortPixel(quantum_info->endian,p,&pixel);
897 SetPixelGreen(q,ScaleShortToQuantum(pixel));
898 p=PushShortPixel(quantum_info->endian,p,&pixel);
899 SetPixelRed(q,ScaleShortToQuantum(pixel));
900 p=PushShortPixel(quantum_info->endian,p,&pixel);
901 SetPixelAlpha(q,ScaleShortToQuantum(pixel));
902 p+=quantum_info->pad;
909 if (quantum_info->format == FloatingPointQuantumFormat)
914 for (x=0; x < (ssize_t) number_pixels; x++)
916 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
917 SetPixelRed(q,ClampToQuantum(pixel));
918 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
919 SetPixelGreen(q,ClampToQuantum(pixel));
920 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
921 SetPixelBlue(q,ClampToQuantum(pixel));
922 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
923 SetPixelAlpha(q,ClampToQuantum(pixel));
924 p+=quantum_info->pad;
929 for (x=0; x < (ssize_t) number_pixels; x++)
931 p=PushLongPixel(quantum_info->endian,p,&pixel);
932 SetPixelBlue(q,ScaleLongToQuantum(pixel));
933 p=PushLongPixel(quantum_info->endian,p,&pixel);
934 SetPixelGreen(q,ScaleLongToQuantum(pixel));
935 p=PushLongPixel(quantum_info->endian,p,&pixel);
936 SetPixelRed(q,ScaleLongToQuantum(pixel));
937 p=PushLongPixel(quantum_info->endian,p,&pixel);
938 SetPixelAlpha(q,ScaleLongToQuantum(pixel));
939 p+=quantum_info->pad;
946 if (quantum_info->format == FloatingPointQuantumFormat)
951 for (x=0; x < (ssize_t) number_pixels; x++)
953 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
954 SetPixelRed(q,ClampToQuantum(pixel));
955 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
956 SetPixelGreen(q,ClampToQuantum(pixel));
957 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
958 SetPixelBlue(q,ClampToQuantum(pixel));
959 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
960 SetPixelAlpha(q,ClampToQuantum(pixel));
961 p+=quantum_info->pad;
970 if (quantum_info->format == FloatingPointQuantumFormat)
975 for (x=0; x < (ssize_t) number_pixels; x++)
977 p=PushDoublePixel(quantum_info,p,&pixel);
978 SetPixelRed(q,ClampToQuantum(pixel));
979 p=PushDoublePixel(quantum_info,p,&pixel);
980 SetPixelGreen(q,ClampToQuantum(pixel));
981 p=PushDoublePixel(quantum_info,p,&pixel);
982 SetPixelBlue(q,ClampToQuantum(pixel));
983 p=PushDoublePixel(quantum_info,p,&pixel);
984 SetPixelAlpha(q,ClampToQuantum(pixel));
985 p+=quantum_info->pad;
994 range=GetQuantumRange(quantum_info->depth);
995 for (x=0; x < (ssize_t) number_pixels; x++)
997 p=PushQuantumPixel(quantum_info,p,&pixel);
998 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
999 p=PushQuantumPixel(quantum_info,p,&pixel);
1000 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
1001 p=PushQuantumPixel(quantum_info,p,&pixel);
1002 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
1003 p=PushQuantumPixel(quantum_info,p,&pixel);
1004 SetPixelAlpha(q,ScaleAnyToQuantum(pixel,range));
1012static void ImportBGROQuantum(
QuantumInfo *quantum_info,
1013 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
1025 switch (quantum_info->depth)
1032 for (x=0; x < (ssize_t) number_pixels; x++)
1034 p=PushCharPixel(p,&pixel);
1035 SetPixelBlue(q,ScaleCharToQuantum(pixel));
1036 p=PushCharPixel(p,&pixel);
1037 SetPixelGreen(q,ScaleCharToQuantum(pixel));
1038 p=PushCharPixel(p,&pixel);
1039 SetPixelRed(q,ScaleCharToQuantum(pixel));
1040 p=PushCharPixel(p,&pixel);
1041 SetPixelOpacity(q,ScaleCharToQuantum(pixel));
1042 p+=quantum_info->pad;
1050 if (quantum_info->pack == MagickFalse)
1063 for (x=0; x < (ssize_t) number_pixels; x++)
1065 for (i=0; i < 4; i++)
1071 p=PushLongPixel(quantum_info->endian,p,&pixel);
1072 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
1073 (((pixel >> 22) & 0x3ff) << 6)));
1078 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
1079 (((pixel >> 12) & 0x3ff) << 6)));
1084 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
1085 (((pixel >> 2) & 0x3ff) << 6)));
1091 case 0: SetPixelRed(q,quantum);
break;
1092 case 1: SetPixelGreen(q,quantum);
break;
1093 case 2: SetPixelBlue(q,quantum);
break;
1094 case 3: SetPixelOpacity(q,quantum);
break;
1098 p+=quantum_info->pad;
1103 for (x=0; x < (ssize_t) number_pixels; x++)
1105 p=PushQuantumPixel(quantum_info,p,&pixel);
1106 SetPixelRed(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
1107 p=PushQuantumPixel(quantum_info,p,&pixel);
1108 SetPixelGreen(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
1109 p=PushQuantumPixel(quantum_info,p,&pixel);
1110 SetPixelBlue(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
1111 p=PushQuantumPixel(quantum_info,p,&pixel);
1112 SetPixelOpacity(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
1122 if (quantum_info->format == FloatingPointQuantumFormat)
1124 for (x=0; x < (ssize_t) number_pixels; x++)
1126 p=PushShortPixel(quantum_info->endian,p,&pixel);
1127 SetPixelRed(q,ClampToQuantum((
double) QuantumRange*(
double)
1128 HalfToSinglePrecision(pixel)));
1129 p=PushShortPixel(quantum_info->endian,p,&pixel);
1130 SetPixelGreen(q,ClampToQuantum((
double) QuantumRange*(
double)
1131 HalfToSinglePrecision(pixel)));
1132 p=PushShortPixel(quantum_info->endian,p,&pixel);
1133 SetPixelBlue(q,ClampToQuantum((
double) QuantumRange*(
double)
1134 HalfToSinglePrecision(pixel)));
1135 p=PushShortPixel(quantum_info->endian,p,&pixel);
1136 SetPixelOpacity(q,ClampToQuantum((
double) QuantumRange*(
double)
1137 HalfToSinglePrecision(pixel)));
1138 p+=quantum_info->pad;
1143 for (x=0; x < (ssize_t) number_pixels; x++)
1145 p=PushShortPixel(quantum_info->endian,p,&pixel);
1146 SetPixelBlue(q,ScaleShortToQuantum(pixel));
1147 p=PushShortPixel(quantum_info->endian,p,&pixel);
1148 SetPixelGreen(q,ScaleShortToQuantum(pixel));
1149 p=PushShortPixel(quantum_info->endian,p,&pixel);
1150 SetPixelRed(q,ScaleShortToQuantum(pixel));
1151 p=PushShortPixel(quantum_info->endian,p,&pixel);
1152 SetPixelOpacity(q,ScaleShortToQuantum(pixel));
1153 p+=quantum_info->pad;
1160 if (quantum_info->format == FloatingPointQuantumFormat)
1165 for (x=0; x < (ssize_t) number_pixels; x++)
1167 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1168 SetPixelRed(q,ClampToQuantum(pixel));
1169 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1170 SetPixelGreen(q,ClampToQuantum(pixel));
1171 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1172 SetPixelBlue(q,ClampToQuantum(pixel));
1173 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1174 SetPixelOpacity(q,ClampToQuantum(pixel));
1175 p+=quantum_info->pad;
1180 for (x=0; x < (ssize_t) number_pixels; x++)
1182 p=PushLongPixel(quantum_info->endian,p,&pixel);
1183 SetPixelBlue(q,ScaleLongToQuantum(pixel));
1184 p=PushLongPixel(quantum_info->endian,p,&pixel);
1185 SetPixelGreen(q,ScaleLongToQuantum(pixel));
1186 p=PushLongPixel(quantum_info->endian,p,&pixel);
1187 SetPixelRed(q,ScaleLongToQuantum(pixel));
1188 p=PushLongPixel(quantum_info->endian,p,&pixel);
1189 SetPixelOpacity(q,ScaleLongToQuantum(pixel));
1190 p+=quantum_info->pad;
1197 if (quantum_info->format == FloatingPointQuantumFormat)
1202 for (x=0; x < (ssize_t) number_pixels; x++)
1204 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1205 SetPixelRed(q,ClampToQuantum(pixel));
1206 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1207 SetPixelGreen(q,ClampToQuantum(pixel));
1208 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1209 SetPixelBlue(q,ClampToQuantum(pixel));
1210 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1211 SetPixelOpacity(q,ClampToQuantum(pixel));
1212 p+=quantum_info->pad;
1221 if (quantum_info->format == FloatingPointQuantumFormat)
1226 for (x=0; x < (ssize_t) number_pixels; x++)
1228 p=PushDoublePixel(quantum_info,p,&pixel);
1229 SetPixelRed(q,ClampToQuantum(pixel));
1230 p=PushDoublePixel(quantum_info,p,&pixel);
1231 SetPixelGreen(q,ClampToQuantum(pixel));
1232 p=PushDoublePixel(quantum_info,p,&pixel);
1233 SetPixelBlue(q,ClampToQuantum(pixel));
1234 p=PushDoublePixel(quantum_info,p,&pixel);
1235 SetPixelOpacity(q,ClampToQuantum(pixel));
1236 p+=quantum_info->pad;
1245 range=GetQuantumRange(quantum_info->depth);
1246 for (x=0; x < (ssize_t) number_pixels; x++)
1248 p=PushQuantumPixel(quantum_info,p,&pixel);
1249 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
1250 p=PushQuantumPixel(quantum_info,p,&pixel);
1251 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
1252 p=PushQuantumPixel(quantum_info,p,&pixel);
1253 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
1254 p=PushQuantumPixel(quantum_info,p,&pixel);
1255 SetPixelOpacity(q,ScaleAnyToQuantum(pixel,range));
1263static void ImportBlackQuantum(
const Image *image,
QuantumInfo *quantum_info,
1264 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
1265 PixelPacket *magick_restrict q,IndexPacket *magick_restrict indexes,
1274 if (image->colorspace != CMYKColorspace)
1276 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1277 "ColorSeparatedImageRequired",
"`%s'",image->filename);
1280 switch (quantum_info->depth)
1287 for (x=0; x < (ssize_t) number_pixels; x++)
1289 p=PushCharPixel(p,&pixel);
1290 SetPixelIndex(indexes+x,ScaleCharToQuantum(pixel));
1291 p+=quantum_info->pad;
1300 if (quantum_info->format == FloatingPointQuantumFormat)
1302 for (x=0; x < (ssize_t) number_pixels; x++)
1304 p=PushShortPixel(quantum_info->endian,p,&pixel);
1305 SetPixelIndex(indexes+x,ClampToQuantum((
double)
1306 QuantumRange*(
double) HalfToSinglePrecision(pixel)));
1307 p+=quantum_info->pad;
1311 for (x=0; x < (ssize_t) number_pixels; x++)
1313 p=PushShortPixel(quantum_info->endian,p,&pixel);
1314 SetPixelIndex(indexes+x,ScaleShortToQuantum(pixel));
1315 p+=quantum_info->pad;
1321 if (quantum_info->format == FloatingPointQuantumFormat)
1326 for (x=0; x < (ssize_t) number_pixels; x++)
1328 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1329 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1330 p+=quantum_info->pad;
1335 for (x=0; x < (ssize_t) number_pixels; x++)
1337 p=PushLongPixel(quantum_info->endian,p,&pixel);
1338 SetPixelIndex(indexes+x,ScaleLongToQuantum(pixel));
1339 p+=quantum_info->pad;
1346 if (quantum_info->format == FloatingPointQuantumFormat)
1351 for (x=0; x < (ssize_t) number_pixels; x++)
1353 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1354 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1355 p+=quantum_info->pad;
1364 if (quantum_info->format == FloatingPointQuantumFormat)
1369 for (x=0; x < (ssize_t) number_pixels; x++)
1371 p=PushDoublePixel(quantum_info,p,&pixel);
1372 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1373 p+=quantum_info->pad;
1385 range=GetQuantumRange(quantum_info->depth);
1386 for (x=0; x < (ssize_t) number_pixels; x++)
1388 p=PushQuantumPixel(quantum_info,p,&pixel);
1389 SetPixelIndex(indexes+x,ScaleAnyToQuantum(pixel,range));
1390 p+=quantum_info->pad;
1398static void ImportBlueQuantum(
QuantumInfo *quantum_info,
1399 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
1408 switch (quantum_info->depth)
1415 for (x=0; x < (ssize_t) number_pixels; x++)
1417 p=PushCharPixel(p,&pixel);
1418 SetPixelBlue(q,ScaleCharToQuantum(pixel));
1419 p+=quantum_info->pad;
1429 if (quantum_info->format == FloatingPointQuantumFormat)
1431 for (x=0; x < (ssize_t) number_pixels; x++)
1433 p=PushShortPixel(quantum_info->endian,p,&pixel);
1434 SetPixelBlue(q,ClampToQuantum((
double) QuantumRange*(
double)
1435 HalfToSinglePrecision(pixel)));
1436 p+=quantum_info->pad;
1441 for (x=0; x < (ssize_t) number_pixels; x++)
1443 p=PushShortPixel(quantum_info->endian,p,&pixel);
1444 SetPixelBlue(q,ScaleShortToQuantum(pixel));
1445 p+=quantum_info->pad;
1452 if (quantum_info->format == FloatingPointQuantumFormat)
1457 for (x=0; x < (ssize_t) number_pixels; x++)
1459 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1460 SetPixelBlue(q,ClampToQuantum(pixel));
1461 p+=quantum_info->pad;
1466 for (x=0; x < (ssize_t) number_pixels; x++)
1468 p=PushLongPixel(quantum_info->endian,p,&pixel);
1469 SetPixelBlue(q,ScaleLongToQuantum(pixel));
1470 p+=quantum_info->pad;
1477 if (quantum_info->format == FloatingPointQuantumFormat)
1482 for (x=0; x < (ssize_t) number_pixels; x++)
1484 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1485 SetPixelBlue(q,ClampToQuantum(pixel));
1486 p+=quantum_info->pad;
1495 if (quantum_info->format == FloatingPointQuantumFormat)
1500 for (x=0; x < (ssize_t) number_pixels; x++)
1502 p=PushDoublePixel(quantum_info,p,&pixel);
1503 SetPixelBlue(q,ClampToQuantum(pixel));
1504 p+=quantum_info->pad;
1516 range=GetQuantumRange(quantum_info->depth);
1517 for (x=0; x < (ssize_t) number_pixels; x++)
1519 p=PushQuantumPixel(quantum_info,p,&pixel);
1520 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
1521 p+=quantum_info->pad;
1529static void ImportCbYCrYQuantum(
const Image *image,
QuantumInfo *quantum_info,
1530 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
1539 switch (quantum_info->depth)
1547 if (quantum_info->pack == MagickFalse)
1560 for (x=0; x < (ssize_t) (number_pixels-3); x+=4)
1562 for (i=0; i < 4; i++)
1568 p=PushLongPixel(quantum_info->endian,p,&pixel);
1569 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
1570 (((pixel >> 22) & 0x3ff) << 6)));
1575 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
1576 (((pixel >> 12) & 0x3ff) << 6)));
1581 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
1582 (((pixel >> 2) & 0x3ff) << 6)));
1586 cbcr[i]=(Quantum) (quantum);
1589 p+=quantum_info->pad;
1590 SetPixelRed(q,cbcr[1]);
1591 SetPixelGreen(q,cbcr[0]);
1592 SetPixelBlue(q,cbcr[2]);
1594 SetPixelRed(q,cbcr[3]);
1595 SetPixelGreen(q,cbcr[0]);
1596 SetPixelBlue(q,cbcr[2]);
1608 range=GetQuantumRange(image->depth);
1609 for (x=0; x < (ssize_t) number_pixels; x++)
1611 p=PushQuantumPixel(quantum_info,p,&pixel);
1612 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
1613 p=PushQuantumPixel(quantum_info,p,&pixel);
1614 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
1623 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
1624 PixelPacket *magick_restrict q,IndexPacket *magick_restrict indexes,
1636 if (image->colorspace != CMYKColorspace)
1638 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1639 "ColorSeparatedImageRequired",
"`%s'",image->filename);
1642 switch (quantum_info->depth)
1649 for (x=0; x < (ssize_t) number_pixels; x++)
1651 p=PushCharPixel(p,&pixel);
1652 SetPixelRed(q,ScaleCharToQuantum(pixel));
1653 p=PushCharPixel(p,&pixel);
1654 SetPixelGreen(q,ScaleCharToQuantum(pixel));
1655 p=PushCharPixel(p,&pixel);
1656 SetPixelBlue(q,ScaleCharToQuantum(pixel));
1657 p=PushCharPixel(p,&pixel);
1658 SetPixelIndex(indexes+x,ScaleCharToQuantum(pixel));
1659 p+=quantum_info->pad;
1669 if (quantum_info->format == FloatingPointQuantumFormat)
1671 for (x=0; x < (ssize_t) number_pixels; x++)
1673 p=PushShortPixel(quantum_info->endian,p,&pixel);
1674 SetPixelRed(q,ClampToQuantum((
double) QuantumRange*(
double)
1675 HalfToSinglePrecision(pixel)));
1676 p=PushShortPixel(quantum_info->endian,p,&pixel);
1677 SetPixelGreen(q,ClampToQuantum((
double) QuantumRange*(
double)
1678 HalfToSinglePrecision(pixel)));
1679 p=PushShortPixel(quantum_info->endian,p,&pixel);
1680 SetPixelBlue(q,ClampToQuantum((
double) QuantumRange*(
double)
1681 HalfToSinglePrecision(pixel)));
1682 p=PushShortPixel(quantum_info->endian,p,&pixel);
1683 SetPixelIndex(indexes+x,ClampToQuantum((
double) QuantumRange*
1684 (
double) HalfToSinglePrecision(pixel)));
1685 p+=quantum_info->pad;
1690 for (x=0; x < (ssize_t) number_pixels; x++)
1692 p=PushShortPixel(quantum_info->endian,p,&pixel);
1693 SetPixelRed(q,ScaleShortToQuantum(pixel));
1694 p=PushShortPixel(quantum_info->endian,p,&pixel);
1695 SetPixelGreen(q,ScaleShortToQuantum(pixel));
1696 p=PushShortPixel(quantum_info->endian,p,&pixel);
1697 SetPixelBlue(q,ScaleShortToQuantum(pixel));
1698 p=PushShortPixel(quantum_info->endian,p,&pixel);
1699 SetPixelIndex(indexes+x,ScaleShortToQuantum(pixel));
1700 p+=quantum_info->pad;
1707 if (quantum_info->format == FloatingPointQuantumFormat)
1712 for (x=0; x < (ssize_t) number_pixels; x++)
1714 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1715 SetPixelRed(q,ClampToQuantum(pixel));
1716 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1717 SetPixelGreen(q,ClampToQuantum(pixel));
1718 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1719 SetPixelBlue(q,ClampToQuantum(pixel));
1720 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1721 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1722 p+=quantum_info->pad;
1727 for (x=0; x < (ssize_t) number_pixels; x++)
1729 p=PushLongPixel(quantum_info->endian,p,&pixel);
1730 SetPixelRed(q,ScaleLongToQuantum(pixel));
1731 p=PushLongPixel(quantum_info->endian,p,&pixel);
1732 SetPixelGreen(q,ScaleLongToQuantum(pixel));
1733 p=PushLongPixel(quantum_info->endian,p,&pixel);
1734 SetPixelBlue(q,ScaleLongToQuantum(pixel));
1735 p=PushLongPixel(quantum_info->endian,p,&pixel);
1736 SetPixelIndex(indexes+x,ScaleLongToQuantum(pixel));
1737 p+=quantum_info->pad;
1744 if (quantum_info->format == FloatingPointQuantumFormat)
1749 for (x=0; x < (ssize_t) number_pixels; x++)
1751 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1752 SetPixelRed(q,ClampToQuantum(pixel));
1753 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1754 SetPixelGreen(q,ClampToQuantum(pixel));
1755 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1756 SetPixelBlue(q,ClampToQuantum(pixel));
1757 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1758 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1759 p+=quantum_info->pad;
1768 if (quantum_info->format == FloatingPointQuantumFormat)
1773 for (x=0; x < (ssize_t) number_pixels; x++)
1775 p=PushDoublePixel(quantum_info,p,&pixel);
1776 SetPixelRed(q,ClampToQuantum(pixel));
1777 p=PushDoublePixel(quantum_info,p,&pixel);
1778 SetPixelGreen(q,ClampToQuantum(pixel));
1779 p=PushDoublePixel(quantum_info,p,&pixel);
1780 SetPixelBlue(q,ClampToQuantum(pixel));
1781 p=PushDoublePixel(quantum_info,p,&pixel);
1782 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1783 p+=quantum_info->pad;
1792 range=GetQuantumRange(quantum_info->depth);
1793 for (x=0; x < (ssize_t) number_pixels; x++)
1795 p=PushQuantumPixel(quantum_info,p,&pixel);
1796 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
1797 p=PushQuantumPixel(quantum_info,p,&pixel);
1798 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
1799 p=PushQuantumPixel(quantum_info,p,&pixel);
1800 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
1801 p=PushQuantumPixel(quantum_info,p,&pixel);
1802 SetPixelIndex(indexes+x,ScaleAnyToQuantum(pixel,range));
1810static void ImportCMYKAQuantum(
const Image *image,
QuantumInfo *quantum_info,
1811 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
1812 PixelPacket *magick_restrict q,IndexPacket *magick_restrict indexes,
1824 if (image->colorspace != CMYKColorspace)
1826 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1827 "ColorSeparatedImageRequired",
"`%s'",image->filename);
1830 switch (quantum_info->depth)
1837 for (x=0; x < (ssize_t) number_pixels; x++)
1839 p=PushCharPixel(p,&pixel);
1840 SetPixelRed(q,ScaleCharToQuantum(pixel));
1841 p=PushCharPixel(p,&pixel);
1842 SetPixelGreen(q,ScaleCharToQuantum(pixel));
1843 p=PushCharPixel(p,&pixel);
1844 SetPixelBlue(q,ScaleCharToQuantum(pixel));
1845 p=PushCharPixel(p,&pixel);
1846 SetPixelIndex(indexes+x,ScaleCharToQuantum(pixel));
1847 p=PushCharPixel(p,&pixel);
1848 SetPixelAlpha(q,ScaleCharToQuantum(pixel));
1849 p+=quantum_info->pad;
1859 if (quantum_info->format == FloatingPointQuantumFormat)
1861 for (x=0; x < (ssize_t) number_pixels; x++)
1863 p=PushShortPixel(quantum_info->endian,p,&pixel);
1864 SetPixelRed(q,ClampToQuantum((
double) QuantumRange*
1865 (
double) HalfToSinglePrecision(pixel)));
1866 p=PushShortPixel(quantum_info->endian,p,&pixel);
1867 SetPixelGreen(q,ClampToQuantum((
double) QuantumRange*
1868 (
double) HalfToSinglePrecision(pixel)));
1869 p=PushShortPixel(quantum_info->endian,p,&pixel);
1870 SetPixelBlue(q,ClampToQuantum((
double) QuantumRange*
1871 (
double) HalfToSinglePrecision(pixel)));
1872 p=PushShortPixel(quantum_info->endian,p,&pixel);
1873 SetPixelIndex(indexes+x,ClampToQuantum((
double) QuantumRange*
1874 (
double) HalfToSinglePrecision(pixel)));
1875 p=PushShortPixel(quantum_info->endian,p,&pixel);
1876 SetPixelAlpha(q,ClampToQuantum((MagickRealType) QuantumRange*
1877 (
double) HalfToSinglePrecision(pixel)));
1878 p+=quantum_info->pad;
1883 for (x=0; x < (ssize_t) number_pixels; x++)
1885 p=PushShortPixel(quantum_info->endian,p,&pixel);
1886 SetPixelRed(q,ScaleShortToQuantum(pixel));
1887 p=PushShortPixel(quantum_info->endian,p,&pixel);
1888 SetPixelGreen(q,ScaleShortToQuantum(pixel));
1889 p=PushShortPixel(quantum_info->endian,p,&pixel);
1890 SetPixelBlue(q,ScaleShortToQuantum(pixel));
1891 p=PushShortPixel(quantum_info->endian,p,&pixel);
1892 SetPixelIndex(indexes+x,ScaleShortToQuantum(pixel));
1893 p=PushShortPixel(quantum_info->endian,p,&pixel);
1894 SetPixelAlpha(q,ScaleShortToQuantum(pixel));
1895 p+=quantum_info->pad;
1902 if (quantum_info->format == FloatingPointQuantumFormat)
1907 for (x=0; x < (ssize_t) number_pixels; x++)
1909 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1910 SetPixelRed(q,ClampToQuantum(pixel));
1911 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1912 SetPixelGreen(q,ClampToQuantum(pixel));
1913 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1914 SetPixelBlue(q,ClampToQuantum(pixel));
1915 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1916 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1917 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1918 SetPixelAlpha(q,ClampToQuantum(pixel));
1919 p+=quantum_info->pad;
1924 for (x=0; x < (ssize_t) number_pixels; x++)
1926 p=PushLongPixel(quantum_info->endian,p,&pixel);
1927 SetPixelRed(q,ScaleLongToQuantum(pixel));
1928 p=PushLongPixel(quantum_info->endian,p,&pixel);
1929 SetPixelGreen(q,ScaleLongToQuantum(pixel));
1930 p=PushLongPixel(quantum_info->endian,p,&pixel);
1931 SetPixelBlue(q,ScaleLongToQuantum(pixel));
1932 p=PushLongPixel(quantum_info->endian,p,&pixel);
1933 SetPixelIndex(indexes+x,ScaleLongToQuantum(pixel));
1934 p=PushLongPixel(quantum_info->endian,p,&pixel);
1935 SetPixelAlpha(q,ScaleLongToQuantum(pixel));
1936 p+=quantum_info->pad;
1943 if (quantum_info->format == FloatingPointQuantumFormat)
1948 for (x=0; x < (ssize_t) number_pixels; x++)
1950 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1951 SetPixelRed(q,ClampToQuantum(pixel));
1952 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1953 SetPixelGreen(q,ClampToQuantum(pixel));
1954 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1955 SetPixelBlue(q,ClampToQuantum(pixel));
1956 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1957 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1958 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1959 SetPixelAlpha(q,ClampToQuantum(pixel));
1960 p+=quantum_info->pad;
1969 if (quantum_info->format == FloatingPointQuantumFormat)
1974 for (x=0; x < (ssize_t) number_pixels; x++)
1976 p=PushDoublePixel(quantum_info,p,&pixel);
1977 SetPixelRed(q,ClampToQuantum(pixel));
1978 p=PushDoublePixel(quantum_info,p,&pixel);
1979 SetPixelGreen(q,ClampToQuantum(pixel));
1980 p=PushDoublePixel(quantum_info,p,&pixel);
1981 SetPixelBlue(q,ClampToQuantum(pixel));
1982 p=PushDoublePixel(quantum_info,p,&pixel);
1983 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
1984 p=PushDoublePixel(quantum_info,p,&pixel);
1985 SetPixelAlpha(q,ClampToQuantum(pixel));
1986 p+=quantum_info->pad;
1995 range=GetQuantumRange(image->depth);
1996 for (x=0; x < (ssize_t) number_pixels; x++)
1998 p=PushQuantumPixel(quantum_info,p,&pixel);
1999 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2000 p=PushQuantumPixel(quantum_info,p,&pixel);
2001 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
2002 p=PushQuantumPixel(quantum_info,p,&pixel);
2003 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
2004 p=PushQuantumPixel(quantum_info,p,&pixel);
2005 SetPixelIndex(indexes+x,ScaleAnyToQuantum(pixel,range));
2006 p=PushQuantumPixel(quantum_info,p,&pixel);
2007 SetPixelAlpha(q,ScaleAnyToQuantum(pixel,range));
2015static void ImportCMYKOQuantum(
const Image *image,
QuantumInfo *quantum_info,
2016 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
2017 PixelPacket *magick_restrict q,IndexPacket *magick_restrict indexes,
2029 if (image->colorspace != CMYKColorspace)
2031 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
2032 "ColorSeparatedImageRequired",
"`%s'",image->filename);
2035 switch (quantum_info->depth)
2042 for (x=0; x < (ssize_t) number_pixels; x++)
2044 p=PushCharPixel(p,&pixel);
2045 SetPixelRed(q,ScaleCharToQuantum(pixel));
2046 p=PushCharPixel(p,&pixel);
2047 SetPixelGreen(q,ScaleCharToQuantum(pixel));
2048 p=PushCharPixel(p,&pixel);
2049 SetPixelBlue(q,ScaleCharToQuantum(pixel));
2050 p=PushCharPixel(p,&pixel);
2051 SetPixelIndex(indexes+x,ScaleCharToQuantum(pixel));
2052 p=PushCharPixel(p,&pixel);
2053 SetPixelOpacity(q,ScaleCharToQuantum(pixel));
2054 p+=quantum_info->pad;
2064 if (quantum_info->format == FloatingPointQuantumFormat)
2066 for (x=0; x < (ssize_t) number_pixels; x++)
2068 p=PushShortPixel(quantum_info->endian,p,&pixel);
2069 SetPixelRed(q,ClampToQuantum((
double) QuantumRange*
2070 (
double) HalfToSinglePrecision(pixel)));
2071 p=PushShortPixel(quantum_info->endian,p,&pixel);
2072 SetPixelGreen(q,ClampToQuantum((
double) QuantumRange*
2073 (
double) HalfToSinglePrecision(pixel)));
2074 p=PushShortPixel(quantum_info->endian,p,&pixel);
2075 SetPixelBlue(q,ClampToQuantum((
double) QuantumRange*
2076 (
double) HalfToSinglePrecision(pixel)));
2077 p=PushShortPixel(quantum_info->endian,p,&pixel);
2078 SetPixelIndex(indexes+x,ClampToQuantum((
double) QuantumRange*
2079 (
double) HalfToSinglePrecision(pixel)));
2080 p=PushShortPixel(quantum_info->endian,p,&pixel);
2081 SetPixelOpacity(q,ClampToQuantum((
double) QuantumRange*
2082 (
double) HalfToSinglePrecision(pixel)));
2083 p+=quantum_info->pad;
2088 for (x=0; x < (ssize_t) number_pixels; x++)
2090 p=PushShortPixel(quantum_info->endian,p,&pixel);
2091 SetPixelRed(q,ScaleShortToQuantum(pixel));
2092 p=PushShortPixel(quantum_info->endian,p,&pixel);
2093 SetPixelGreen(q,ScaleShortToQuantum(pixel));
2094 p=PushShortPixel(quantum_info->endian,p,&pixel);
2095 SetPixelBlue(q,ScaleShortToQuantum(pixel));
2096 p=PushShortPixel(quantum_info->endian,p,&pixel);
2097 SetPixelIndex(indexes+x,ScaleShortToQuantum(pixel));
2098 p=PushShortPixel(quantum_info->endian,p,&pixel);
2099 SetPixelOpacity(q,ScaleShortToQuantum(pixel));
2100 p+=quantum_info->pad;
2107 if (quantum_info->format == FloatingPointQuantumFormat)
2112 for (x=0; x < (ssize_t) number_pixels; x++)
2114 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2115 SetPixelRed(q,ClampToQuantum(pixel));
2116 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2117 SetPixelGreen(q,ClampToQuantum(pixel));
2118 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2119 SetPixelBlue(q,ClampToQuantum(pixel));
2120 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2121 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
2122 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2123 SetPixelOpacity(q,ClampToQuantum(pixel));
2124 p+=quantum_info->pad;
2129 for (x=0; x < (ssize_t) number_pixels; x++)
2131 p=PushLongPixel(quantum_info->endian,p,&pixel);
2132 SetPixelRed(q,ScaleLongToQuantum(pixel));
2133 p=PushLongPixel(quantum_info->endian,p,&pixel);
2134 SetPixelGreen(q,ScaleLongToQuantum(pixel));
2135 p=PushLongPixel(quantum_info->endian,p,&pixel);
2136 SetPixelBlue(q,ScaleLongToQuantum(pixel));
2137 p=PushLongPixel(quantum_info->endian,p,&pixel);
2138 SetPixelIndex(indexes+x,ScaleLongToQuantum(pixel));
2139 p=PushLongPixel(quantum_info->endian,p,&pixel);
2140 SetPixelOpacity(q,ScaleLongToQuantum(pixel));
2141 p+=quantum_info->pad;
2148 if (quantum_info->format == FloatingPointQuantumFormat)
2153 for (x=0; x < (ssize_t) number_pixels; x++)
2155 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2156 SetPixelRed(q,ClampToQuantum(pixel));
2157 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2158 SetPixelGreen(q,ClampToQuantum(pixel));
2159 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2160 SetPixelBlue(q,ClampToQuantum(pixel));
2161 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2162 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
2163 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2164 SetPixelOpacity(q,ClampToQuantum(pixel));
2165 p+=quantum_info->pad;
2174 if (quantum_info->format == FloatingPointQuantumFormat)
2179 for (x=0; x < (ssize_t) number_pixels; x++)
2181 p=PushDoublePixel(quantum_info,p,&pixel);
2182 SetPixelRed(q,ClampToQuantum(pixel));
2183 p=PushDoublePixel(quantum_info,p,&pixel);
2184 SetPixelGreen(q,ClampToQuantum(pixel));
2185 p=PushDoublePixel(quantum_info,p,&pixel);
2186 SetPixelBlue(q,ClampToQuantum(pixel));
2187 p=PushDoublePixel(quantum_info,p,&pixel);
2188 SetPixelIndex(indexes+x,ClampToQuantum(pixel));
2189 p=PushDoublePixel(quantum_info,p,&pixel);
2190 SetPixelOpacity(q,ClampToQuantum(pixel));
2191 p+=quantum_info->pad;
2200 range=GetQuantumRange(image->depth);
2201 for (x=0; x < (ssize_t) number_pixels; x++)
2203 p=PushQuantumPixel(quantum_info,p,&pixel);
2204 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2205 p=PushQuantumPixel(quantum_info,p,&pixel);
2206 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
2207 p=PushQuantumPixel(quantum_info,p,&pixel);
2208 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
2209 p=PushQuantumPixel(quantum_info,p,&pixel);
2210 SetPixelIndex(indexes+x,ScaleAnyToQuantum(pixel,range));
2211 p=PushQuantumPixel(quantum_info,p,&pixel);
2212 SetPixelOpacity(q,ScaleAnyToQuantum(pixel,range));
2221 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
2237 switch (quantum_info->depth)
2247 if (quantum_info->min_is_white != MagickFalse)
2252 for (x=0; x < ((ssize_t) number_pixels-7); x+=8)
2254 for (bit=0; bit < 8; bit++)
2256 SetPixelRed(q,((*p) & (1 << (7-bit))) == 0 ? black : white);
2257 SetPixelGreen(q,GetPixelRed(q));
2258 SetPixelBlue(q,GetPixelRed(q));
2263 for (bit=0; bit < (ssize_t) (number_pixels % 8); bit++)
2265 SetPixelRed(q,((*p) & (0x01 << (7-bit))) == 0 ? black : white);
2266 SetPixelGreen(q,GetPixelRed(q));
2267 SetPixelBlue(q,GetPixelRed(q));
2279 range=GetQuantumRange(quantum_info->depth);
2280 for (x=0; x < ((ssize_t) number_pixels-1); x+=2)
2282 pixel=(
unsigned char) ((*p >> 4) & 0xf);
2283 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2284 SetPixelGreen(q,GetPixelRed(q));
2285 SetPixelBlue(q,GetPixelRed(q));
2287 pixel=(
unsigned char) ((*p) & 0xf);
2288 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2289 SetPixelGreen(q,GetPixelRed(q));
2290 SetPixelBlue(q,GetPixelRed(q));
2294 for (bit=0; bit < (ssize_t) (number_pixels % 2); bit++)
2296 pixel=(
unsigned char) (*p++ >> 4);
2297 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2298 SetPixelGreen(q,GetPixelRed(q));
2299 SetPixelBlue(q,GetPixelRed(q));
2309 if (quantum_info->min_is_white != MagickFalse)
2311 for (x=0; x < (ssize_t) number_pixels; x++)
2313 p=PushCharPixel(p,&pixel);
2314 SetPixelRed(q,QuantumRange-ScaleCharToQuantum(pixel));
2315 SetPixelGreen(q,GetPixelRed(q));
2316 SetPixelBlue(q,GetPixelRed(q));
2317 SetPixelOpacity(q,OpaqueOpacity);
2318 p+=quantum_info->pad;
2323 for (x=0; x < (ssize_t) number_pixels; x++)
2325 p=PushCharPixel(p,&pixel);
2326 SetPixelRed(q,ScaleCharToQuantum(pixel));
2327 SetPixelGreen(q,GetPixelRed(q));
2328 SetPixelBlue(q,GetPixelRed(q));
2329 SetPixelOpacity(q,OpaqueOpacity);
2330 p+=quantum_info->pad;
2337 range=GetQuantumRange(quantum_info->depth);
2338 if (quantum_info->pack == MagickFalse)
2340 if (image->endian == LSBEndian)
2342 for (x=0; x < (ssize_t) (number_pixels-2); x+=3)
2344 p=PushLongPixel(quantum_info->endian,p,&pixel);
2345 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range));
2346 SetPixelGreen(q,GetPixelRed(q));
2347 SetPixelBlue(q,GetPixelRed(q));
2349 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range));
2350 SetPixelGreen(q,GetPixelRed(q));
2351 SetPixelBlue(q,GetPixelRed(q));
2353 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range));
2354 SetPixelGreen(q,GetPixelRed(q));
2355 SetPixelBlue(q,GetPixelRed(q));
2356 p+=quantum_info->pad;
2359 if (x++ < (ssize_t) (number_pixels-1))
2361 p=PushLongPixel(quantum_info->endian,p,&pixel);
2362 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range));
2363 SetPixelGreen(q,GetPixelRed(q));
2364 SetPixelBlue(q,GetPixelRed(q));
2367 if (x++ < (ssize_t) number_pixels)
2369 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range));
2370 SetPixelGreen(q,GetPixelRed(q));
2371 SetPixelBlue(q,GetPixelRed(q));
2376 for (x=0; x < (ssize_t) (number_pixels-2); x+=3)
2378 p=PushLongPixel(quantum_info->endian,p,&pixel);
2379 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range));
2380 SetPixelGreen(q,GetPixelRed(q));
2381 SetPixelBlue(q,GetPixelRed(q));
2383 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range));
2384 SetPixelGreen(q,GetPixelRed(q));
2385 SetPixelBlue(q,GetPixelRed(q));
2387 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range));
2388 SetPixelGreen(q,GetPixelRed(q));
2389 SetPixelBlue(q,GetPixelRed(q));
2390 p+=quantum_info->pad;
2393 if (x++ < (ssize_t) (number_pixels-1))
2395 p=PushLongPixel(quantum_info->endian,p,&pixel);
2396 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range));
2397 SetPixelGreen(q,GetPixelRed(q));
2398 SetPixelBlue(q,GetPixelRed(q));
2401 if (x++ < (ssize_t) number_pixels)
2403 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range));
2404 SetPixelGreen(q,GetPixelRed(q));
2405 SetPixelBlue(q,GetPixelRed(q));
2410 for (x=0; x < (ssize_t) number_pixels; x++)
2412 p=PushQuantumPixel(quantum_info,p,&pixel);
2413 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2414 SetPixelGreen(q,GetPixelRed(q));
2415 SetPixelBlue(q,GetPixelRed(q));
2416 p+=quantum_info->pad;
2423 range=GetQuantumRange(quantum_info->depth);
2424 if (quantum_info->pack == MagickFalse)
2429 for (x=0; x < (ssize_t) (number_pixels-1); x+=2)
2431 p=PushShortPixel(quantum_info->endian,p,&pixel);
2432 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range));
2433 SetPixelGreen(q,GetPixelRed(q));
2434 SetPixelBlue(q,GetPixelRed(q));
2436 p=PushShortPixel(quantum_info->endian,p,&pixel);
2437 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range));
2438 SetPixelGreen(q,GetPixelRed(q));
2439 SetPixelBlue(q,GetPixelRed(q));
2440 p+=quantum_info->pad;
2443 for (bit=0; bit < (ssize_t) (number_pixels % 2); bit++)
2445 p=PushShortPixel(quantum_info->endian,p,&pixel);
2446 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny)
2447 (pixel >> 4),range));
2448 SetPixelGreen(q,GetPixelRed(q));
2449 SetPixelBlue(q,GetPixelRed(q));
2450 p+=quantum_info->pad;
2457 for (x=0; x < (ssize_t) number_pixels; x++)
2459 p=PushQuantumPixel(quantum_info,p,&pixel);
2460 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2461 SetPixelGreen(q,GetPixelRed(q));
2462 SetPixelBlue(q,GetPixelRed(q));
2463 p+=quantum_info->pad;
2473 if (quantum_info->min_is_white != MagickFalse)
2475 for (x=0; x < (ssize_t) number_pixels; x++)
2477 p=PushShortPixel(quantum_info->endian,p,&pixel);
2478 SetPixelRed(q,QuantumRange-ScaleShortToQuantum(pixel));
2479 SetPixelGreen(q,GetPixelRed(q));
2480 SetPixelBlue(q,GetPixelRed(q));
2481 p+=quantum_info->pad;
2486 if (quantum_info->format == FloatingPointQuantumFormat)
2488 for (x=0; x < (ssize_t) number_pixels; x++)
2490 p=PushShortPixel(quantum_info->endian,p,&pixel);
2491 SetPixelRed(q,ClampToQuantum((
double) QuantumRange*
2492 (
double) HalfToSinglePrecision(pixel)));
2493 SetPixelGreen(q,GetPixelRed(q));
2494 SetPixelBlue(q,GetPixelRed(q));
2495 p+=quantum_info->pad;
2500 if (quantum_info->format == SignedQuantumFormat)
2502 for (x=0; x < (ssize_t) number_pixels; x++)
2504 p=PushShortPixel(quantum_info->endian,p,&pixel);
2505 pixel=(
unsigned short) (((
unsigned int) pixel+32768) % 65536);
2506 SetPixelRed(q,ScaleShortToQuantum(pixel));
2507 SetPixelGreen(q,GetPixelRed(q));
2508 SetPixelBlue(q,GetPixelRed(q));
2509 p+=quantum_info->pad;
2514 for (x=0; x < (ssize_t) number_pixels; x++)
2516 p=PushShortPixel(quantum_info->endian,p,&pixel);
2517 SetPixelRed(q,ScaleShortToQuantum(pixel));
2518 SetPixelGreen(q,GetPixelRed(q));
2519 SetPixelBlue(q,GetPixelRed(q));
2520 p+=quantum_info->pad;
2527 if (quantum_info->format == FloatingPointQuantumFormat)
2532 for (x=0; x < (ssize_t) number_pixels; x++)
2534 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2535 SetPixelRed(q,ClampToQuantum(pixel));
2536 SetPixelGreen(q,GetPixelRed(q));
2537 SetPixelBlue(q,GetPixelRed(q));
2538 p+=quantum_info->pad;
2543 for (x=0; x < (ssize_t) number_pixels; x++)
2545 p=PushLongPixel(quantum_info->endian,p,&pixel);
2546 SetPixelRed(q,ScaleLongToQuantum(pixel));
2547 SetPixelGreen(q,GetPixelRed(q));
2548 SetPixelBlue(q,GetPixelRed(q));
2549 p+=quantum_info->pad;
2556 if (quantum_info->format == FloatingPointQuantumFormat)
2561 for (x=0; x < (ssize_t) number_pixels; x++)
2563 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2564 SetPixelRed(q,ClampToQuantum(pixel));
2565 SetPixelGreen(q,GetPixelRed(q));
2566 SetPixelBlue(q,GetPixelRed(q));
2567 p+=quantum_info->pad;
2576 if (quantum_info->format == FloatingPointQuantumFormat)
2581 for (x=0; x < (ssize_t) number_pixels; x++)
2583 p=PushDoublePixel(quantum_info,p,&pixel);
2584 SetPixelRed(q,ClampToQuantum(pixel));
2585 SetPixelGreen(q,GetPixelRed(q));
2586 SetPixelBlue(q,GetPixelRed(q));
2587 p+=quantum_info->pad;
2596 range=GetQuantumRange(quantum_info->depth);
2597 for (x=0; x < (ssize_t) number_pixels; x++)
2599 p=PushQuantumPixel(quantum_info,p,&pixel);
2600 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2601 SetPixelGreen(q,GetPixelRed(q));
2602 SetPixelBlue(q,GetPixelRed(q));
2603 p+=quantum_info->pad;
2611static void ImportGrayAlphaQuantum(
QuantumInfo *quantum_info,
2612 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
2627 switch (quantum_info->depth)
2635 for (x=((ssize_t) number_pixels-3); x > 0; x-=4)
2637 for (bit=0; bit < 8; bit+=2)
2639 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
2640 SetPixelRed(q,pixel == 0 ? 0 : QuantumRange);
2641 SetPixelGreen(q,GetPixelRed(q));
2642 SetPixelBlue(q,GetPixelRed(q));
2643 SetPixelOpacity(q,((*p) & (1UL << (
unsigned char) (6-bit))) == 0 ?
2644 TransparentOpacity : OpaqueOpacity);
2649 if ((number_pixels % 4) != 0)
2650 for (bit=3; bit >= (ssize_t) (4-(number_pixels % 4)); bit-=2)
2652 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
2653 SetPixelRed(q,pixel != 0 ? 0 : QuantumRange);
2654 SetPixelGreen(q,GetPixelRed(q));
2655 SetPixelBlue(q,GetPixelRed(q));
2656 SetPixelOpacity(q,((*p) & (1UL << (
unsigned char) (6-bit))) == 0 ?
2657 TransparentOpacity : OpaqueOpacity);
2669 range=GetQuantumRange(quantum_info->depth);
2670 for (x=0; x < (ssize_t) number_pixels; x++)
2672 pixel=(
unsigned char) ((*p >> 4) & 0xf);
2673 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2674 SetPixelGreen(q,GetPixelRed(q));
2675 SetPixelBlue(q,GetPixelRed(q));
2676 pixel=(
unsigned char) ((*p) & 0xf);
2677 SetPixelAlpha(q,ScaleAnyToQuantum(pixel,range));
2688 for (x=0; x < (ssize_t) number_pixels; x++)
2690 p=PushCharPixel(p,&pixel);
2691 SetPixelRed(q,ScaleCharToQuantum(pixel));
2692 SetPixelGreen(q,GetPixelRed(q));
2693 SetPixelBlue(q,GetPixelRed(q));
2694 p=PushCharPixel(p,&pixel);
2695 SetPixelAlpha(q,ScaleCharToQuantum(pixel));
2696 p+=quantum_info->pad;
2703 range=GetQuantumRange(quantum_info->depth);
2704 for (x=0; x < (ssize_t) number_pixels; x++)
2706 p=PushQuantumPixel(quantum_info,p,&pixel);
2707 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2708 SetPixelGreen(q,GetPixelRed(q));
2709 SetPixelBlue(q,GetPixelRed(q));
2710 p=PushQuantumPixel(quantum_info,p,&pixel);
2711 SetPixelOpacity(q,ScaleAnyToQuantum(pixel,range));
2712 p+=quantum_info->pad;
2719 range=GetQuantumRange(quantum_info->depth);
2720 for (x=0; x < (ssize_t) number_pixels; x++)
2722 p=PushQuantumPixel(quantum_info,p,&pixel);
2723 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2724 SetPixelGreen(q,GetPixelRed(q));
2725 SetPixelBlue(q,GetPixelRed(q));
2726 p=PushQuantumPixel(quantum_info,p,&pixel);
2727 SetPixelOpacity(q,ScaleAnyToQuantum(pixel,range));
2728 p+=quantum_info->pad;
2738 if (quantum_info->format == FloatingPointQuantumFormat)
2740 for (x=0; x < (ssize_t) number_pixels; x++)
2742 p=PushShortPixel(quantum_info->endian,p,&pixel);
2743 SetPixelRed(q,ClampToQuantum((
double) QuantumRange*
2744 (
double) HalfToSinglePrecision(pixel)));
2745 SetPixelGreen(q,GetPixelRed(q));
2746 SetPixelBlue(q,GetPixelRed(q));
2747 p=PushShortPixel(quantum_info->endian,p,&pixel);
2748 SetPixelAlpha(q,ClampToQuantum((
double) QuantumRange*
2749 (
double) HalfToSinglePrecision(pixel)));
2750 p+=quantum_info->pad;
2755 for (x=0; x < (ssize_t) number_pixels; x++)
2757 p=PushShortPixel(quantum_info->endian,p,&pixel);
2758 SetPixelRed(q,ScaleShortToQuantum(pixel));
2759 SetPixelGreen(q,GetPixelRed(q));
2760 SetPixelBlue(q,GetPixelRed(q));
2761 p=PushShortPixel(quantum_info->endian,p,&pixel);
2762 SetPixelAlpha(q,ScaleShortToQuantum(pixel));
2763 p+=quantum_info->pad;
2770 if (quantum_info->format == FloatingPointQuantumFormat)
2775 for (x=0; x < (ssize_t) number_pixels; x++)
2777 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2778 SetPixelRed(q,ClampToQuantum(pixel));
2779 SetPixelGreen(q,GetPixelRed(q));
2780 SetPixelBlue(q,GetPixelRed(q));
2781 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2782 SetPixelAlpha(q,ClampToQuantum(pixel));
2783 p+=quantum_info->pad;
2788 for (x=0; x < (ssize_t) number_pixels; x++)
2790 p=PushLongPixel(quantum_info->endian,p,&pixel);
2791 SetPixelRed(q,ScaleLongToQuantum(pixel));
2792 SetPixelGreen(q,GetPixelRed(q));
2793 SetPixelBlue(q,GetPixelRed(q));
2794 p=PushLongPixel(quantum_info->endian,p,&pixel);
2795 SetPixelAlpha(q,ScaleLongToQuantum(pixel));
2796 p+=quantum_info->pad;
2803 if (quantum_info->format == FloatingPointQuantumFormat)
2808 for (x=0; x < (ssize_t) number_pixels; x++)
2810 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2811 SetPixelRed(q,ClampToQuantum(pixel));
2812 SetPixelGreen(q,GetPixelRed(q));
2813 SetPixelBlue(q,GetPixelRed(q));
2814 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2815 SetPixelAlpha(q,ClampToQuantum(pixel));
2816 p+=quantum_info->pad;
2825 if (quantum_info->format == FloatingPointQuantumFormat)
2830 for (x=0; x < (ssize_t) number_pixels; x++)
2832 p=PushDoublePixel(quantum_info,p,&pixel);
2833 SetPixelRed(q,ClampToQuantum(pixel));
2834 SetPixelGreen(q,GetPixelRed(q));
2835 SetPixelBlue(q,GetPixelRed(q));
2836 p=PushDoublePixel(quantum_info,p,&pixel);
2837 SetPixelAlpha(q,ClampToQuantum(pixel));
2838 p+=quantum_info->pad;
2850 range=GetQuantumRange(quantum_info->depth);
2851 for (x=0; x < (ssize_t) number_pixels; x++)
2853 p=PushQuantumPixel(quantum_info,p,&pixel);
2854 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
2855 SetPixelGreen(q,GetPixelRed(q));
2856 SetPixelBlue(q,GetPixelRed(q));
2857 p=PushQuantumPixel(quantum_info,p,&pixel);
2858 SetPixelAlpha(q,ScaleAnyToQuantum(pixel,range));
2859 p+=quantum_info->pad;
2867static void ImportGreenQuantum(
QuantumInfo *quantum_info,
2868 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
2877 switch (quantum_info->depth)
2884 for (x=0; x < (ssize_t) number_pixels; x++)
2886 p=PushCharPixel(p,&pixel);
2887 SetPixelGreen(q,ScaleCharToQuantum(pixel));
2888 p+=quantum_info->pad;
2898 if (quantum_info->format == FloatingPointQuantumFormat)
2900 for (x=0; x < (ssize_t) number_pixels; x++)
2902 p=PushShortPixel(quantum_info->endian,p,&pixel);
2903 SetPixelGreen(q,ClampToQuantum((
double) QuantumRange*(
double)
2904 HalfToSinglePrecision(pixel)));
2905 p+=quantum_info->pad;
2910 for (x=0; x < (ssize_t) number_pixels; x++)
2912 p=PushShortPixel(quantum_info->endian,p,&pixel);
2913 SetPixelGreen(q,ScaleShortToQuantum(pixel));
2914 p+=quantum_info->pad;
2921 if (quantum_info->format == FloatingPointQuantumFormat)
2926 for (x=0; x < (ssize_t) number_pixels; x++)
2928 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2929 SetPixelGreen(q,ClampToQuantum(pixel));
2930 p+=quantum_info->pad;
2935 for (x=0; x < (ssize_t) number_pixels; x++)
2937 p=PushLongPixel(quantum_info->endian,p,&pixel);
2938 SetPixelGreen(q,ScaleLongToQuantum(pixel));
2939 p+=quantum_info->pad;
2946 if (quantum_info->format == FloatingPointQuantumFormat)
2951 for (x=0; x < (ssize_t) number_pixels; x++)
2953 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2954 SetPixelGreen(q,ClampToQuantum(pixel));
2955 p+=quantum_info->pad;
2964 if (quantum_info->format == FloatingPointQuantumFormat)
2969 for (x=0; x < (ssize_t) number_pixels; x++)
2971 p=PushDoublePixel(quantum_info,p,&pixel);
2972 SetPixelGreen(q,ClampToQuantum(pixel));
2973 p+=quantum_info->pad;
2985 range=GetQuantumRange(quantum_info->depth);
2986 for (x=0; x < (ssize_t) number_pixels; x++)
2988 p=PushQuantumPixel(quantum_info,p,&pixel);
2989 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
2990 p+=quantum_info->pad;
2998static void ImportIndexQuantum(
const Image *image,
QuantumInfo *quantum_info,
2999 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
3000 PixelPacket *magick_restrict q,IndexPacket *magick_restrict indexes,
3015 if (image->storage_class != PseudoClass)
3017 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
3018 "ColormappedImageRequired",
"`%s'",image->filename);
3021 range_exception=MagickFalse;
3022 switch (quantum_info->depth)
3029 for (x=0; x < ((ssize_t) number_pixels-7); x+=8)
3031 for (bit=0; bit < 8; bit++)
3033 if (quantum_info->min_is_white == MagickFalse)
3034 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) == 0 ? 0x00 : 0x01);
3036 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
3037 SetPixelIndex(indexes+x+bit,PushColormapIndex(image,pixel,
3039 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(
3045 for (bit=0; bit < (ssize_t) (number_pixels % 8); bit++)
3047 if (quantum_info->min_is_white == MagickFalse)
3048 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) == 0 ? 0x00 : 0x01);
3050 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
3051 SetPixelIndex(indexes+x+bit,PushColormapIndex(image,pixel,
3053 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x+bit));
3063 for (x=0; x < ((ssize_t) number_pixels-1); x+=2)
3065 pixel=(
unsigned char) ((*p >> 4) & 0xf);
3066 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3068 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3070 pixel=(
unsigned char) ((*p) & 0xf);
3071 SetPixelIndex(indexes+x+1,PushColormapIndex(image,pixel,
3073 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x+1));
3077 for (bit=0; bit < (ssize_t) (number_pixels % 2); bit++)
3079 pixel=(
unsigned char) ((*p++ >> 4) & 0xf);
3080 SetPixelIndex(indexes+x+bit,PushColormapIndex(image,pixel,
3082 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x+bit));
3092 for (x=0; x < (ssize_t) number_pixels; x++)
3094 p=PushCharPixel(p,&pixel);
3095 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3097 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3098 p+=quantum_info->pad;
3108 if (quantum_info->format == FloatingPointQuantumFormat)
3110 for (x=0; x < (ssize_t) number_pixels; x++)
3112 p=PushShortPixel(quantum_info->endian,p,&pixel);
3113 SetPixelIndex(indexes+x,PushColormapIndex(image,(
size_t)
3114 ClampToQuantum((
double) QuantumRange* (
double)
3115 HalfToSinglePrecision(pixel)),&range_exception));
3116 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3117 p+=quantum_info->pad;
3122 for (x=0; x < (ssize_t) number_pixels; x++)
3124 p=PushShortPixel(quantum_info->endian,p,&pixel);
3125 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3127 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3128 p+=quantum_info->pad;
3135 if (quantum_info->format == FloatingPointQuantumFormat)
3140 for (x=0; x < (ssize_t) number_pixels; x++)
3142 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3143 SetPixelIndex(indexes+x,PushColormapIndex(image,(
size_t)
3144 ClampToQuantum(pixel),&range_exception));
3145 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3146 p+=quantum_info->pad;
3151 for (x=0; x < (ssize_t) number_pixels; x++)
3153 p=PushLongPixel(quantum_info->endian,p,&pixel);
3154 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3156 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3157 p+=quantum_info->pad;
3164 if (quantum_info->format == FloatingPointQuantumFormat)
3169 for (x=0; x < (ssize_t) number_pixels; x++)
3171 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3172 SetPixelIndex(indexes+x,PushColormapIndex(image,(
size_t)
3173 ClampToQuantum(pixel),&range_exception));
3174 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3175 p+=quantum_info->pad;
3184 if (quantum_info->format == FloatingPointQuantumFormat)
3189 for (x=0; x < (ssize_t) number_pixels; x++)
3191 p=PushDoublePixel(quantum_info,p,&pixel);
3192 SetPixelIndex(indexes+x,PushColormapIndex(image,(
size_t)
3193 ClampToQuantum(pixel),&range_exception));
3194 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3195 p+=quantum_info->pad;
3204 for (x=0; x < (ssize_t) number_pixels; x++)
3206 p=PushQuantumPixel(quantum_info,p,&pixel);
3207 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3209 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3210 p+=quantum_info->pad;
3216 if (range_exception != MagickFalse)
3217 (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError,
3218 "InvalidColormapIndex",
"`%s'",image->filename);
3221static void ImportIndexAlphaQuantum(
const Image *image,
3222 QuantumInfo *quantum_info,
const MagickSizeType number_pixels,
3223 const unsigned char *magick_restrict p,
PixelPacket *magick_restrict q,
3224 IndexPacket *magick_restrict indexes,
ExceptionInfo *exception)
3241 if (image->storage_class != PseudoClass)
3243 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
3244 "ColormappedImageRequired",
"`%s'",image->filename);
3247 range_exception=MagickFalse;
3248 switch (quantum_info->depth)
3255 for (x=((ssize_t) number_pixels-3); x > 0; x-=4)
3257 for (bit=0; bit < 8; bit+=2)
3259 if (quantum_info->min_is_white == MagickFalse)
3260 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) == 0 ? 0x00 : 0x01);
3262 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
3263 SetPixelIndex(indexes+x+bit/2,pixel == 0 ? 0 : 1);
3264 SetPixelRed(q,pixel == 0 ? 0 : QuantumRange);
3265 SetPixelGreen(q,GetPixelRed(q));
3266 SetPixelBlue(q,GetPixelRed(q));
3267 SetPixelOpacity(q,((*p) & (1UL << (
unsigned char) (6-bit))) == 0 ?
3268 TransparentOpacity : OpaqueOpacity);
3272 if ((number_pixels % 4) != 0)
3273 for (bit=0; bit < (ssize_t) (number_pixels % 4); bit+=2)
3275 if (quantum_info->min_is_white == MagickFalse)
3276 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) == 0 ? 0x00 : 0x01);
3278 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
3279 SetPixelIndex(indexes+x+bit/2,pixel == 0 ? 0 : 1);
3280 SetPixelRed(q,pixel == 0 ? 0 : QuantumRange);
3281 SetPixelGreen(q,GetPixelRed(q));
3282 SetPixelBlue(q,GetPixelRed(q));
3283 SetPixelOpacity(q,((*p) & (1UL << (
unsigned char) (6-bit))) == 0 ?
3284 TransparentOpacity : OpaqueOpacity);
3294 range=GetQuantumRange(quantum_info->depth);
3295 for (x=0; x < (ssize_t) number_pixels; x++)
3297 pixel=(
unsigned char) ((*p >> 4) & 0xf);
3298 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3300 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3301 pixel=(
unsigned char) ((*p) & 0xf);
3302 SetPixelAlpha(q,ScaleAnyToQuantum(pixel,range));
3313 for (x=0; x < (ssize_t) number_pixels; x++)
3315 p=PushCharPixel(p,&pixel);
3316 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3318 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3319 p=PushCharPixel(p,&pixel);
3320 SetPixelAlpha(q,ScaleCharToQuantum(pixel));
3321 p+=quantum_info->pad;
3331 if (quantum_info->format == FloatingPointQuantumFormat)
3333 for (x=0; x < (ssize_t) number_pixels; x++)
3335 p=PushShortPixel(quantum_info->endian,p,&pixel);
3336 SetPixelIndex(indexes+x,PushColormapIndex(image,(
size_t)
3337 ClampToQuantum((
double) QuantumRange*(
double)
3338 HalfToSinglePrecision(pixel)),&range_exception));
3339 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3340 p=PushShortPixel(quantum_info->endian,p,&pixel);
3341 SetPixelAlpha(q,ClampToQuantum((
double) QuantumRange*(
double)
3342 HalfToSinglePrecision(pixel)));
3343 p+=quantum_info->pad;
3348 for (x=0; x < (ssize_t) number_pixels; x++)
3350 p=PushShortPixel(quantum_info->endian,p,&pixel);
3351 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3353 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3354 p=PushShortPixel(quantum_info->endian,p,&pixel);
3355 SetPixelAlpha(q,ScaleShortToQuantum(pixel));
3356 p+=quantum_info->pad;
3363 if (quantum_info->format == FloatingPointQuantumFormat)
3368 for (x=0; x < (ssize_t) number_pixels; x++)
3370 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3371 SetPixelIndex(indexes+x,PushColormapIndex(image,(
size_t)
3372 ClampToQuantum(pixel),&range_exception));
3373 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3374 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3375 SetPixelAlpha(q,ClampToQuantum(pixel));
3376 p+=quantum_info->pad;
3381 for (x=0; x < (ssize_t) number_pixels; x++)
3383 p=PushLongPixel(quantum_info->endian,p,&pixel);
3384 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3386 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3387 p=PushLongPixel(quantum_info->endian,p,&pixel);
3388 SetPixelAlpha(q,ScaleLongToQuantum(pixel));
3389 p+=quantum_info->pad;
3396 if (quantum_info->format == FloatingPointQuantumFormat)
3401 for (x=0; x < (ssize_t) number_pixels; x++)
3403 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3404 SetPixelIndex(indexes+x,PushColormapIndex(image,(
size_t)
3405 ClampToQuantum(pixel),&range_exception));
3406 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3407 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3408 SetPixelAlpha(q,ClampToQuantum(pixel));
3409 p+=quantum_info->pad;
3418 if (quantum_info->format == FloatingPointQuantumFormat)
3423 for (x=0; x < (ssize_t) number_pixels; x++)
3425 p=PushDoublePixel(quantum_info,p,&pixel);
3426 SetPixelIndex(indexes+x,PushColormapIndex(image,(
size_t)
3427 ClampToQuantum(pixel),&range_exception));
3428 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3429 p=PushDoublePixel(quantum_info,p,&pixel);
3430 SetPixelAlpha(q,ClampToQuantum(pixel));
3431 p+=quantum_info->pad;
3440 range=GetQuantumRange(quantum_info->depth);
3441 for (x=0; x < (ssize_t) number_pixels; x++)
3443 p=PushQuantumPixel(quantum_info,p,&pixel);
3444 SetPixelIndex(indexes+x,PushColormapIndex(image,pixel,
3446 SetPixelRGBO(q,image->colormap+(ssize_t) GetPixelIndex(indexes+x));
3447 p=PushQuantumPixel(quantum_info,p,&pixel);
3448 SetPixelAlpha(q,ScaleAnyToQuantum(pixel,range));
3449 p+=quantum_info->pad;
3455 if (range_exception != MagickFalse)
3456 (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError,
3457 "InvalidColormapIndex",
"`%s'",image->filename);
3460static void ImportRedQuantum(
QuantumInfo *quantum_info,
3461 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
3470 switch (quantum_info->depth)
3477 for (x=0; x < (ssize_t) number_pixels; x++)
3479 p=PushCharPixel(p,&pixel);
3480 SetPixelRed(q,ScaleCharToQuantum(pixel));
3481 p+=quantum_info->pad;
3491 if (quantum_info->format == FloatingPointQuantumFormat)
3493 for (x=0; x < (ssize_t) number_pixels; x++)
3495 p=PushShortPixel(quantum_info->endian,p,&pixel);
3496 SetPixelRed(q,ClampToQuantum((
double) QuantumRange*
3497 (
double) HalfToSinglePrecision(pixel)));
3498 p+=quantum_info->pad;
3503 for (x=0; x < (ssize_t) number_pixels; x++)
3505 p=PushShortPixel(quantum_info->endian,p,&pixel);
3506 SetPixelRed(q,ScaleShortToQuantum(pixel));
3507 p+=quantum_info->pad;
3514 if (quantum_info->format == FloatingPointQuantumFormat)
3519 for (x=0; x < (ssize_t) number_pixels; x++)
3521 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3522 SetPixelRed(q,ClampToQuantum(pixel));
3523 p+=quantum_info->pad;
3528 for (x=0; x < (ssize_t) number_pixels; x++)
3530 p=PushLongPixel(quantum_info->endian,p,&pixel);
3531 SetPixelRed(q,ScaleLongToQuantum(pixel));
3532 p+=quantum_info->pad;
3539 if (quantum_info->format == FloatingPointQuantumFormat)
3544 for (x=0; x < (ssize_t) number_pixels; x++)
3546 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3547 SetPixelRed(q,ClampToQuantum(pixel));
3548 p+=quantum_info->pad;
3557 if (quantum_info->format == FloatingPointQuantumFormat)
3562 for (x=0; x < (ssize_t) number_pixels; x++)
3564 p=PushDoublePixel(quantum_info,p,&pixel);
3565 SetPixelRed(q,ClampToQuantum(pixel));
3566 p+=quantum_info->pad;
3578 range=GetQuantumRange(quantum_info->depth);
3579 for (x=0; x < (ssize_t) number_pixels; x++)
3581 p=PushQuantumPixel(quantum_info,p,&pixel);
3582 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
3583 p+=quantum_info->pad;
3591static void ImportRGBQuantum(
QuantumInfo *quantum_info,
3592 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
3607 switch (quantum_info->depth)
3614 for (x=0; x < (ssize_t) number_pixels; x++)
3616 p=PushCharPixel(p,&pixel);
3617 SetPixelRed(q,ScaleCharToQuantum(pixel));
3618 p=PushCharPixel(p,&pixel);
3619 SetPixelGreen(q,ScaleCharToQuantum(pixel));
3620 p=PushCharPixel(p,&pixel);
3621 SetPixelBlue(q,ScaleCharToQuantum(pixel));
3622 SetPixelOpacity(q,OpaqueOpacity);
3623 p+=quantum_info->pad;
3630 range=GetQuantumRange(quantum_info->depth);
3631 if (quantum_info->pack == MagickFalse)
3633 for (x=0; x < (ssize_t) number_pixels; x++)
3635 p=PushLongPixel(quantum_info->endian,p,&pixel);
3636 SetPixelRed(q,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range));
3637 SetPixelGreen(q,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range));
3638 SetPixelBlue(q,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range));
3639 p+=quantum_info->pad;
3644 if (quantum_info->quantum == 32U)
3646 for (x=0; x < (ssize_t) number_pixels; x++)
3648 p=PushQuantumLongPixel(quantum_info,p,&pixel);
3649 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
3650 p=PushQuantumLongPixel(quantum_info,p,&pixel);
3651 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
3652 p=PushQuantumLongPixel(quantum_info,p,&pixel);
3653 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
3658 for (x=0; x < (ssize_t) number_pixels; x++)
3660 p=PushQuantumPixel(quantum_info,p,&pixel);
3661 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
3662 p=PushQuantumPixel(quantum_info,p,&pixel);
3663 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
3664 p=PushQuantumPixel(quantum_info,p,&pixel);
3665 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
3672 range=GetQuantumRange(quantum_info->depth);
3673 if (quantum_info->pack == MagickFalse)
3678 for (x=0; x < (ssize_t) (3*number_pixels-1); x+=2)
3680 p=PushShortPixel(quantum_info->endian,p,&pixel);
3686 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3692 SetPixelGreen(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3698 SetPixelBlue(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3704 p=PushShortPixel(quantum_info->endian,p,&pixel);
3710 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3716 SetPixelGreen(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3722 SetPixelBlue(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3728 p+=quantum_info->pad;
3730 for (bit=0; bit < (ssize_t) (3*number_pixels % 2); bit++)
3732 p=PushShortPixel(quantum_info->endian,p,&pixel);
3733 switch ((x+bit) % 3)
3738 SetPixelRed(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3744 SetPixelGreen(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3750 SetPixelBlue(q,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
3756 p+=quantum_info->pad;
3762 if (quantum_info->quantum == 32U)
3764 for (x=0; x < (ssize_t) number_pixels; x++)
3766 p=PushQuantumLongPixel(quantum_info,p,&pixel);
3767 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
3768 p=PushQuantumLongPixel(quantum_info,p,&pixel);
3769 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
3770 p=PushQuantumLongPixel(quantum_info,p,&pixel);
3771 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
3776 for (x=0; x < (ssize_t) number_pixels; x++)
3778 p=PushQuantumPixel(quantum_info,p,&pixel);
3779 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
3780 p=PushQuantumPixel(quantum_info,p,&pixel);
3781 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
3782 p=PushQuantumPixel(quantum_info,p,&pixel);
3783 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
3793 if (quantum_info->format == FloatingPointQuantumFormat)
3795 for (x=0; x < (ssize_t) number_pixels; x++)
3797 p=PushShortPixel(quantum_info->endian,p,&pixel);
3798 SetPixelRed(q,ClampToQuantum((
double) QuantumRange*
3799 (
double) HalfToSinglePrecision(pixel)));
3800 p=PushShortPixel(quantum_info->endian,p,&pixel);
3801 SetPixelGreen(q,ClampToQuantum((
double) QuantumRange*
3802 (
double) HalfToSinglePrecision(pixel)));
3803 p=PushShortPixel(quantum_info->endian,p,&pixel);
3804 SetPixelBlue(q,ClampToQuantum((
double) QuantumRange*
3805 (
double) HalfToSinglePrecision(pixel)));
3806 p+=quantum_info->pad;
3811 for (x=0; x < (ssize_t) number_pixels; x++)
3813 p=PushShortPixel(quantum_info->endian,p,&pixel);
3814 SetPixelRed(q,ScaleShortToQuantum(pixel));
3815 p=PushShortPixel(quantum_info->endian,p,&pixel);
3816 SetPixelGreen(q,ScaleShortToQuantum(pixel));
3817 p=PushShortPixel(quantum_info->endian,p,&pixel);
3818 SetPixelBlue(q,ScaleShortToQuantum(pixel));
3819 p+=quantum_info->pad;
3826 if (quantum_info->format == FloatingPointQuantumFormat)
3831 for (x=0; x < (ssize_t) number_pixels; x++)
3833 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3834 SetPixelRed(q,ClampToQuantum(pixel));
3835 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3836 SetPixelGreen(q,ClampToQuantum(pixel));
3837 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3838 SetPixelBlue(q,ClampToQuantum(pixel));
3839 p+=quantum_info->pad;
3844 for (x=0; x < (ssize_t) number_pixels; x++)
3846 p=PushLongPixel(quantum_info->endian,p,&pixel);
3847 SetPixelRed(q,ScaleLongToQuantum(pixel));
3848 p=PushLongPixel(quantum_info->endian,p,&pixel);
3849 SetPixelGreen(q,ScaleLongToQuantum(pixel));
3850 p=PushLongPixel(quantum_info->endian,p,&pixel);
3851 SetPixelBlue(q,ScaleLongToQuantum(pixel));
3852 p+=quantum_info->pad;
3859 if (quantum_info->format == FloatingPointQuantumFormat)
3864 for (x=0; x < (ssize_t) number_pixels; x++)
3866 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3867 SetPixelRed(q,ClampToQuantum(pixel));
3868 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3869 SetPixelGreen(q,ClampToQuantum(pixel));
3870 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3871 SetPixelBlue(q,ClampToQuantum(pixel));
3872 p+=quantum_info->pad;
3881 if (quantum_info->format == FloatingPointQuantumFormat)
3886 for (x=0; x < (ssize_t) number_pixels; x++)
3888 p=PushDoublePixel(quantum_info,p,&pixel);
3889 SetPixelRed(q,ClampToQuantum(pixel));
3890 p=PushDoublePixel(quantum_info,p,&pixel);
3891 SetPixelGreen(q,ClampToQuantum(pixel));
3892 p=PushDoublePixel(quantum_info,p,&pixel);
3893 SetPixelBlue(q,ClampToQuantum(pixel));
3894 p+=quantum_info->pad;
3903 range=GetQuantumRange(quantum_info->depth);
3904 for (x=0; x < (ssize_t) number_pixels; x++)
3906 p=PushQuantumPixel(quantum_info,p,&pixel);
3907 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
3908 p=PushQuantumPixel(quantum_info,p,&pixel);
3909 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
3910 p=PushQuantumPixel(quantum_info,p,&pixel);
3911 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
3919static void ImportRGBAQuantum(
QuantumInfo *quantum_info,
3920 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
3932 switch (quantum_info->depth)
3939 for (x=0; x < (ssize_t) number_pixels; x++)
3941 p=PushCharPixel(p,&pixel);
3942 SetPixelRed(q,ScaleCharToQuantum(pixel));
3943 p=PushCharPixel(p,&pixel);
3944 SetPixelGreen(q,ScaleCharToQuantum(pixel));
3945 p=PushCharPixel(p,&pixel);
3946 SetPixelBlue(q,ScaleCharToQuantum(pixel));
3947 p=PushCharPixel(p,&pixel);
3948 SetPixelAlpha(q,ScaleCharToQuantum(pixel));
3949 p+=quantum_info->pad;
3957 if (quantum_info->pack == MagickFalse)
3970 for (x=0; x < (ssize_t) number_pixels; x++)
3972 for (i=0; i < 4; i++)
3978 p=PushLongPixel(quantum_info->endian,p,&pixel);
3979 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
3980 (((pixel >> 22) & 0x3ff) << 6)));
3985 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
3986 (((pixel >> 12) & 0x3ff) << 6)));
3991 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
3992 (((pixel >> 2) & 0x3ff) << 6)));
3998 case 0: SetPixelRed(q,quantum);
break;
3999 case 1: SetPixelGreen(q,quantum);
break;
4000 case 2: SetPixelBlue(q,quantum);
break;
4001 case 3: SetPixelAlpha(q,quantum);
break;
4005 p+=quantum_info->pad;
4010 for (x=0; x < (ssize_t) number_pixels; x++)
4012 p=PushQuantumPixel(quantum_info,p,&pixel);
4013 SetPixelRed(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
4014 p=PushQuantumPixel(quantum_info,p,&pixel);
4015 SetPixelGreen(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
4016 p=PushQuantumPixel(quantum_info,p,&pixel);
4017 SetPixelBlue(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
4018 p=PushQuantumPixel(quantum_info,p,&pixel);
4019 SetPixelAlpha(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
4029 if (quantum_info->format == FloatingPointQuantumFormat)
4031 for (x=0; x < (ssize_t) number_pixels; x++)
4033 p=PushShortPixel(quantum_info->endian,p,&pixel);
4034 SetPixelRed(q,ClampToQuantum((
double) QuantumRange*(
double)
4035 HalfToSinglePrecision(pixel)));
4036 p=PushShortPixel(quantum_info->endian,p,&pixel);
4037 SetPixelGreen(q,ClampToQuantum((
double) QuantumRange*(
double)
4038 HalfToSinglePrecision(pixel)));
4039 p=PushShortPixel(quantum_info->endian,p,&pixel);
4040 SetPixelBlue(q,ClampToQuantum((
double) QuantumRange*(
double)
4041 HalfToSinglePrecision(pixel)));
4042 p=PushShortPixel(quantum_info->endian,p,&pixel);
4043 SetPixelAlpha(q,ClampToQuantum((
double) QuantumRange* (
double)
4044 HalfToSinglePrecision(pixel)));
4045 p+=quantum_info->pad;
4050 for (x=0; x < (ssize_t) number_pixels; x++)
4052 p=PushShortPixel(quantum_info->endian,p,&pixel);
4053 SetPixelRed(q,ScaleShortToQuantum(pixel));
4054 p=PushShortPixel(quantum_info->endian,p,&pixel);
4055 SetPixelGreen(q,ScaleShortToQuantum(pixel));
4056 p=PushShortPixel(quantum_info->endian,p,&pixel);
4057 SetPixelBlue(q,ScaleShortToQuantum(pixel));
4058 p=PushShortPixel(quantum_info->endian,p,&pixel);
4059 SetPixelAlpha(q,ScaleShortToQuantum(pixel));
4060 p+=quantum_info->pad;
4067 if (quantum_info->format == FloatingPointQuantumFormat)
4072 for (x=0; x < (ssize_t) number_pixels; x++)
4074 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4075 SetPixelRed(q,ClampToQuantum(pixel));
4076 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4077 SetPixelGreen(q,ClampToQuantum(pixel));
4078 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4079 SetPixelBlue(q,ClampToQuantum(pixel));
4080 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4081 SetPixelAlpha(q,ClampToQuantum(pixel));
4082 p+=quantum_info->pad;
4087 for (x=0; x < (ssize_t) number_pixels; x++)
4089 p=PushLongPixel(quantum_info->endian,p,&pixel);
4090 SetPixelRed(q,ScaleLongToQuantum(pixel));
4091 p=PushLongPixel(quantum_info->endian,p,&pixel);
4092 SetPixelGreen(q,ScaleLongToQuantum(pixel));
4093 p=PushLongPixel(quantum_info->endian,p,&pixel);
4094 SetPixelBlue(q,ScaleLongToQuantum(pixel));
4095 p=PushLongPixel(quantum_info->endian,p,&pixel);
4096 SetPixelAlpha(q,ScaleLongToQuantum(pixel));
4097 p+=quantum_info->pad;
4104 if (quantum_info->format == FloatingPointQuantumFormat)
4109 for (x=0; x < (ssize_t) number_pixels; x++)
4111 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4112 SetPixelRed(q,ClampToQuantum(pixel));
4113 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4114 SetPixelGreen(q,ClampToQuantum(pixel));
4115 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4116 SetPixelBlue(q,ClampToQuantum(pixel));
4117 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4118 SetPixelAlpha(q,ClampToQuantum(pixel));
4119 p+=quantum_info->pad;
4128 if (quantum_info->format == FloatingPointQuantumFormat)
4133 for (x=0; x < (ssize_t) number_pixels; x++)
4135 p=PushDoublePixel(quantum_info,p,&pixel);
4136 SetPixelRed(q,ClampToQuantum(pixel));
4137 p=PushDoublePixel(quantum_info,p,&pixel);
4138 SetPixelGreen(q,ClampToQuantum(pixel));
4139 p=PushDoublePixel(quantum_info,p,&pixel);
4140 SetPixelBlue(q,ClampToQuantum(pixel));
4141 p=PushDoublePixel(quantum_info,p,&pixel);
4142 SetPixelAlpha(q,ClampToQuantum(pixel));
4143 p+=quantum_info->pad;
4152 range=GetQuantumRange(quantum_info->depth);
4153 for (x=0; x < (ssize_t) number_pixels; x++)
4155 p=PushQuantumPixel(quantum_info,p,&pixel);
4156 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
4157 p=PushQuantumPixel(quantum_info,p,&pixel);
4158 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
4159 p=PushQuantumPixel(quantum_info,p,&pixel);
4160 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
4161 p=PushQuantumPixel(quantum_info,p,&pixel);
4162 SetPixelAlpha(q,ScaleAnyToQuantum(pixel,range));
4170static void ImportRGBOQuantum(
QuantumInfo *quantum_info,
4171 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
4183 switch (quantum_info->depth)
4190 for (x=0; x < (ssize_t) number_pixels; x++)
4192 p=PushCharPixel(p,&pixel);
4193 SetPixelRed(q,ScaleCharToQuantum(pixel));
4194 p=PushCharPixel(p,&pixel);
4195 SetPixelGreen(q,ScaleCharToQuantum(pixel));
4196 p=PushCharPixel(p,&pixel);
4197 SetPixelBlue(q,ScaleCharToQuantum(pixel));
4198 p=PushCharPixel(p,&pixel);
4199 SetPixelOpacity(q,ScaleCharToQuantum(pixel));
4200 p+=quantum_info->pad;
4208 if (quantum_info->pack == MagickFalse)
4221 for (x=0; x < (ssize_t) number_pixels; x++)
4223 for (i=0; i < 4; i++)
4229 p=PushLongPixel(quantum_info->endian,p,&pixel);
4230 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
4231 (((pixel >> 22) & 0x3ff) << 6)));
4236 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
4237 (((pixel >> 12) & 0x3ff) << 6)));
4242 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
4243 (((pixel >> 2) & 0x3ff) << 6)));
4249 case 0: SetPixelRed(q,quantum);
break;
4250 case 1: SetPixelGreen(q,quantum);
break;
4251 case 2: SetPixelBlue(q,quantum);
break;
4252 case 3: SetPixelOpacity(q,quantum);
break;
4256 p+=quantum_info->pad;
4261 for (x=0; x < (ssize_t) number_pixels; x++)
4263 p=PushQuantumPixel(quantum_info,p,&pixel);
4264 SetPixelRed(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
4265 p=PushQuantumPixel(quantum_info,p,&pixel);
4266 SetPixelGreen(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
4267 p=PushQuantumPixel(quantum_info,p,&pixel);
4268 SetPixelBlue(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
4269 p=PushQuantumPixel(quantum_info,p,&pixel);
4270 SetPixelOpacity(q,ScaleShortToQuantum((
unsigned short) (pixel << 6)));
4280 if (quantum_info->format == FloatingPointQuantumFormat)
4282 for (x=0; x < (ssize_t) number_pixels; x++)
4284 p=PushShortPixel(quantum_info->endian,p,&pixel);
4285 SetPixelRed(q,ClampToQuantum((
double) QuantumRange*(
double)
4286 HalfToSinglePrecision(pixel)));
4287 p=PushShortPixel(quantum_info->endian,p,&pixel);
4288 SetPixelGreen(q,ClampToQuantum((
double) QuantumRange*(
double)
4289 HalfToSinglePrecision(pixel)));
4290 p=PushShortPixel(quantum_info->endian,p,&pixel);
4291 SetPixelBlue(q,ClampToQuantum((
double) QuantumRange*(
double)
4292 HalfToSinglePrecision(pixel)));
4293 p=PushShortPixel(quantum_info->endian,p,&pixel);
4294 SetPixelOpacity(q,ClampToQuantum((
double) QuantumRange*(
double)
4295 HalfToSinglePrecision(pixel)));
4296 p+=quantum_info->pad;
4301 for (x=0; x < (ssize_t) number_pixels; x++)
4303 p=PushShortPixel(quantum_info->endian,p,&pixel);
4304 SetPixelRed(q,ScaleShortToQuantum(pixel));
4305 p=PushShortPixel(quantum_info->endian,p,&pixel);
4306 SetPixelGreen(q,ScaleShortToQuantum(pixel));
4307 p=PushShortPixel(quantum_info->endian,p,&pixel);
4308 SetPixelBlue(q,ScaleShortToQuantum(pixel));
4309 p=PushShortPixel(quantum_info->endian,p,&pixel);
4310 SetPixelOpacity(q,ScaleShortToQuantum(pixel));
4311 p+=quantum_info->pad;
4318 if (quantum_info->format == FloatingPointQuantumFormat)
4323 for (x=0; x < (ssize_t) number_pixels; x++)
4325 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4326 SetPixelRed(q,ClampToQuantum(pixel));
4327 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4328 SetPixelGreen(q,ClampToQuantum(pixel));
4329 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4330 SetPixelBlue(q,ClampToQuantum(pixel));
4331 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4332 SetPixelOpacity(q,ClampToQuantum(pixel));
4333 p+=quantum_info->pad;
4338 for (x=0; x < (ssize_t) number_pixels; x++)
4340 p=PushLongPixel(quantum_info->endian,p,&pixel);
4341 SetPixelRed(q,ScaleLongToQuantum(pixel));
4342 p=PushLongPixel(quantum_info->endian,p,&pixel);
4343 SetPixelGreen(q,ScaleLongToQuantum(pixel));
4344 p=PushLongPixel(quantum_info->endian,p,&pixel);
4345 SetPixelBlue(q,ScaleLongToQuantum(pixel));
4346 p=PushLongPixel(quantum_info->endian,p,&pixel);
4347 SetPixelOpacity(q,ScaleLongToQuantum(pixel));
4348 p+=quantum_info->pad;
4355 if (quantum_info->format == FloatingPointQuantumFormat)
4360 for (x=0; x < (ssize_t) number_pixels; x++)
4362 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4363 SetPixelRed(q,ClampToQuantum(pixel));
4364 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4365 SetPixelGreen(q,ClampToQuantum(pixel));
4366 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4367 SetPixelBlue(q,ClampToQuantum(pixel));
4368 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4369 SetPixelOpacity(q,ClampToQuantum(pixel));
4370 p+=quantum_info->pad;
4379 if (quantum_info->format == FloatingPointQuantumFormat)
4384 for (x=0; x < (ssize_t) number_pixels; x++)
4386 p=PushDoublePixel(quantum_info,p,&pixel);
4387 SetPixelRed(q,ClampToQuantum(pixel));
4388 p=PushDoublePixel(quantum_info,p,&pixel);
4389 SetPixelGreen(q,ClampToQuantum(pixel));
4390 p=PushDoublePixel(quantum_info,p,&pixel);
4391 SetPixelBlue(q,ClampToQuantum(pixel));
4392 p=PushDoublePixel(quantum_info,p,&pixel);
4393 SetPixelOpacity(q,ClampToQuantum(pixel));
4394 p+=quantum_info->pad;
4403 range=GetQuantumRange(quantum_info->depth);
4404 for (x=0; x < (ssize_t) number_pixels; x++)
4406 p=PushQuantumPixel(quantum_info,p,&pixel);
4407 SetPixelRed(q,ScaleAnyToQuantum(pixel,range));
4408 p=PushQuantumPixel(quantum_info,p,&pixel);
4409 SetPixelGreen(q,ScaleAnyToQuantum(pixel,range));
4410 p=PushQuantumPixel(quantum_info,p,&pixel);
4411 SetPixelBlue(q,ScaleAnyToQuantum(pixel,range));
4412 p=PushQuantumPixel(quantum_info,p,&pixel);
4413 SetPixelOpacity(q,ScaleAnyToQuantum(pixel,range));
4421MagickExport
size_t ImportQuantumPixels(
Image *image,
CacheView *image_view,
4422 const QuantumInfo *quantum_info,
const QuantumType quantum_type,
4423 const unsigned char *magick_restrict pixels,
ExceptionInfo *exception)
4432 *magick_restrict indexes;
4443 assert(image != (
Image *) NULL);
4444 assert(image->signature == MagickCoreSignature);
4446 assert(quantum_info->signature == MagickCoreSignature);
4447 if (IsEventLogging() != MagickFalse)
4448 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
4449 if (pixels == (
const unsigned char *) NULL)
4450 pixels=GetQuantumPixels(quantum_info);
4455 number_pixels=GetImageExtent(image);
4456 q=GetAuthenticPixelQueue(image);
4457 indexes=GetAuthenticIndexQueue(image);
4461 number_pixels=GetCacheViewExtent(image_view);
4462 q=GetCacheViewAuthenticPixelQueue(image_view);
4463 indexes=GetCacheViewAuthenticIndexQueue(image_view);
4466 extent=GetQuantumExtent(image,quantum_info,quantum_type);
4467 switch (quantum_type)
4471 ImportAlphaQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4476 ImportBGRQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4481 ImportBGRAQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4486 ImportBGROQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4491 ImportBlackQuantum(image,(
QuantumInfo *) quantum_info,number_pixels,p,q,
4498 ImportBlueQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4503 ImportCbYCrYQuantum(image,(
QuantumInfo *) quantum_info,number_pixels,p,
4509 ImportCMYKQuantum(image,(
QuantumInfo *) quantum_info,number_pixels,p,q,
4515 ImportCMYKAQuantum(image,(
QuantumInfo *) quantum_info,number_pixels,p,q,
4521 ImportCMYKOQuantum(image,(
QuantumInfo *) quantum_info,number_pixels,p,q,
4527 ImportGrayQuantum(image,(
QuantumInfo *) quantum_info,number_pixels,p,q);
4530 case GrayAlphaQuantum:
4532 ImportGrayAlphaQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4536 case MagentaQuantum:
4538 ImportGreenQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4543 ImportIndexQuantum(image,(
QuantumInfo *) quantum_info,number_pixels,p,q,
4547 case IndexAlphaQuantum:
4549 ImportIndexAlphaQuantum(image,(
QuantumInfo *) quantum_info,number_pixels,
4550 p,q,indexes,exception);
4556 ImportRedQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4562 ImportRGBQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4568 ImportRGBAQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4573 ImportRGBOQuantum((
QuantumInfo *) quantum_info,number_pixels,p,q);
4579 if ((quantum_type == CbYCrQuantum) || (quantum_type == CbYCrAQuantum))
4587 q=GetAuthenticPixelQueue(image);
4589 q=GetCacheViewAuthenticPixelQueue(image_view);
4590 for (x=0; x < (ssize_t) number_pixels; x++)
4592 quantum=GetPixelRed(q);
4593 SetPixelRed(q,GetPixelGreen(q));
4594 SetPixelGreen(q,quantum);
4598 if (quantum_info->alpha_type == AssociatedQuantumAlpha)
4609 q=GetAuthenticPixelQueue(image);
4611 q=GetCacheViewAuthenticPixelQueue(image_view);
4612 indexes=GetAuthenticIndexQueue(image);
4613 for (x=0; x < (ssize_t) number_pixels; x++)
4615 alpha=QuantumScale*(double) GetPixelAlpha(q);
4616 alpha=PerceptibleReciprocal(alpha);
4617 SetPixelRed(q,ClampToQuantum(alpha*(
double) GetPixelRed(q)));
4618 SetPixelGreen(q,ClampToQuantum(alpha*(
double) GetPixelGreen(q)));
4619 SetPixelBlue(q,ClampToQuantum(alpha*(
double) GetPixelBlue(q)));
4620 if (image->colorspace == CMYKColorspace)
4621 SetPixelBlack(indexes+x,ClampToQuantum(alpha*(
double) GetPixelBlack(