47#include "MagickCore/studio.h"
48#include "MagickCore/property.h"
49#include "MagickCore/blob.h"
50#include "MagickCore/blob-private.h"
51#include "MagickCore/color-private.h"
52#include "MagickCore/exception.h"
53#include "MagickCore/exception-private.h"
54#include "MagickCore/cache.h"
55#include "MagickCore/constitute.h"
56#include "MagickCore/delegate.h"
57#include "MagickCore/geometry.h"
58#include "MagickCore/list.h"
59#include "MagickCore/magick.h"
60#include "MagickCore/memory_.h"
61#include "MagickCore/monitor.h"
62#include "MagickCore/option.h"
63#include "MagickCore/pixel.h"
64#include "MagickCore/pixel-accessor.h"
65#include "MagickCore/quantum.h"
66#include "MagickCore/quantum-private.h"
67#include "MagickCore/resource_.h"
68#include "MagickCore/semaphore.h"
69#include "MagickCore/statistic.h"
70#include "MagickCore/stream.h"
71#include "MagickCore/string_.h"
72#include "MagickCore/utility.h"
112static inline Quantum PushColormapIndex(
const Image *image,
const size_t index,
113 MagickBooleanType *range_exception)
115 if (index < image->colors)
116 return((Quantum) index);
117 *range_exception=MagickTrue;
121static inline const unsigned char *PushDoublePixel(
QuantumInfo *quantum_info,
122 const unsigned char *magick_restrict pixels,
double *pixel)
130 if (quantum_info->endian == LSBEndian)
132 quantum[0]=(*pixels++);
133 quantum[1]=(*pixels++);
134 quantum[2]=(*pixels++);
135 quantum[3]=(*pixels++);
136 quantum[4]=(*pixels++);
137 quantum[5]=(*pixels++);
138 quantum[6]=(*pixels++);
139 quantum[7]=(*pixels++);
143 quantum[7]=(*pixels++);
144 quantum[6]=(*pixels++);
145 quantum[5]=(*pixels++);
146 quantum[4]=(*pixels++);
147 quantum[3]=(*pixels++);
148 quantum[2]=(*pixels++);
149 quantum[1]=(*pixels++);
150 quantum[0]=(*pixels++);
152 p=(
double *) quantum;
154 *pixel-=quantum_info->minimum;
155 *pixel*=quantum_info->scale;
159static inline float ScaleFloatPixel(
const QuantumInfo *quantum_info,
160 const unsigned char *quantum)
165 pixel=(double) (*((
float *) quantum));
166 pixel-=quantum_info->minimum;
167 pixel*=quantum_info->scale;
168 if (pixel < (
double) -FLT_MAX)
170 if (pixel > (
double) FLT_MAX)
175static inline const unsigned char *PushQuantumFloatPixel(
176 const QuantumInfo *quantum_info,
const unsigned char *magick_restrict pixels,
182 if (quantum_info->endian == LSBEndian)
184 quantum[0]=(*pixels++);
185 quantum[1]=(*pixels++);
186 quantum[2]=(*pixels++);
187 quantum[3]=(*pixels++);
191 quantum[3]=(*pixels++);
192 quantum[2]=(*pixels++);
193 quantum[1]=(*pixels++);
194 quantum[0]=(*pixels++);
196 *pixel=ScaleFloatPixel(quantum_info,quantum);
200static inline const unsigned char *PushQuantumFloat24Pixel(
201 const QuantumInfo *quantum_info,
const unsigned char *magick_restrict pixels,
207 if (quantum_info->endian == LSBEndian)
209 quantum[0]=(*pixels++);
210 quantum[1]=(*pixels++);
211 quantum[2]=(*pixels++);
215 quantum[2]=(*pixels++);
216 quantum[1]=(*pixels++);
217 quantum[0]=(*pixels++);
219 if ((quantum[0] | quantum[1] | quantum[2]) == 0U)
227 sign_bit=(quantum[2] & 0x80);
228 exponent=(quantum[2] & 0x7F);
230 exponent=exponent-63+127;
231 quantum[3]=sign_bit | (exponent >> 1);
232 quantum[2]=((exponent & 1) << 7) | ((quantum[1] & 0xFE) >> 1);
233 quantum[1]=((quantum[1] & 0x01) << 7) | ((quantum[0] & 0xFE) >> 1);
234 quantum[0]=(quantum[0] & 0x01) << 7;
236 *pixel=ScaleFloatPixel(quantum_info,quantum);
240static inline const unsigned char *PushQuantumPixel(
QuantumInfo *quantum_info,
241 const unsigned char *magick_restrict pixels,
unsigned int *quantum)
249 *quantum=(QuantumAny) 0;
250 for (i=(ssize_t) quantum_info->depth; i > 0L; )
252 if (quantum_info->state.bits == 0UL)
254 quantum_info->state.pixel=(*pixels++);
255 quantum_info->state.bits=8UL;
257 quantum_bits=(size_t) i;
258 if (quantum_bits > quantum_info->state.bits)
259 quantum_bits=quantum_info->state.bits;
260 i-=(ssize_t) quantum_bits;
261 quantum_info->state.bits-=quantum_bits;
262 if (quantum_bits < 64)
263 *quantum=(
unsigned int) (((MagickSizeType) *quantum << quantum_bits) |
264 ((quantum_info->state.pixel >> quantum_info->state.bits) &~
265 ((~0UL) << quantum_bits)));
270static inline const unsigned char *PushQuantumLongPixel(
271 QuantumInfo *quantum_info,
const unsigned char *magick_restrict pixels,
272 unsigned int *quantum)
281 for (i=(ssize_t) quantum_info->depth; i > 0; )
283 if (quantum_info->state.bits == 0)
285 pixels=PushLongPixel(quantum_info->endian,pixels,
286 &quantum_info->state.pixel);
287 quantum_info->state.bits=32U;
289 quantum_bits=(size_t) i;
290 if (quantum_bits > quantum_info->state.bits)
291 quantum_bits=quantum_info->state.bits;
292 *quantum|=(((quantum_info->state.pixel >> (32U-quantum_info->state.bits)) &
293 quantum_info->state.mask[quantum_bits]) << ((ssize_t)
294 quantum_info->depth-i));
295 i-=(ssize_t) quantum_bits;
296 quantum_info->state.bits-=quantum_bits;
302 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
303 Quantum *magick_restrict q)
311 assert(image != (
Image *) NULL);
312 assert(image->signature == MagickCoreSignature);
313 switch (quantum_info->depth)
320 for (x=0; x < (ssize_t) number_pixels; x++)
322 p=PushCharPixel(p,&pixel);
323 SetPixelAlpha(image,ScaleCharToQuantum(pixel),q);
324 p+=(ptrdiff_t) quantum_info->pad;
325 q+=(ptrdiff_t) GetPixelChannels(image);
334 if (quantum_info->format == FloatingPointQuantumFormat)
336 for (x=0; x < (ssize_t) number_pixels; x++)
338 p=PushShortPixel(quantum_info->endian,p,&pixel);
339 SetPixelAlpha(image,ClampToQuantum((
double) QuantumRange*(
double)
340 HalfToSinglePrecision(pixel)),q);
341 p+=(ptrdiff_t) quantum_info->pad;
342 q+=(ptrdiff_t) GetPixelChannels(image);
346 for (x=0; x < (ssize_t) number_pixels; x++)
348 p=PushShortPixel(quantum_info->endian,p,&pixel);
349 SetPixelAlpha(image,ScaleShortToQuantum(pixel),q);
350 p+=(ptrdiff_t) quantum_info->pad;
351 q+=(ptrdiff_t) GetPixelChannels(image);
357 if (quantum_info->format == FloatingPointQuantumFormat)
362 for (x=0; x < (ssize_t) number_pixels; x++)
364 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
365 SetPixelAlpha(image,ClampToQuantum(pixel),q);
366 p+=(ptrdiff_t) quantum_info->pad;
367 q+=(ptrdiff_t) GetPixelChannels(image);
376 for (x=0; x < (ssize_t) number_pixels; x++)
378 p=PushLongPixel(quantum_info->endian,p,&pixel);
379 SetPixelAlpha(image,ScaleLongToQuantum(pixel),q);
380 p+=(ptrdiff_t) quantum_info->pad;
381 q+=(ptrdiff_t) GetPixelChannels(image);
388 if (quantum_info->format == FloatingPointQuantumFormat)
393 for (x=0; x < (ssize_t) number_pixels; x++)
395 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
396 SetPixelAlpha(image,ClampToQuantum(pixel),q);
397 p+=(ptrdiff_t) quantum_info->pad;
398 q+=(ptrdiff_t) GetPixelChannels(image);
406 if (quantum_info->format == FloatingPointQuantumFormat)
411 for (x=0; x < (ssize_t) number_pixels; x++)
413 p=PushDoublePixel(quantum_info,p,&pixel);
414 SetPixelAlpha(image,ClampToQuantum(pixel),q);
415 p+=(ptrdiff_t) quantum_info->pad;
416 q+=(ptrdiff_t) GetPixelChannels(image);
427 range=GetQuantumRange(quantum_info->depth);
428 for (x=0; x < (ssize_t) number_pixels; x++)
430 p=PushQuantumPixel(quantum_info,p,&pixel);
431 SetPixelAlpha(image,ScaleAnyToQuantum(pixel,range),q);
432 p+=(ptrdiff_t) quantum_info->pad;
433 q+=(ptrdiff_t) GetPixelChannels(image);
441 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
442 Quantum *magick_restrict q)
453 assert(image != (
Image *) NULL);
454 assert(image->signature == MagickCoreSignature);
455 switch (quantum_info->depth)
462 for (x=0; x < (ssize_t) number_pixels; x++)
464 p=PushCharPixel(p,&pixel);
465 SetPixelBlue(image,ScaleCharToQuantum(pixel),q);
466 p=PushCharPixel(p,&pixel);
467 SetPixelGreen(image,ScaleCharToQuantum(pixel),q);
468 p=PushCharPixel(p,&pixel);
469 SetPixelRed(image,ScaleCharToQuantum(pixel),q);
470 SetPixelAlpha(image,OpaqueAlpha,q);
471 p+=(ptrdiff_t) quantum_info->pad;
472 q+=(ptrdiff_t) GetPixelChannels(image);
481 range=GetQuantumRange(quantum_info->depth);
482 if (quantum_info->pack == MagickFalse)
484 for (x=0; x < (ssize_t) number_pixels; x++)
486 p=PushLongPixel(quantum_info->endian,p,&pixel);
487 SetPixelRed(image,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range),q);
488 SetPixelGreen(image,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range),
490 SetPixelBlue(image,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range),q);
491 p+=(ptrdiff_t) quantum_info->pad;
492 q+=(ptrdiff_t) GetPixelChannels(image);
496 if (quantum_info->quantum == 32U)
498 for (x=0; x < (ssize_t) number_pixels; x++)
500 p=PushQuantumLongPixel(quantum_info,p,&pixel);
501 SetPixelBlue(image,ScaleAnyToQuantum(pixel,range),q);
502 p=PushQuantumLongPixel(quantum_info,p,&pixel);
503 SetPixelGreen(image,ScaleAnyToQuantum(pixel,range),q);
504 p=PushQuantumLongPixel(quantum_info,p,&pixel);
505 SetPixelRed(image,ScaleAnyToQuantum(pixel,range),q);
506 q+=(ptrdiff_t) GetPixelChannels(image);
510 for (x=0; x < (ssize_t) number_pixels; x++)
512 p=PushQuantumPixel(quantum_info,p,&pixel);
513 SetPixelBlue(image,ScaleAnyToQuantum(pixel,range),q);
514 p=PushQuantumPixel(quantum_info,p,&pixel);
515 SetPixelGreen(image,ScaleAnyToQuantum(pixel,range),q);
516 p=PushQuantumPixel(quantum_info,p,&pixel);
517 SetPixelRed(image,ScaleAnyToQuantum(pixel,range),q);
518 q+=(ptrdiff_t) GetPixelChannels(image);
524 range=GetQuantumRange(quantum_info->depth);
525 if (quantum_info->pack == MagickFalse)
530 for (x=0; x < (ssize_t) (3*number_pixels-1); x+=2)
532 p=PushShortPixel(quantum_info->endian,p,&pixel);
538 SetPixelRed(image,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
544 SetPixelGreen(image,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
550 SetPixelBlue(image,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
552 q+=(ptrdiff_t) GetPixelChannels(image);
556 p=PushShortPixel(quantum_info->endian,p,&pixel);
562 SetPixelRed(image,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
568 SetPixelGreen(image,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
574 SetPixelBlue(image,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
576 q+=(ptrdiff_t) GetPixelChannels(image);
580 p+=(ptrdiff_t) quantum_info->pad;
582 for (bit=0; bit < (ssize_t) (3*number_pixels % 2); bit++)
584 p=PushShortPixel(quantum_info->endian,p,&pixel);
590 SetPixelRed(image,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
596 SetPixelGreen(image,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
602 SetPixelBlue(image,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
604 q+=(ptrdiff_t) GetPixelChannels(image);
608 p+=(ptrdiff_t) quantum_info->pad;
619 if (quantum_info->quantum == 32U)
621 for (x=0; x < (ssize_t) number_pixels; x++)
623 p=PushQuantumLongPixel(quantum_info,p,&pixel);
624 SetPixelBlue(image,ScaleAnyToQuantum(pixel,range),q);
625 p=PushQuantumLongPixel(quantum_info,p,&pixel);
626 SetPixelGreen(image,ScaleAnyToQuantum(pixel,range),q);
627 p=PushQuantumLongPixel(quantum_info,p,&pixel);
628 SetPixelRed(image,ScaleAnyToQuantum(pixel,range),q);
629 q+=(ptrdiff_t) GetPixelChannels(image);
633 for (x=0; x < (ssize_t) number_pixels; x++)
635 p=PushQuantumPixel(quantum_info,p,&pixel);
636 SetPixelBlue(image,ScaleAnyToQuantum(pixel,range),q);
637 p=PushQuantumPixel(quantum_info,p,&pixel);
638 SetPixelGreen(image,ScaleAnyToQuantum(pixel,range),q);
639 p=PushQuantumPixel(quantum_info,p,&pixel);
640 SetPixelRed(image,ScaleAnyToQuantum(pixel,range),q);
641 q+=(ptrdiff_t) GetPixelChannels(image);
651 if (quantum_info->format == FloatingPointQuantumFormat)
653 for (x=0; x < (ssize_t) number_pixels; x++)
655 p=PushShortPixel(quantum_info->endian,p,&pixel);
656 SetPixelRed(image,ClampToQuantum((
double) QuantumRange*(
double)
657 HalfToSinglePrecision(pixel)),q);
658 p=PushShortPixel(quantum_info->endian,p,&pixel);
659 SetPixelGreen(image,ClampToQuantum((
double) QuantumRange*(
double)
660 HalfToSinglePrecision(pixel)),q);
661 p=PushShortPixel(quantum_info->endian,p,&pixel);
662 SetPixelBlue(image,ClampToQuantum((
double) QuantumRange*(
double)
663 HalfToSinglePrecision(pixel)),q);
664 p+=(ptrdiff_t) quantum_info->pad;
665 q+=(ptrdiff_t) GetPixelChannels(image);
669 for (x=0; x < (ssize_t) number_pixels; x++)
671 p=PushShortPixel(quantum_info->endian,p,&pixel);
672 SetPixelBlue(image,ScaleShortToQuantum(pixel),q);
673 p=PushShortPixel(quantum_info->endian,p,&pixel);
674 SetPixelGreen(image,ScaleShortToQuantum(pixel),q);
675 p=PushShortPixel(quantum_info->endian,p,&pixel);
676 SetPixelRed(image,ScaleShortToQuantum(pixel),q);
677 p+=(ptrdiff_t) quantum_info->pad;
678 q+=(ptrdiff_t) GetPixelChannels(image);
684 if (quantum_info->format == FloatingPointQuantumFormat)
689 for (x=0; x < (ssize_t) number_pixels; x++)
691 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
692 SetPixelRed(image,ClampToQuantum(pixel),q);
693 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
694 SetPixelGreen(image,ClampToQuantum(pixel),q);
695 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
696 SetPixelBlue(image,ClampToQuantum(pixel),q);
697 p+=(ptrdiff_t) quantum_info->pad;
698 q+=(ptrdiff_t) GetPixelChannels(image);
707 for (x=0; x < (ssize_t) number_pixels; x++)
709 p=PushLongPixel(quantum_info->endian,p,&pixel);
710 SetPixelBlue(image,ScaleLongToQuantum(pixel),q);
711 p=PushLongPixel(quantum_info->endian,p,&pixel);
712 SetPixelGreen(image,ScaleLongToQuantum(pixel),q);
713 p=PushLongPixel(quantum_info->endian,p,&pixel);
714 SetPixelRed(image,ScaleLongToQuantum(pixel),q);
715 p+=(ptrdiff_t) quantum_info->pad;
716 q+=(ptrdiff_t) GetPixelChannels(image);
723 if (quantum_info->format == FloatingPointQuantumFormat)
728 for (x=0; x < (ssize_t) number_pixels; x++)
730 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
731 SetPixelRed(image,ClampToQuantum(pixel),q);
732 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
733 SetPixelGreen(image,ClampToQuantum(pixel),q);
734 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
735 SetPixelBlue(image,ClampToQuantum(pixel),q);
736 p+=(ptrdiff_t) quantum_info->pad;
737 q+=(ptrdiff_t) GetPixelChannels(image);
745 if (quantum_info->format == FloatingPointQuantumFormat)
750 for (x=0; x < (ssize_t) number_pixels; x++)
752 p=PushDoublePixel(quantum_info,p,&pixel);
753 SetPixelRed(image,ClampToQuantum(pixel),q);
754 p=PushDoublePixel(quantum_info,p,&pixel);
755 SetPixelGreen(image,ClampToQuantum(pixel),q);
756 p=PushDoublePixel(quantum_info,p,&pixel);
757 SetPixelBlue(image,ClampToQuantum(pixel),q);
758 p+=(ptrdiff_t) quantum_info->pad;
759 q+=(ptrdiff_t) GetPixelChannels(image);
770 range=GetQuantumRange(quantum_info->depth);
771 for (x=0; x < (ssize_t) number_pixels; x++)
773 p=PushQuantumPixel(quantum_info,p,&pixel);
774 SetPixelBlue(image,ScaleAnyToQuantum(pixel,range),q);
775 p=PushQuantumPixel(quantum_info,p,&pixel);
776 SetPixelGreen(image,ScaleAnyToQuantum(pixel,range),q);
777 p=PushQuantumPixel(quantum_info,p,&pixel);
778 SetPixelRed(image,ScaleAnyToQuantum(pixel,range),q);
779 q+=(ptrdiff_t) GetPixelChannels(image);
787 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
788 Quantum *magick_restrict q)
796 assert(image != (
Image *) NULL);
797 assert(image->signature == MagickCoreSignature);
798 switch (quantum_info->depth)
805 for (x=0; x < (ssize_t) number_pixels; x++)
807 p=PushCharPixel(p,&pixel);
808 SetPixelBlue(image,ScaleCharToQuantum(pixel),q);
809 p=PushCharPixel(p,&pixel);
810 SetPixelGreen(image,ScaleCharToQuantum(pixel),q);
811 p=PushCharPixel(p,&pixel);
812 SetPixelRed(image,ScaleCharToQuantum(pixel),q);
813 p=PushCharPixel(p,&pixel);
814 SetPixelAlpha(image,ScaleCharToQuantum(pixel),q);
815 p+=(ptrdiff_t) quantum_info->pad;
816 q+=(ptrdiff_t) GetPixelChannels(image);
826 if (quantum_info->pack == MagickFalse)
839 for (x=0; x < (ssize_t) number_pixels; x++)
841 for (i=0; i < 4; i++)
847 p=PushLongPixel(quantum_info->endian,p,&pixel);
848 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
849 (((pixel >> 22) & 0x3ff) << 6)));
854 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
855 (((pixel >> 12) & 0x3ff) << 6)));
860 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
861 (((pixel >> 2) & 0x3ff) << 6)));
867 case 0: SetPixelRed(image,(Quantum) quantum,q);
break;
868 case 1: SetPixelGreen(image,(Quantum) quantum,q);
break;
869 case 2: SetPixelBlue(image,(Quantum) quantum,q);
break;
870 case 3: SetPixelAlpha(image,(Quantum) quantum,q);
break;
874 p+=(ptrdiff_t) quantum_info->pad;
875 q+=(ptrdiff_t) GetPixelChannels(image);
879 for (x=0; x < (ssize_t) number_pixels; x++)
881 p=PushQuantumPixel(quantum_info,p,&pixel);
882 SetPixelRed(image,ScaleShortToQuantum((
unsigned short) (pixel << 6)),q);
883 p=PushQuantumPixel(quantum_info,p,&pixel);
884 SetPixelGreen(image,ScaleShortToQuantum((
unsigned short) (pixel << 6)),
886 p=PushQuantumPixel(quantum_info,p,&pixel);
887 SetPixelBlue(image,ScaleShortToQuantum((
unsigned short) (pixel << 6)),
889 p=PushQuantumPixel(quantum_info,p,&pixel);
890 SetPixelAlpha(image,ScaleShortToQuantum((
unsigned short) (pixel << 6)),
892 q+=(ptrdiff_t) GetPixelChannels(image);
901 if (quantum_info->format == FloatingPointQuantumFormat)
903 for (x=0; x < (ssize_t) number_pixels; x++)
905 p=PushShortPixel(quantum_info->endian,p,&pixel);
906 SetPixelRed(image,ClampToQuantum((
double) QuantumRange*(
double)
907 HalfToSinglePrecision(pixel)),q);
908 p=PushShortPixel(quantum_info->endian,p,&pixel);
909 SetPixelGreen(image,ClampToQuantum((
double) QuantumRange*(
double)
910 HalfToSinglePrecision(pixel)),q);
911 p=PushShortPixel(quantum_info->endian,p,&pixel);
912 SetPixelBlue(image,ClampToQuantum((
double) QuantumRange*(
double)
913 HalfToSinglePrecision(pixel)),q);
914 p=PushShortPixel(quantum_info->endian,p,&pixel);
915 SetPixelAlpha(image,ClampToQuantum((
double) QuantumRange*(
double)
916 HalfToSinglePrecision(pixel)),q);
917 p+=(ptrdiff_t) quantum_info->pad;
918 q+=(ptrdiff_t) GetPixelChannels(image);
922 for (x=0; x < (ssize_t) number_pixels; x++)
924 p=PushShortPixel(quantum_info->endian,p,&pixel);
925 SetPixelBlue(image,ScaleShortToQuantum(pixel),q);
926 p=PushShortPixel(quantum_info->endian,p,&pixel);
927 SetPixelGreen(image,ScaleShortToQuantum(pixel),q);
928 p=PushShortPixel(quantum_info->endian,p,&pixel);
929 SetPixelRed(image,ScaleShortToQuantum(pixel),q);
930 p=PushShortPixel(quantum_info->endian,p,&pixel);
931 SetPixelAlpha(image,ScaleShortToQuantum(pixel),q);
932 p+=(ptrdiff_t) quantum_info->pad;
933 q+=(ptrdiff_t) GetPixelChannels(image);
939 if (quantum_info->format == FloatingPointQuantumFormat)
944 for (x=0; x < (ssize_t) number_pixels; x++)
946 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
947 SetPixelRed(image,ClampToQuantum(pixel),q);
948 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
949 SetPixelGreen(image,ClampToQuantum(pixel),q);
950 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
951 SetPixelBlue(image,ClampToQuantum(pixel),q);
952 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
953 SetPixelAlpha(image,ClampToQuantum(pixel),q);
954 p+=(ptrdiff_t) quantum_info->pad;
955 q+=(ptrdiff_t) GetPixelChannels(image);
964 for (x=0; x < (ssize_t) number_pixels; x++)
966 p=PushLongPixel(quantum_info->endian,p,&pixel);
967 SetPixelBlue(image,ScaleLongToQuantum(pixel),q);
968 p=PushLongPixel(quantum_info->endian,p,&pixel);
969 SetPixelGreen(image,ScaleLongToQuantum(pixel),q);
970 p=PushLongPixel(quantum_info->endian,p,&pixel);
971 SetPixelRed(image,ScaleLongToQuantum(pixel),q);
972 p=PushLongPixel(quantum_info->endian,p,&pixel);
973 SetPixelAlpha(image,ScaleLongToQuantum(pixel),q);
974 p+=(ptrdiff_t) quantum_info->pad;
975 q+=(ptrdiff_t) GetPixelChannels(image);
982 if (quantum_info->format == FloatingPointQuantumFormat)
987 for (x=0; x < (ssize_t) number_pixels; x++)
989 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
990 SetPixelRed(image,ClampToQuantum(pixel),q);
991 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
992 SetPixelGreen(image,ClampToQuantum(pixel),q);
993 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
994 SetPixelBlue(image,ClampToQuantum(pixel),q);
995 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
996 SetPixelAlpha(image,ClampToQuantum(pixel),q);
997 p+=(ptrdiff_t) quantum_info->pad;
998 q+=(ptrdiff_t) GetPixelChannels(image);
1006 if (quantum_info->format == FloatingPointQuantumFormat)
1011 for (x=0; x < (ssize_t) number_pixels; x++)
1013 p=PushDoublePixel(quantum_info,p,&pixel);
1014 SetPixelRed(image,ClampToQuantum(pixel),q);
1015 p=PushDoublePixel(quantum_info,p,&pixel);
1016 SetPixelGreen(image,ClampToQuantum(pixel),q);
1017 p=PushDoublePixel(quantum_info,p,&pixel);
1018 SetPixelBlue(image,ClampToQuantum(pixel),q);
1019 p=PushDoublePixel(quantum_info,p,&pixel);
1020 SetPixelAlpha(image,ClampToQuantum(pixel),q);
1021 p+=(ptrdiff_t) quantum_info->pad;
1022 q+=(ptrdiff_t) GetPixelChannels(image);
1033 range=GetQuantumRange(quantum_info->depth);
1034 for (x=0; x < (ssize_t) number_pixels; x++)
1036 p=PushQuantumPixel(quantum_info,p,&pixel);
1037 SetPixelBlue(image,ScaleAnyToQuantum(pixel,range),q);
1038 p=PushQuantumPixel(quantum_info,p,&pixel);
1039 SetPixelGreen(image,ScaleAnyToQuantum(pixel,range),q);
1040 p=PushQuantumPixel(quantum_info,p,&pixel);
1041 SetPixelRed(image,ScaleAnyToQuantum(pixel,range),q);
1042 p=PushQuantumPixel(quantum_info,p,&pixel);
1043 SetPixelAlpha(image,ScaleAnyToQuantum(pixel,range),q);
1044 q+=(ptrdiff_t) GetPixelChannels(image);
1052 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
1053 Quantum *magick_restrict q)
1061 assert(image != (
Image *) NULL);
1062 assert(image->signature == MagickCoreSignature);
1063 switch (quantum_info->depth)
1070 for (x=0; x < (ssize_t) number_pixels; x++)
1072 p=PushCharPixel(p,&pixel);
1073 SetPixelBlue(image,ScaleCharToQuantum(pixel),q);
1074 p=PushCharPixel(p,&pixel);
1075 SetPixelGreen(image,ScaleCharToQuantum(pixel),q);
1076 p=PushCharPixel(p,&pixel);
1077 SetPixelRed(image,ScaleCharToQuantum(pixel),q);
1078 p=PushCharPixel(p,&pixel);
1079 SetPixelOpacity(image,ScaleCharToQuantum(pixel),q);
1080 p+=(ptrdiff_t) quantum_info->pad;
1081 q+=(ptrdiff_t) GetPixelChannels(image);
1091 if (quantum_info->pack == MagickFalse)
1104 for (x=0; x < (ssize_t) number_pixels; x++)
1106 for (i=0; i < 4; i++)
1112 p=PushLongPixel(quantum_info->endian,p,&pixel);
1113 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
1114 (((pixel >> 22) & 0x3ff) << 6)));
1119 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
1120 (((pixel >> 12) & 0x3ff) << 6)));
1125 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
1126 (((pixel >> 2) & 0x3ff) << 6)));
1132 case 0: SetPixelRed(image,(Quantum) quantum,q);
break;
1133 case 1: SetPixelGreen(image,(Quantum) quantum,q);
break;
1134 case 2: SetPixelBlue(image,(Quantum) quantum,q);
break;
1135 case 3: SetPixelOpacity(image,(Quantum) quantum,q);
break;
1139 p+=(ptrdiff_t) quantum_info->pad;
1140 q+=(ptrdiff_t) GetPixelChannels(image);
1144 for (x=0; x < (ssize_t) number_pixels; x++)
1146 p=PushQuantumPixel(quantum_info,p,&pixel);
1147 SetPixelRed(image,ScaleShortToQuantum((
unsigned short) (pixel << 6)),q);
1148 p=PushQuantumPixel(quantum_info,p,&pixel);
1149 SetPixelGreen(image,ScaleShortToQuantum((
unsigned short) (pixel << 6)),
1151 p=PushQuantumPixel(quantum_info,p,&pixel);
1152 SetPixelBlue(image,ScaleShortToQuantum((
unsigned short) (pixel << 6)),
1154 p=PushQuantumPixel(quantum_info,p,&pixel);
1155 SetPixelOpacity(image,ScaleShortToQuantum((
unsigned short) (pixel << 6)),
1157 q+=(ptrdiff_t) GetPixelChannels(image);
1166 if (quantum_info->format == FloatingPointQuantumFormat)
1168 for (x=0; x < (ssize_t) number_pixels; x++)
1170 p=PushShortPixel(quantum_info->endian,p,&pixel);
1171 SetPixelRed(image,ClampToQuantum((
double) QuantumRange*(
double)
1172 HalfToSinglePrecision(pixel)),q);
1173 p=PushShortPixel(quantum_info->endian,p,&pixel);
1174 SetPixelGreen(image,ClampToQuantum((
double) QuantumRange*(
double)
1175 HalfToSinglePrecision(pixel)),q);
1176 p=PushShortPixel(quantum_info->endian,p,&pixel);
1177 SetPixelBlue(image,ClampToQuantum((
double) QuantumRange*(
double)
1178 HalfToSinglePrecision(pixel)),q);
1179 p=PushShortPixel(quantum_info->endian,p,&pixel);
1180 SetPixelOpacity(image,ClampToQuantum((
double) QuantumRange*(
double)
1181 HalfToSinglePrecision(pixel)),q);
1182 p+=(ptrdiff_t) quantum_info->pad;
1183 q+=(ptrdiff_t) GetPixelChannels(image);
1187 for (x=0; x < (ssize_t) number_pixels; x++)
1189 p=PushShortPixel(quantum_info->endian,p,&pixel);
1190 SetPixelBlue(image,ScaleShortToQuantum(pixel),q);
1191 p=PushShortPixel(quantum_info->endian,p,&pixel);
1192 SetPixelGreen(image,ScaleShortToQuantum(pixel),q);
1193 p=PushShortPixel(quantum_info->endian,p,&pixel);
1194 SetPixelRed(image,ScaleShortToQuantum(pixel),q);
1195 p=PushShortPixel(quantum_info->endian,p,&pixel);
1196 SetPixelOpacity(image,ScaleShortToQuantum(pixel),q);
1197 p+=(ptrdiff_t) quantum_info->pad;
1198 q+=(ptrdiff_t) GetPixelChannels(image);
1204 if (quantum_info->format == FloatingPointQuantumFormat)
1209 for (x=0; x < (ssize_t) number_pixels; x++)
1211 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1212 SetPixelRed(image,ClampToQuantum(pixel),q);
1213 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1214 SetPixelGreen(image,ClampToQuantum(pixel),q);
1215 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1216 SetPixelBlue(image,ClampToQuantum(pixel),q);
1217 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1218 SetPixelOpacity(image,ClampToQuantum(pixel),q);
1219 p+=(ptrdiff_t) quantum_info->pad;
1220 q+=(ptrdiff_t) GetPixelChannels(image);
1229 for (x=0; x < (ssize_t) number_pixels; x++)
1231 p=PushLongPixel(quantum_info->endian,p,&pixel);
1232 SetPixelBlue(image,ScaleLongToQuantum(pixel),q);
1233 p=PushLongPixel(quantum_info->endian,p,&pixel);
1234 SetPixelGreen(image,ScaleLongToQuantum(pixel),q);
1235 p=PushLongPixel(quantum_info->endian,p,&pixel);
1236 SetPixelRed(image,ScaleLongToQuantum(pixel),q);
1237 p=PushLongPixel(quantum_info->endian,p,&pixel);
1238 SetPixelOpacity(image,ScaleLongToQuantum(pixel),q);
1239 p+=(ptrdiff_t) quantum_info->pad;
1240 q+=(ptrdiff_t) GetPixelChannels(image);
1247 if (quantum_info->format == FloatingPointQuantumFormat)
1252 for (x=0; x < (ssize_t) number_pixels; x++)
1254 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1255 SetPixelRed(image,ClampToQuantum(pixel),q);
1256 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1257 SetPixelGreen(image,ClampToQuantum(pixel),q);
1258 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1259 SetPixelBlue(image,ClampToQuantum(pixel),q);
1260 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1261 SetPixelOpacity(image,ClampToQuantum(pixel),q);
1262 p+=(ptrdiff_t) quantum_info->pad;
1263 q+=(ptrdiff_t) GetPixelChannels(image);
1271 if (quantum_info->format == FloatingPointQuantumFormat)
1276 for (x=0; x < (ssize_t) number_pixels; x++)
1278 p=PushDoublePixel(quantum_info,p,&pixel);
1279 SetPixelRed(image,ClampToQuantum(pixel),q);
1280 p=PushDoublePixel(quantum_info,p,&pixel);
1281 SetPixelGreen(image,ClampToQuantum(pixel),q);
1282 p=PushDoublePixel(quantum_info,p,&pixel);
1283 SetPixelBlue(image,ClampToQuantum(pixel),q);
1284 p=PushDoublePixel(quantum_info,p,&pixel);
1285 SetPixelOpacity(image,ClampToQuantum(pixel),q);
1286 p+=(ptrdiff_t) quantum_info->pad;
1287 q+=(ptrdiff_t) GetPixelChannels(image);
1298 range=GetQuantumRange(quantum_info->depth);
1299 for (x=0; x < (ssize_t) number_pixels; x++)
1301 p=PushQuantumPixel(quantum_info,p,&pixel);
1302 SetPixelBlue(image,ScaleAnyToQuantum(pixel,range),q);
1303 p=PushQuantumPixel(quantum_info,p,&pixel);
1304 SetPixelGreen(image,ScaleAnyToQuantum(pixel,range),q);
1305 p=PushQuantumPixel(quantum_info,p,&pixel);
1306 SetPixelRed(image,ScaleAnyToQuantum(pixel,range),q);
1307 p=PushQuantumPixel(quantum_info,p,&pixel);
1308 SetPixelOpacity(image,ScaleAnyToQuantum(pixel,range),q);
1309 q+=(ptrdiff_t) GetPixelChannels(image);
1316static void ImportBlackQuantum(
const Image *image,
QuantumInfo *quantum_info,
1317 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
1326 if (image->colorspace != CMYKColorspace)
1328 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1329 "ColorSeparatedImageRequired",
"`%s'",image->filename);
1332 switch (quantum_info->depth)
1339 for (x=0; x < (ssize_t) number_pixels; x++)
1341 p=PushCharPixel(p,&pixel);
1342 SetPixelBlack(image,ScaleCharToQuantum(pixel),q);
1343 p+=(ptrdiff_t) quantum_info->pad;
1344 q+=(ptrdiff_t) GetPixelChannels(image);
1353 if (quantum_info->format == FloatingPointQuantumFormat)
1355 for (x=0; x < (ssize_t) number_pixels; x++)
1357 p=PushShortPixel(quantum_info->endian,p,&pixel);
1358 SetPixelBlack(image,ClampToQuantum((
double) QuantumRange*(
double)
1359 HalfToSinglePrecision(pixel)),q);
1360 p+=(ptrdiff_t) quantum_info->pad;
1361 q+=(ptrdiff_t) GetPixelChannels(image);
1365 for (x=0; x < (ssize_t) number_pixels; x++)
1367 p=PushShortPixel(quantum_info->endian,p,&pixel);
1368 SetPixelBlack(image,ScaleShortToQuantum(pixel),q);
1369 p+=(ptrdiff_t) quantum_info->pad;
1370 q+=(ptrdiff_t) GetPixelChannels(image);
1376 if (quantum_info->format == FloatingPointQuantumFormat)
1381 for (x=0; x < (ssize_t) number_pixels; x++)
1383 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1384 SetPixelBlack(image,ClampToQuantum(pixel),q);
1385 p+=(ptrdiff_t) quantum_info->pad;
1386 q+=(ptrdiff_t) GetPixelChannels(image);
1395 for (x=0; x < (ssize_t) number_pixels; x++)
1397 p=PushLongPixel(quantum_info->endian,p,&pixel);
1398 SetPixelBlack(image,ScaleLongToQuantum(pixel),q);
1399 p+=(ptrdiff_t) quantum_info->pad;
1400 q+=(ptrdiff_t) GetPixelChannels(image);
1407 if (quantum_info->format == FloatingPointQuantumFormat)
1412 for (x=0; x < (ssize_t) number_pixels; x++)
1414 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1415 SetPixelBlack(image,ClampToQuantum(pixel),q);
1416 p+=(ptrdiff_t) quantum_info->pad;
1417 q+=(ptrdiff_t) GetPixelChannels(image);
1425 if (quantum_info->format == FloatingPointQuantumFormat)
1430 for (x=0; x < (ssize_t) number_pixels; x++)
1432 p=PushDoublePixel(quantum_info,p,&pixel);
1433 SetPixelBlack(image,ClampToQuantum(pixel),q);
1434 p+=(ptrdiff_t) quantum_info->pad;
1435 q+=(ptrdiff_t) GetPixelChannels(image);
1446 range=GetQuantumRange(quantum_info->depth);
1447 for (x=0; x < (ssize_t) number_pixels; x++)
1449 p=PushQuantumPixel(quantum_info,p,&pixel);
1450 SetPixelBlack(image,ScaleAnyToQuantum(pixel,range),q);
1451 p+=(ptrdiff_t) quantum_info->pad;
1452 q+=(ptrdiff_t) GetPixelChannels(image);
1460 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
1461 Quantum *magick_restrict q)
1469 assert(image != (
Image *) NULL);
1470 assert(image->signature == MagickCoreSignature);
1471 switch (quantum_info->depth)
1478 for (x=0; x < (ssize_t) number_pixels; x++)
1480 p=PushCharPixel(p,&pixel);
1481 SetPixelBlue(image,ScaleCharToQuantum(pixel),q);
1482 p+=(ptrdiff_t) quantum_info->pad;
1483 q+=(ptrdiff_t) GetPixelChannels(image);
1492 if (quantum_info->format == FloatingPointQuantumFormat)
1494 for (x=0; x < (ssize_t) number_pixels; x++)
1496 p=PushShortPixel(quantum_info->endian,p,&pixel);
1497 SetPixelBlue(image,ClampToQuantum((
double) QuantumRange*(
double)
1498 HalfToSinglePrecision(pixel)),q);
1499 p+=(ptrdiff_t) quantum_info->pad;
1500 q+=(ptrdiff_t) GetPixelChannels(image);
1504 for (x=0; x < (ssize_t) number_pixels; x++)
1506 p=PushShortPixel(quantum_info->endian,p,&pixel);
1507 SetPixelBlue(image,ScaleShortToQuantum(pixel),q);
1508 p+=(ptrdiff_t) quantum_info->pad;
1509 q+=(ptrdiff_t) GetPixelChannels(image);
1515 if (quantum_info->format == FloatingPointQuantumFormat)
1520 for (x=0; x < (ssize_t) number_pixels; x++)
1522 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1523 SetPixelBlue(image,ClampToQuantum(pixel),q);
1524 p+=(ptrdiff_t) quantum_info->pad;
1525 q+=(ptrdiff_t) GetPixelChannels(image);
1534 for (x=0; x < (ssize_t) number_pixels; x++)
1536 p=PushLongPixel(quantum_info->endian,p,&pixel);
1537 SetPixelBlue(image,ScaleLongToQuantum(pixel),q);
1538 p+=(ptrdiff_t) quantum_info->pad;
1539 q+=(ptrdiff_t) GetPixelChannels(image);
1546 if (quantum_info->format == FloatingPointQuantumFormat)
1551 for (x=0; x < (ssize_t) number_pixels; x++)
1553 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1554 SetPixelBlue(image,ClampToQuantum(pixel),q);
1555 p+=(ptrdiff_t) quantum_info->pad;
1556 q+=(ptrdiff_t) GetPixelChannels(image);
1564 if (quantum_info->format == FloatingPointQuantumFormat)
1569 for (x=0; x < (ssize_t) number_pixels; x++)
1571 p=PushDoublePixel(quantum_info,p,&pixel);
1572 SetPixelBlue(image,ClampToQuantum(pixel),q);
1573 p+=(ptrdiff_t) quantum_info->pad;
1574 q+=(ptrdiff_t) GetPixelChannels(image);
1585 range=GetQuantumRange(quantum_info->depth);
1586 for (x=0; x < (ssize_t) number_pixels; x++)
1588 p=PushQuantumPixel(quantum_info,p,&pixel);
1589 SetPixelBlue(image,ScaleAnyToQuantum(pixel,range),q);
1590 p+=(ptrdiff_t) quantum_info->pad;
1591 q+=(ptrdiff_t) GetPixelChannels(image);
1598static void ImportCbYCrYQuantum(
const Image *image,
QuantumInfo *quantum_info,
1599 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
1600 Quantum *magick_restrict q)
1611 assert(image != (
Image *) NULL);
1612 assert(image->signature == MagickCoreSignature);
1613 switch (quantum_info->depth)
1621 if (quantum_info->pack == MagickFalse)
1634 for (x=0; x < (ssize_t) (number_pixels-3); x+=4)
1636 for (i=0; i < 4; i++)
1642 p=PushLongPixel(quantum_info->endian,p,&pixel);
1643 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
1644 (((pixel >> 22) & 0x3ff) << 6)));
1649 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
1650 (((pixel >> 12) & 0x3ff) << 6)));
1655 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
1656 (((pixel >> 2) & 0x3ff) << 6)));
1660 cbcr[i]=(Quantum) (quantum);
1663 p+=(ptrdiff_t) quantum_info->pad;
1664 SetPixelRed(image,cbcr[1],q);
1665 SetPixelGreen(image,cbcr[0],q);
1666 SetPixelBlue(image,cbcr[2],q);
1667 q+=(ptrdiff_t) GetPixelChannels(image);
1668 SetPixelRed(image,cbcr[3],q);
1669 SetPixelGreen(image,cbcr[0],q);
1670 SetPixelBlue(image,cbcr[2],q);
1671 q+=(ptrdiff_t) GetPixelChannels(image);
1679 range=GetQuantumRange(quantum_info->depth);
1680 for (x=0; x < (ssize_t) number_pixels; x++)
1682 p=PushQuantumPixel(quantum_info,p,&pixel);
1683 SetPixelRed(image,ScaleAnyToQuantum(pixel,range),q);
1684 p=PushQuantumPixel(quantum_info,p,&pixel);
1685 SetPixelGreen(image,ScaleAnyToQuantum(pixel,range),q);
1686 q+=(ptrdiff_t) GetPixelChannels(image);
1694 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
1703 if (image->colorspace != CMYKColorspace)
1705 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1706 "ColorSeparatedImageRequired",
"`%s'",image->filename);
1709 switch (quantum_info->depth)
1716 for (x=0; x < (ssize_t) number_pixels; x++)
1718 p=PushCharPixel(p,&pixel);
1719 SetPixelRed(image,ScaleCharToQuantum(pixel),q);
1720 p=PushCharPixel(p,&pixel);
1721 SetPixelGreen(image,ScaleCharToQuantum(pixel),q);
1722 p=PushCharPixel(p,&pixel);
1723 SetPixelBlue(image,ScaleCharToQuantum(pixel),q);
1724 p=PushCharPixel(p,&pixel);
1725 SetPixelBlack(image,ScaleCharToQuantum(pixel),q);
1726 p+=(ptrdiff_t) quantum_info->pad;
1727 q+=(ptrdiff_t) GetPixelChannels(image);
1736 if (quantum_info->format == FloatingPointQuantumFormat)
1738 for (x=0; x < (ssize_t) number_pixels; x++)
1740 p=PushShortPixel(quantum_info->endian,p,&pixel);
1741 SetPixelRed(image,ClampToQuantum((
double) QuantumRange*(
double)
1742 HalfToSinglePrecision(pixel)),q);
1743 p=PushShortPixel(quantum_info->endian,p,&pixel);
1744 SetPixelGreen(image,ClampToQuantum((
double) QuantumRange*(
double)
1745 HalfToSinglePrecision(pixel)),q);
1746 p=PushShortPixel(quantum_info->endian,p,&pixel);
1747 SetPixelBlue(image,ClampToQuantum((
double) QuantumRange*(
double)
1748 HalfToSinglePrecision(pixel)),q);
1749 p=PushShortPixel(quantum_info->endian,p,&pixel);
1750 SetPixelBlack(image,ClampToQuantum((
double) QuantumRange*(
double)
1751 HalfToSinglePrecision(pixel)),q);
1752 p+=(ptrdiff_t) quantum_info->pad;
1753 q+=(ptrdiff_t) GetPixelChannels(image);
1757 for (x=0; x < (ssize_t) number_pixels; x++)
1759 p=PushShortPixel(quantum_info->endian,p,&pixel);
1760 SetPixelRed(image,ScaleShortToQuantum(pixel),q);
1761 p=PushShortPixel(quantum_info->endian,p,&pixel);
1762 SetPixelGreen(image,ScaleShortToQuantum(pixel),q);
1763 p=PushShortPixel(quantum_info->endian,p,&pixel);
1764 SetPixelBlue(image,ScaleShortToQuantum(pixel),q);
1765 p=PushShortPixel(quantum_info->endian,p,&pixel);
1766 SetPixelBlack(image,ScaleShortToQuantum(pixel),q);
1767 p+=(ptrdiff_t) quantum_info->pad;
1768 q+=(ptrdiff_t) GetPixelChannels(image);
1774 if (quantum_info->format == FloatingPointQuantumFormat)
1779 for (x=0; x < (ssize_t) number_pixels; x++)
1781 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1782 SetPixelRed(image,ClampToQuantum(pixel),q);
1783 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1784 SetPixelGreen(image,ClampToQuantum(pixel),q);
1785 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1786 SetPixelBlue(image,ClampToQuantum(pixel),q);
1787 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1788 SetPixelBlack(image,ClampToQuantum(pixel),q);
1789 p+=(ptrdiff_t) quantum_info->pad;
1790 q+=(ptrdiff_t) GetPixelChannels(image);
1799 for (x=0; x < (ssize_t) number_pixels; x++)
1801 p=PushLongPixel(quantum_info->endian,p,&pixel);
1802 SetPixelRed(image,ScaleLongToQuantum(pixel),q);
1803 p=PushLongPixel(quantum_info->endian,p,&pixel);
1804 SetPixelGreen(image,ScaleLongToQuantum(pixel),q);
1805 p=PushLongPixel(quantum_info->endian,p,&pixel);
1806 SetPixelBlue(image,ScaleLongToQuantum(pixel),q);
1807 p=PushLongPixel(quantum_info->endian,p,&pixel);
1808 SetPixelBlack(image,ScaleLongToQuantum(pixel),q);
1809 p+=(ptrdiff_t) quantum_info->pad;
1810 q+=(ptrdiff_t) GetPixelChannels(image);
1817 if (quantum_info->format == FloatingPointQuantumFormat)
1822 for (x=0; x < (ssize_t) number_pixels; x++)
1824 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1825 SetPixelRed(image,ClampToQuantum(pixel),q);
1826 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1827 SetPixelGreen(image,ClampToQuantum(pixel),q);
1828 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1829 SetPixelBlue(image,ClampToQuantum(pixel),q);
1830 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
1831 SetPixelBlack(image,ClampToQuantum(pixel),q);
1832 p+=(ptrdiff_t) quantum_info->pad;
1833 q+=(ptrdiff_t) GetPixelChannels(image);
1841 if (quantum_info->format == FloatingPointQuantumFormat)
1846 for (x=0; x < (ssize_t) number_pixels; x++)
1848 p=PushDoublePixel(quantum_info,p,&pixel);
1849 SetPixelRed(image,ClampToQuantum(pixel),q);
1850 p=PushDoublePixel(quantum_info,p,&pixel);
1851 SetPixelGreen(image,ClampToQuantum(pixel),q);
1852 p=PushDoublePixel(quantum_info,p,&pixel);
1853 SetPixelBlue(image,ClampToQuantum(pixel),q);
1854 p=PushDoublePixel(quantum_info,p,&pixel);
1855 SetPixelBlack(image,ClampToQuantum(pixel),q);
1856 p+=(ptrdiff_t) quantum_info->pad;
1857 q+=(ptrdiff_t) GetPixelChannels(image);
1868 range=GetQuantumRange(quantum_info->depth);
1869 for (x=0; x < (ssize_t) number_pixels; x++)
1871 p=PushQuantumPixel(quantum_info,p,&pixel);
1872 SetPixelRed(image,ScaleAnyToQuantum(pixel,range),q);
1873 p=PushQuantumPixel(quantum_info,p,&pixel);
1874 SetPixelGreen(image,ScaleAnyToQuantum(pixel,range),q);
1875 p=PushQuantumPixel(quantum_info,p,&pixel);
1876 SetPixelBlue(image,ScaleAnyToQuantum(pixel,range),q);
1877 p=PushQuantumPixel(quantum_info,p,&pixel);
1878 SetPixelBlack(image,ScaleAnyToQuantum(pixel,range),q);
1879 q+=(ptrdiff_t) GetPixelChannels(image);
1886static void ImportCMYKAQuantum(
const Image *image,
QuantumInfo *quantum_info,
1887 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
1896 if (image->colorspace != CMYKColorspace)
1898 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1899 "ColorSeparatedImageRequired",
"`%s'",image->filename);
1902 switch (quantum_info->depth)
1909 for (x=0; x < (ssize_t) number_pixels; x++)
1911 p=PushCharPixel(p,&pixel);
1912 SetPixelRed(image,ScaleCharToQuantum(pixel),q);
1913 p=PushCharPixel(p,&pixel);
1914 SetPixelGreen(image,ScaleCharToQuantum(pixel),q);
1915 p=PushCharPixel(p,&pixel);
1916 SetPixelBlue(image,ScaleCharToQuantum(pixel),q);
1917 p=PushCharPixel(p,&pixel);
1918 SetPixelBlack(image,ScaleCharToQuantum(pixel),q);
1919 p=PushCharPixel(p,&pixel);
1920 SetPixelAlpha(image,ScaleCharToQuantum(pixel),q);
1921 p+=(ptrdiff_t) quantum_info->pad;
1922 q+=(ptrdiff_t) GetPixelChannels(image);
1931 if (quantum_info->format == FloatingPointQuantumFormat)
1933 for (x=0; x < (ssize_t) number_pixels; x++)
1935 p=PushShortPixel(quantum_info->endian,p,&pixel);
1936 SetPixelRed(image,ClampToQuantum((
double) QuantumRange*(
double)
1937 HalfToSinglePrecision(pixel)),q);
1938 p=PushShortPixel(quantum_info->endian,p,&pixel);
1939 SetPixelGreen(image,ClampToQuantum((
double) QuantumRange*(
double)
1940 HalfToSinglePrecision(pixel)),q);
1941 p=PushShortPixel(quantum_info->endian,p,&pixel);
1942 SetPixelBlue(image,ClampToQuantum((
double) QuantumRange*(
double)
1943 HalfToSinglePrecision(pixel)),q);
1944 p=PushShortPixel(quantum_info->endian,p,&pixel);
1945 SetPixelBlack(image,ClampToQuantum((
double) QuantumRange*(
double)
1946 HalfToSinglePrecision(pixel)),q);
1947 p=PushShortPixel(quantum_info->endian,p,&pixel);
1948 SetPixelAlpha(image,ClampToQuantum((
double) QuantumRange*(
double)
1949 HalfToSinglePrecision(pixel)),q);
1950 p+=(ptrdiff_t) quantum_info->pad;
1951 q+=(ptrdiff_t) GetPixelChannels(image);
1955 for (x=0; x < (ssize_t) number_pixels; x++)
1957 p=PushShortPixel(quantum_info->endian,p,&pixel);
1958 SetPixelRed(image,ScaleShortToQuantum(pixel),q);
1959 p=PushShortPixel(quantum_info->endian,p,&pixel);
1960 SetPixelGreen(image,ScaleShortToQuantum(pixel),q);
1961 p=PushShortPixel(quantum_info->endian,p,&pixel);
1962 SetPixelBlue(image,ScaleShortToQuantum(pixel),q);
1963 p=PushShortPixel(quantum_info->endian,p,&pixel);
1964 SetPixelBlack(image,ScaleShortToQuantum(pixel),q);
1965 p=PushShortPixel(quantum_info->endian,p,&pixel);
1966 SetPixelAlpha(image,ScaleShortToQuantum(pixel),q);
1967 p+=(ptrdiff_t) quantum_info->pad;
1968 q+=(ptrdiff_t) GetPixelChannels(image);
1974 if (quantum_info->format == FloatingPointQuantumFormat)
1979 for (x=0; x < (ssize_t) number_pixels; x++)
1981 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1982 SetPixelRed(image,ClampToQuantum(pixel),q);
1983 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1984 SetPixelGreen(image,ClampToQuantum(pixel),q);
1985 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1986 SetPixelBlue(image,ClampToQuantum(pixel),q);
1987 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1988 SetPixelBlack(image,ClampToQuantum(pixel),q);
1989 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
1990 SetPixelAlpha(image,ClampToQuantum(pixel),q);
1991 p+=(ptrdiff_t) quantum_info->pad;
1992 q+=(ptrdiff_t) GetPixelChannels(image);
2001 for (x=0; x < (ssize_t) number_pixels; x++)
2003 p=PushLongPixel(quantum_info->endian,p,&pixel);
2004 SetPixelRed(image,ScaleLongToQuantum(pixel),q);
2005 p=PushLongPixel(quantum_info->endian,p,&pixel);
2006 SetPixelGreen(image,ScaleLongToQuantum(pixel),q);
2007 p=PushLongPixel(quantum_info->endian,p,&pixel);
2008 SetPixelBlue(image,ScaleLongToQuantum(pixel),q);
2009 p=PushLongPixel(quantum_info->endian,p,&pixel);
2010 SetPixelBlack(image,ScaleLongToQuantum(pixel),q);
2011 p=PushLongPixel(quantum_info->endian,p,&pixel);
2012 SetPixelAlpha(image,ScaleLongToQuantum(pixel),q);
2013 p+=(ptrdiff_t) quantum_info->pad;
2014 q+=(ptrdiff_t) GetPixelChannels(image);
2021 if (quantum_info->format == FloatingPointQuantumFormat)
2026 for (x=0; x < (ssize_t) number_pixels; x++)
2028 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2029 SetPixelRed(image,ClampToQuantum(pixel),q);
2030 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2031 SetPixelGreen(image,ClampToQuantum(pixel),q);
2032 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2033 SetPixelBlue(image,ClampToQuantum(pixel),q);
2034 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2035 SetPixelBlack(image,ClampToQuantum(pixel),q);
2036 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2037 SetPixelAlpha(image,ClampToQuantum(pixel),q);
2038 p+=(ptrdiff_t) quantum_info->pad;
2039 q+=(ptrdiff_t) GetPixelChannels(image);
2047 if (quantum_info->format == FloatingPointQuantumFormat)
2052 for (x=0; x < (ssize_t) number_pixels; x++)
2054 p=PushDoublePixel(quantum_info,p,&pixel);
2055 SetPixelRed(image,ClampToQuantum(pixel),q);
2056 p=PushDoublePixel(quantum_info,p,&pixel);
2057 SetPixelGreen(image,ClampToQuantum(pixel),q);
2058 p=PushDoublePixel(quantum_info,p,&pixel);
2059 SetPixelBlue(image,ClampToQuantum(pixel),q);
2060 p=PushDoublePixel(quantum_info,p,&pixel);
2061 SetPixelBlack(image,ClampToQuantum(pixel),q);
2062 p=PushDoublePixel(quantum_info,p,&pixel);
2063 SetPixelAlpha(image,ClampToQuantum(pixel),q);
2064 p+=(ptrdiff_t) quantum_info->pad;
2065 q+=(ptrdiff_t) GetPixelChannels(image);
2076 range=GetQuantumRange(quantum_info->depth);
2077 for (x=0; x < (ssize_t) number_pixels; x++)
2079 p=PushQuantumPixel(quantum_info,p,&pixel);
2080 SetPixelRed(image,ScaleAnyToQuantum(pixel,range),q);
2081 p=PushQuantumPixel(quantum_info,p,&pixel);
2082 SetPixelGreen(image,ScaleAnyToQuantum(pixel,range),q);
2083 p=PushQuantumPixel(quantum_info,p,&pixel);
2084 SetPixelBlue(image,ScaleAnyToQuantum(pixel,range),q);
2085 p=PushQuantumPixel(quantum_info,p,&pixel);
2086 SetPixelBlack(image,ScaleAnyToQuantum(pixel,range),q);
2087 p=PushQuantumPixel(quantum_info,p,&pixel);
2088 SetPixelAlpha(image,ScaleAnyToQuantum(pixel,range),q);
2089 q+=(ptrdiff_t) GetPixelChannels(image);
2096static void ImportCMYKOQuantum(
const Image *image,
QuantumInfo *quantum_info,
2097 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
2106 if (image->colorspace != CMYKColorspace)
2108 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
2109 "ColorSeparatedImageRequired",
"`%s'",image->filename);
2112 switch (quantum_info->depth)
2119 for (x=0; x < (ssize_t) number_pixels; x++)
2121 p=PushCharPixel(p,&pixel);
2122 SetPixelRed(image,ScaleCharToQuantum(pixel),q);
2123 p=PushCharPixel(p,&pixel);
2124 SetPixelGreen(image,ScaleCharToQuantum(pixel),q);
2125 p=PushCharPixel(p,&pixel);
2126 SetPixelBlue(image,ScaleCharToQuantum(pixel),q);
2127 p=PushCharPixel(p,&pixel);
2128 SetPixelBlack(image,ScaleCharToQuantum(pixel),q);
2129 p=PushCharPixel(p,&pixel);
2130 SetPixelOpacity(image,ScaleCharToQuantum(pixel),q);
2131 p+=(ptrdiff_t) quantum_info->pad;
2132 q+=(ptrdiff_t) GetPixelChannels(image);
2141 if (quantum_info->format == FloatingPointQuantumFormat)
2143 for (x=0; x < (ssize_t) number_pixels; x++)
2145 p=PushShortPixel(quantum_info->endian,p,&pixel);
2146 SetPixelRed(image,ClampToQuantum((
double) QuantumRange*(
double)
2147 HalfToSinglePrecision(pixel)),q);
2148 p=PushShortPixel(quantum_info->endian,p,&pixel);
2149 SetPixelGreen(image,ClampToQuantum((
double) QuantumRange*(
double)
2150 HalfToSinglePrecision(pixel)),q);
2151 p=PushShortPixel(quantum_info->endian,p,&pixel);
2152 SetPixelBlue(image,ClampToQuantum((
double) QuantumRange*(
double)
2153 HalfToSinglePrecision(pixel)),q);
2154 p=PushShortPixel(quantum_info->endian,p,&pixel);
2155 SetPixelBlack(image,ClampToQuantum((
double) QuantumRange*(
double)
2156 HalfToSinglePrecision(pixel)),q);
2157 p=PushShortPixel(quantum_info->endian,p,&pixel);
2158 SetPixelOpacity(image,ClampToQuantum((
double) QuantumRange*(
double)
2159 HalfToSinglePrecision(pixel)),q);
2160 p+=(ptrdiff_t) quantum_info->pad;
2161 q+=(ptrdiff_t) GetPixelChannels(image);
2165 for (x=0; x < (ssize_t) number_pixels; x++)
2167 p=PushShortPixel(quantum_info->endian,p,&pixel);
2168 SetPixelRed(image,ScaleShortToQuantum(pixel),q);
2169 p=PushShortPixel(quantum_info->endian,p,&pixel);
2170 SetPixelGreen(image,ScaleShortToQuantum(pixel),q);
2171 p=PushShortPixel(quantum_info->endian,p,&pixel);
2172 SetPixelBlue(image,ScaleShortToQuantum(pixel),q);
2173 p=PushShortPixel(quantum_info->endian,p,&pixel);
2174 SetPixelBlack(image,ScaleShortToQuantum(pixel),q);
2175 p=PushShortPixel(quantum_info->endian,p,&pixel);
2176 SetPixelOpacity(image,ScaleShortToQuantum(pixel),q);
2177 p+=(ptrdiff_t) quantum_info->pad;
2178 q+=(ptrdiff_t) GetPixelChannels(image);
2184 if (quantum_info->format == FloatingPointQuantumFormat)
2189 for (x=0; x < (ssize_t) number_pixels; x++)
2191 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2192 SetPixelRed(image,ClampToQuantum(pixel),q);
2193 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2194 SetPixelGreen(image,ClampToQuantum(pixel),q);
2195 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2196 SetPixelBlue(image,ClampToQuantum(pixel),q);
2197 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2198 SetPixelBlack(image,ClampToQuantum(pixel),q);
2199 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2200 SetPixelOpacity(image,ClampToQuantum(pixel),q);
2201 p+=(ptrdiff_t) quantum_info->pad;
2202 q+=(ptrdiff_t) GetPixelChannels(image);
2211 for (x=0; x < (ssize_t) number_pixels; x++)
2213 p=PushLongPixel(quantum_info->endian,p,&pixel);
2214 SetPixelRed(image,ScaleLongToQuantum(pixel),q);
2215 p=PushLongPixel(quantum_info->endian,p,&pixel);
2216 SetPixelGreen(image,ScaleLongToQuantum(pixel),q);
2217 p=PushLongPixel(quantum_info->endian,p,&pixel);
2218 SetPixelBlue(image,ScaleLongToQuantum(pixel),q);
2219 p=PushLongPixel(quantum_info->endian,p,&pixel);
2220 SetPixelBlack(image,ScaleLongToQuantum(pixel),q);
2221 p=PushLongPixel(quantum_info->endian,p,&pixel);
2222 SetPixelOpacity(image,ScaleLongToQuantum(pixel),q);
2223 p+=(ptrdiff_t) quantum_info->pad;
2224 q+=(ptrdiff_t) GetPixelChannels(image);
2231 if (quantum_info->format == FloatingPointQuantumFormat)
2236 for (x=0; x < (ssize_t) number_pixels; x++)
2238 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2239 SetPixelRed(image,ClampToQuantum(pixel),q);
2240 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2241 SetPixelGreen(image,ClampToQuantum(pixel),q);
2242 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2243 SetPixelBlue(image,ClampToQuantum(pixel),q);
2244 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2245 SetPixelBlack(image,ClampToQuantum(pixel),q);
2246 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2247 SetPixelOpacity(image,ClampToQuantum(pixel),q);
2248 p+=(ptrdiff_t) quantum_info->pad;
2249 q+=(ptrdiff_t) GetPixelChannels(image);
2257 if (quantum_info->format == FloatingPointQuantumFormat)
2262 for (x=0; x < (ssize_t) number_pixels; x++)
2264 p=PushDoublePixel(quantum_info,p,&pixel);
2265 SetPixelRed(image,ClampToQuantum(pixel),q);
2266 p=PushDoublePixel(quantum_info,p,&pixel);
2267 SetPixelGreen(image,ClampToQuantum(pixel),q);
2268 p=PushDoublePixel(quantum_info,p,&pixel);
2269 SetPixelBlue(image,ClampToQuantum(pixel),q);
2270 p=PushDoublePixel(quantum_info,p,&pixel);
2271 SetPixelBlack(image,ClampToQuantum(pixel),q);
2272 p=PushDoublePixel(quantum_info,p,&pixel);
2273 SetPixelOpacity(image,ClampToQuantum(pixel),q);
2274 p+=(ptrdiff_t) quantum_info->pad;
2275 q+=(ptrdiff_t) GetPixelChannels(image);
2286 range=GetQuantumRange(quantum_info->depth);
2287 for (x=0; x < (ssize_t) number_pixels; x++)
2289 p=PushQuantumPixel(quantum_info,p,&pixel);
2290 SetPixelRed(image,ScaleAnyToQuantum(pixel,range),q);
2291 p=PushQuantumPixel(quantum_info,p,&pixel);
2292 SetPixelGreen(image,ScaleAnyToQuantum(pixel,range),q);
2293 p=PushQuantumPixel(quantum_info,p,&pixel);
2294 SetPixelBlue(image,ScaleAnyToQuantum(pixel,range),q);
2295 p=PushQuantumPixel(quantum_info,p,&pixel);
2296 SetPixelBlack(image,ScaleAnyToQuantum(pixel,range),q);
2297 p=PushQuantumPixel(quantum_info,p,&pixel);
2298 SetPixelOpacity(image,ScaleAnyToQuantum(pixel,range),q);
2299 q+=(ptrdiff_t) GetPixelChannels(image);
2307 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
2308 Quantum *magick_restrict q)
2319 assert(image != (
Image *) NULL);
2320 assert(image->signature == MagickCoreSignature);
2321 switch (quantum_info->depth)
2331 if (quantum_info->min_is_white != MagickFalse)
2336 for (x=0; x < ((ssize_t) number_pixels-7); x+=8)
2338 for (bit=0; bit < 8; bit++)
2340 SetPixelGray(image,((*p) & (1 << (7-bit))) == 0 ? black : white,q);
2341 q+=(ptrdiff_t) GetPixelChannels(image);
2345 for (bit=0; bit < (ssize_t) (number_pixels % 8); bit++)
2347 SetPixelGray(image,((*p) & (0x01 << (7-bit))) == 0 ? black : white,q);
2348 q+=(ptrdiff_t) GetPixelChannels(image);
2359 range=GetQuantumRange(quantum_info->depth);
2360 for (x=0; x < ((ssize_t) number_pixels-1); x+=2)
2362 pixel=(
unsigned char) ((*p >> 4) & 0xf);
2363 SetPixelGray(image,ScaleAnyToQuantum(pixel,range),q);
2364 q+=(ptrdiff_t) GetPixelChannels(image);
2365 pixel=(
unsigned char) ((*p) & 0xf);
2366 SetPixelGray(image,ScaleAnyToQuantum(pixel,range),q);
2368 q+=(ptrdiff_t) GetPixelChannels(image);
2370 for (bit=0; bit < (ssize_t) (number_pixels % 2); bit++)
2372 pixel=(
unsigned char) (*p++ >> 4);
2373 SetPixelGray(image,ScaleAnyToQuantum(pixel,range),q);
2374 q+=(ptrdiff_t) GetPixelChannels(image);
2383 if (quantum_info->min_is_white != MagickFalse)
2385 for (x=0; x < (ssize_t) number_pixels; x++)
2387 p=PushCharPixel(p,&pixel);
2388 SetPixelGray(image,QuantumRange-ScaleCharToQuantum(pixel),q);
2389 SetPixelAlpha(image,OpaqueAlpha,q);
2390 p+=(ptrdiff_t) quantum_info->pad;
2391 q+=(ptrdiff_t) GetPixelChannels(image);
2395 for (x=0; x < (ssize_t) number_pixels; x++)
2397 p=PushCharPixel(p,&pixel);
2398 SetPixelGray(image,ScaleCharToQuantum(pixel),q);
2399 SetPixelAlpha(image,OpaqueAlpha,q);
2400 p+=(ptrdiff_t) quantum_info->pad;
2401 q+=(ptrdiff_t) GetPixelChannels(image);
2411 range=GetQuantumRange(quantum_info->depth);
2412 if (quantum_info->pack == MagickFalse)
2414 if (image->endian == LSBEndian)
2416 for (x=0; x < (ssize_t) (number_pixels-2); x+=3)
2418 p=PushLongPixel(quantum_info->endian,p,&pixel);
2419 SetPixelGray(image,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,
2421 q+=(ptrdiff_t) GetPixelChannels(image);
2422 SetPixelGray(image,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,
2424 q+=(ptrdiff_t) GetPixelChannels(image);
2425 SetPixelGray(image,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,
2427 p+=(ptrdiff_t) quantum_info->pad;
2428 q+=(ptrdiff_t) GetPixelChannels(image);
2430 if (x++ < (ssize_t) (number_pixels-1))
2432 p=PushLongPixel(quantum_info->endian,p,&pixel);
2433 SetPixelGray(image,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,
2435 q+=(ptrdiff_t) GetPixelChannels(image);
2437 if (x++ < (ssize_t) number_pixels)
2439 SetPixelGray(image,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,
2441 q+=(ptrdiff_t) GetPixelChannels(image);
2445 for (x=0; x < (ssize_t) (number_pixels-2); x+=3)
2447 p=PushLongPixel(quantum_info->endian,p,&pixel);
2448 SetPixelGray(image,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range),
2450 q+=(ptrdiff_t) GetPixelChannels(image);
2451 SetPixelGray(image,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range),
2453 q+=(ptrdiff_t) GetPixelChannels(image);
2454 SetPixelGray(image,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range),
2456 p+=(ptrdiff_t) quantum_info->pad;
2457 q+=(ptrdiff_t) GetPixelChannels(image);
2459 if (x++ < (ssize_t) (number_pixels-1))
2461 p=PushLongPixel(quantum_info->endian,p,&pixel);
2462 SetPixelGray(image,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,
2464 q+=(ptrdiff_t) GetPixelChannels(image);
2466 if (x++ < (ssize_t) number_pixels)
2468 SetPixelGray(image,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,
2470 q+=(ptrdiff_t) GetPixelChannels(image);
2474 for (x=0; x < (ssize_t) number_pixels; x++)
2476 p=PushQuantumPixel(quantum_info,p,&pixel);
2477 SetPixelGray(image,ScaleAnyToQuantum(pixel,range),q);
2478 p+=(ptrdiff_t) quantum_info->pad;
2479 q+=(ptrdiff_t) GetPixelChannels(image);
2485 range=GetQuantumRange(quantum_info->depth);
2486 if (quantum_info->pack == MagickFalse)
2491 for (x=0; x < (ssize_t) (number_pixels-1); x+=2)
2493 p=PushShortPixel(quantum_info->endian,p,&pixel);
2494 SetPixelGray(image,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
2496 q+=(ptrdiff_t) GetPixelChannels(image);
2497 p=PushShortPixel(quantum_info->endian,p,&pixel);
2498 SetPixelGray(image,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
2500 p+=(ptrdiff_t) quantum_info->pad;
2501 q+=(ptrdiff_t) GetPixelChannels(image);
2503 for (bit=0; bit < (ssize_t) (number_pixels % 2); bit++)
2505 p=PushShortPixel(quantum_info->endian,p,&pixel);
2506 SetPixelGray(image,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
2508 p+=(ptrdiff_t) quantum_info->pad;
2509 q+=(ptrdiff_t) GetPixelChannels(image);
2520 for (x=0; x < (ssize_t) number_pixels; x++)
2522 p=PushQuantumPixel(quantum_info,p,&pixel);
2523 SetPixelGray(image,ScaleAnyToQuantum(pixel,range),q);
2524 p+=(ptrdiff_t) quantum_info->pad;
2525 q+=(ptrdiff_t) GetPixelChannels(image);
2535 if (quantum_info->min_is_white != MagickFalse)
2537 for (x=0; x < (ssize_t) number_pixels; x++)
2539 p=PushShortPixel(quantum_info->endian,p,&pixel);
2540 SetPixelGray(image,QuantumRange-ScaleShortToQuantum(pixel),q);
2541 p+=(ptrdiff_t) quantum_info->pad;
2542 q+=(ptrdiff_t) GetPixelChannels(image);
2546 if (quantum_info->format == FloatingPointQuantumFormat)
2548 for (x=0; x < (ssize_t) number_pixels; x++)
2550 p=PushShortPixel(quantum_info->endian,p,&pixel);
2551 SetPixelGray(image,ClampToQuantum((
double) QuantumRange*(
double)
2552 HalfToSinglePrecision(pixel)),q);
2553 p+=(ptrdiff_t) quantum_info->pad;
2554 q+=(ptrdiff_t) GetPixelChannels(image);
2558 if (quantum_info->format == SignedQuantumFormat)
2560 for (x=0; x < (ssize_t) number_pixels; x++)
2562 p=PushShortPixel(quantum_info->endian,p,&pixel);
2563 pixel=(
unsigned short) (((
unsigned int) pixel+32768) % 65536);
2564 SetPixelGray(image,ScaleShortToQuantum(pixel),q);
2565 p+=(ptrdiff_t) quantum_info->pad;
2566 q+=(ptrdiff_t) GetPixelChannels(image);
2570 for (x=0; x < (ssize_t) number_pixels; x++)
2572 p=PushShortPixel(quantum_info->endian,p,&pixel);
2573 SetPixelGray(image,ScaleShortToQuantum(pixel),q);
2574 p+=(ptrdiff_t) quantum_info->pad;
2575 q+=(ptrdiff_t) GetPixelChannels(image);
2581 if (quantum_info->format == FloatingPointQuantumFormat)
2586 for (x=0; x < (ssize_t) number_pixels; x++)
2588 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2589 SetPixelGray(image,ClampToQuantum(pixel),q);
2590 p+=(ptrdiff_t) quantum_info->pad;
2591 q+=(ptrdiff_t) GetPixelChannels(image);
2600 for (x=0; x < (ssize_t) number_pixels; x++)
2602 p=PushLongPixel(quantum_info->endian,p,&pixel);
2603 SetPixelGray(image,ScaleLongToQuantum(pixel),q);
2604 p+=(ptrdiff_t) quantum_info->pad;
2605 q+=(ptrdiff_t) GetPixelChannels(image);
2612 if (quantum_info->format == FloatingPointQuantumFormat)
2617 for (x=0; x < (ssize_t) number_pixels; x++)
2619 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2620 SetPixelGray(image,ClampToQuantum(pixel),q);
2621 p+=(ptrdiff_t) quantum_info->pad;
2622 q+=(ptrdiff_t) GetPixelChannels(image);
2630 if (quantum_info->format == FloatingPointQuantumFormat)
2635 for (x=0; x < (ssize_t) number_pixels; x++)
2637 p=PushDoublePixel(quantum_info,p,&pixel);
2638 SetPixelGray(image,ClampToQuantum(pixel),q);
2639 p+=(ptrdiff_t) quantum_info->pad;
2640 q+=(ptrdiff_t) GetPixelChannels(image);
2651 range=GetQuantumRange(quantum_info->depth);
2652 for (x=0; x < (ssize_t) number_pixels; x++)
2654 p=PushQuantumPixel(quantum_info,p,&pixel);
2655 SetPixelGray(image,ScaleAnyToQuantum(pixel,range),q);
2656 p+=(ptrdiff_t) quantum_info->pad;
2657 q+=(ptrdiff_t) GetPixelChannels(image);
2664static void ImportGrayAlphaQuantum(
const Image *image,
QuantumInfo *quantum_info,
2665 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
2666 Quantum *magick_restrict q)
2677 assert(image != (
Image *) NULL);
2678 assert(image->signature == MagickCoreSignature);
2679 switch (quantum_info->depth)
2687 for (x=((ssize_t) number_pixels-3); x > 0; x-=4)
2689 for (bit=0; bit < 8; bit+=2)
2691 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
2692 SetPixelGray(image,(Quantum) (pixel == 0 ? 0 : QuantumRange),q);
2693 SetPixelAlpha(image,((*p) & (1UL << (
unsigned char) (6-bit))) == 0 ?
2694 TransparentAlpha : OpaqueAlpha,q);
2695 q+=(ptrdiff_t) GetPixelChannels(image);
2699 if ((number_pixels % 4) != 0)
2700 for (bit=3; bit >= (ssize_t) (4-(number_pixels % 4)); bit-=2)
2702 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
2703 SetPixelGray(image,(Quantum) (pixel != 0 ? 0 : QuantumRange),q);
2704 SetPixelAlpha(image,((*p) & (1UL << (
unsigned char) (6-bit))) == 0 ?
2705 TransparentAlpha : OpaqueAlpha,q);
2706 q+=(ptrdiff_t) GetPixelChannels(image);
2717 range=GetQuantumRange(quantum_info->depth);
2718 for (x=0; x < (ssize_t) number_pixels; x++)
2720 pixel=(
unsigned char) ((*p >> 4) & 0xf);
2721 SetPixelGray(image,ScaleAnyToQuantum(pixel,range),q);
2722 pixel=(
unsigned char) ((*p) & 0xf);
2723 SetPixelAlpha(image,ScaleAnyToQuantum(pixel,range),q);
2725 q+=(ptrdiff_t) GetPixelChannels(image);
2734 for (x=0; x < (ssize_t) number_pixels; x++)
2736 p=PushCharPixel(p,&pixel);
2737 SetPixelGray(image,ScaleCharToQuantum(pixel),q);
2738 p=PushCharPixel(p,&pixel);
2739 SetPixelAlpha(image,ScaleCharToQuantum(pixel),q);
2740 p+=(ptrdiff_t) quantum_info->pad;
2741 q+=(ptrdiff_t) GetPixelChannels(image);
2750 range=GetQuantumRange(quantum_info->depth);
2751 for (x=0; x < (ssize_t) number_pixels; x++)
2753 p=PushQuantumPixel(quantum_info,p,&pixel);
2754 SetPixelGray(image,ScaleAnyToQuantum(pixel,range),q);
2755 p=PushQuantumPixel(quantum_info,p,&pixel);
2756 SetPixelAlpha(image,ScaleAnyToQuantum(pixel,range),q);
2757 p+=(ptrdiff_t) quantum_info->pad;
2758 q+=(ptrdiff_t) GetPixelChannels(image);
2767 range=GetQuantumRange(quantum_info->depth);
2768 for (x=0; x < (ssize_t) number_pixels; x++)
2770 p=PushQuantumPixel(quantum_info,p,&pixel);
2771 SetPixelGray(image,ScaleAnyToQuantum(pixel,range),q);
2772 p=PushQuantumPixel(quantum_info,p,&pixel);
2773 SetPixelAlpha(image,ScaleAnyToQuantum(pixel,range),q);
2774 p+=(ptrdiff_t) quantum_info->pad;
2775 q+=(ptrdiff_t) GetPixelChannels(image);
2784 if (quantum_info->format == FloatingPointQuantumFormat)
2786 for (x=0; x < (ssize_t) number_pixels; x++)
2788 p=PushShortPixel(quantum_info->endian,p,&pixel);
2789 SetPixelGray(image,ClampToQuantum((
double) QuantumRange*(
double)
2790 HalfToSinglePrecision(pixel)),q);
2791 p=PushShortPixel(quantum_info->endian,p,&pixel);
2792 SetPixelAlpha(image,ClampToQuantum((
double) QuantumRange*(
double)
2793 HalfToSinglePrecision(pixel)),q);
2794 p+=(ptrdiff_t) quantum_info->pad;
2795 q+=(ptrdiff_t) GetPixelChannels(image);
2799 for (x=0; x < (ssize_t) number_pixels; x++)
2801 p=PushShortPixel(quantum_info->endian,p,&pixel);
2802 SetPixelGray(image,ScaleShortToQuantum(pixel),q);
2803 p=PushShortPixel(quantum_info->endian,p,&pixel);
2804 SetPixelAlpha(image,ScaleShortToQuantum(pixel),q);
2805 p+=(ptrdiff_t) quantum_info->pad;
2806 q+=(ptrdiff_t) GetPixelChannels(image);
2812 if (quantum_info->format == FloatingPointQuantumFormat)
2817 for (x=0; x < (ssize_t) number_pixels; x++)
2819 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2820 SetPixelGray(image,ClampToQuantum(pixel),q);
2821 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2822 SetPixelAlpha(image,ClampToQuantum(pixel),q);
2823 p+=(ptrdiff_t) quantum_info->pad;
2824 q+=(ptrdiff_t) GetPixelChannels(image);
2833 for (x=0; x < (ssize_t) number_pixels; x++)
2835 p=PushLongPixel(quantum_info->endian,p,&pixel);
2836 SetPixelGray(image,ScaleLongToQuantum(pixel),q);
2837 p=PushLongPixel(quantum_info->endian,p,&pixel);
2838 SetPixelAlpha(image,ScaleLongToQuantum(pixel),q);
2839 p+=(ptrdiff_t) quantum_info->pad;
2840 q+=(ptrdiff_t) GetPixelChannels(image);
2847 if (quantum_info->format == FloatingPointQuantumFormat)
2852 for (x=0; x < (ssize_t) number_pixels; x++)
2854 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2855 SetPixelGray(image,ClampToQuantum(pixel),q);
2856 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
2857 SetPixelAlpha(image,ClampToQuantum(pixel),q);
2858 p+=(ptrdiff_t) quantum_info->pad;
2859 q+=(ptrdiff_t) GetPixelChannels(image);
2867 if (quantum_info->format == FloatingPointQuantumFormat)
2872 for (x=0; x < (ssize_t) number_pixels; x++)
2874 p=PushDoublePixel(quantum_info,p,&pixel);
2875 SetPixelGray(image,ClampToQuantum(pixel),q);
2876 p=PushDoublePixel(quantum_info,p,&pixel);
2877 SetPixelAlpha(image,ClampToQuantum(pixel),q);
2878 p+=(ptrdiff_t) quantum_info->pad;
2879 q+=(ptrdiff_t) GetPixelChannels(image);
2890 range=GetQuantumRange(quantum_info->depth);
2891 for (x=0; x < (ssize_t) number_pixels; x++)
2893 p=PushQuantumPixel(quantum_info,p,&pixel);
2894 SetPixelGray(image,ScaleAnyToQuantum(pixel,range),q);
2895 p=PushQuantumPixel(quantum_info,p,&pixel);
2896 SetPixelAlpha(image,ScaleAnyToQuantum(pixel,range),q);
2897 p+=(ptrdiff_t) quantum_info->pad;
2898 q+=(ptrdiff_t) GetPixelChannels(image);
2905static void ImportGreenQuantum(
const Image *image,
QuantumInfo *quantum_info,
2906 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
2907 Quantum *magick_restrict q)
2915 assert(image != (
Image *) NULL);
2916 assert(image->signature == MagickCoreSignature);
2917 switch (quantum_info->depth)
2924 for (x=0; x < (ssize_t) number_pixels; x++)
2926 p=PushCharPixel(p,&pixel);
2927 SetPixelGreen(image,ScaleCharToQuantum(pixel),q);
2928 p+=(ptrdiff_t) quantum_info->pad;
2929 q+=(ptrdiff_t) GetPixelChannels(image);
2938 if (quantum_info->format == FloatingPointQuantumFormat)
2940 for (x=0; x < (ssize_t) number_pixels; x++)
2942 p=PushShortPixel(quantum_info->endian,p,&pixel);
2943 SetPixelGreen(image,ClampToQuantum((
double) QuantumRange*(
double)
2944 HalfToSinglePrecision(pixel)),q);
2945 p+=(ptrdiff_t) quantum_info->pad;
2946 q+=(ptrdiff_t) GetPixelChannels(image);
2950 for (x=0; x < (ssize_t) number_pixels; x++)
2952 p=PushShortPixel(quantum_info->endian,p,&pixel);
2953 SetPixelGreen(image,ScaleShortToQuantum(pixel),q);
2954 p+=(ptrdiff_t) quantum_info->pad;
2955 q+=(ptrdiff_t) GetPixelChannels(image);
2961 if (quantum_info->format == FloatingPointQuantumFormat)
2966 for (x=0; x < (ssize_t) number_pixels; x++)
2968 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
2969 SetPixelGreen(image,ClampToQuantum(pixel),q);
2970 p+=(ptrdiff_t) quantum_info->pad;
2971 q+=(ptrdiff_t) GetPixelChannels(image);
2980 for (x=0; x < (ssize_t) number_pixels; x++)
2982 p=PushLongPixel(quantum_info->endian,p,&pixel);
2983 SetPixelGreen(image,ScaleLongToQuantum(pixel),q);
2984 p+=(ptrdiff_t) quantum_info->pad;
2985 q+=(ptrdiff_t) GetPixelChannels(image);
2992 if (quantum_info->format == FloatingPointQuantumFormat)
2997 for (x=0; x < (ssize_t) number_pixels; x++)
2999 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3000 SetPixelGreen(image,ClampToQuantum(pixel),q);
3001 p+=(ptrdiff_t) quantum_info->pad;
3002 q+=(ptrdiff_t) GetPixelChannels(image);
3010 if (quantum_info->format == FloatingPointQuantumFormat)
3015 for (x=0; x < (ssize_t) number_pixels; x++)
3017 p=PushDoublePixel(quantum_info,p,&pixel);
3018 SetPixelGreen(image,ClampToQuantum(pixel),q);
3019 p+=(ptrdiff_t) quantum_info->pad;
3020 q+=(ptrdiff_t) GetPixelChannels(image);
3031 range=GetQuantumRange(quantum_info->depth);
3032 for (x=0; x < (ssize_t) number_pixels; x++)
3034 p=PushQuantumPixel(quantum_info,p,&pixel);
3035 SetPixelGreen(image,ScaleAnyToQuantum(pixel,range),q);
3036 p+=(ptrdiff_t) quantum_info->pad;
3037 q+=(ptrdiff_t) GetPixelChannels(image);
3044static void ImportIndexQuantum(
const Image *image,
QuantumInfo *quantum_info,
3045 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
3057 if (image->storage_class != PseudoClass)
3059 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
3060 "ColormappedImageRequired",
"`%s'",image->filename);
3063 range_exception=MagickFalse;
3064 switch (quantum_info->depth)
3071 for (x=0; x < ((ssize_t) number_pixels-7); x+=8)
3073 for (bit=0; bit < 8; bit++)
3075 if (quantum_info->min_is_white == MagickFalse)
3076 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) == 0 ?
3079 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) != 0 ?
3081 SetPixelIndex(image,PushColormapIndex(image,pixel,&range_exception),
3083 SetPixelViaPixelInfo(image,image->colormap+(ssize_t)
3084 GetPixelIndex(image,q),q);
3085 q+=(ptrdiff_t) GetPixelChannels(image);
3089 for (bit=0; bit < (ssize_t) (number_pixels % 8); bit++)
3091 if (quantum_info->min_is_white == MagickFalse)
3092 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) == 0 ? 0x00 : 0x01);
3094 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
3095 SetPixelIndex(image,PushColormapIndex(image,pixel,&range_exception),q);
3096 SetPixelViaPixelInfo(image,image->colormap+(ssize_t)
3097 GetPixelIndex(image,q),q);
3098 q+=(ptrdiff_t) GetPixelChannels(image);
3107 for (x=0; x < ((ssize_t) number_pixels-1); x+=2)
3109 pixel=(
unsigned char) ((*p >> 4) & 0xf);
3110 SetPixelIndex(image,PushColormapIndex(image,pixel,&range_exception),q);
3111 SetPixelViaPixelInfo(image,image->colormap+(ssize_t)
3112 GetPixelIndex(image,q),q);
3113 q+=(ptrdiff_t) GetPixelChannels(image);
3114 pixel=(
unsigned char) ((*p) & 0xf);
3115 SetPixelIndex(image,PushColormapIndex(image,pixel,&range_exception),q);
3116 SetPixelViaPixelInfo(image,image->colormap+(ssize_t)
3117 GetPixelIndex(image,q),q);
3119 q+=(ptrdiff_t) GetPixelChannels(image);
3121 for (bit=0; bit < (ssize_t) (number_pixels % 2); bit++)
3123 pixel=(
unsigned char) ((*p++ >> 4) & 0xf);
3124 SetPixelIndex(image,PushColormapIndex(image,pixel,&range_exception),q);
3125 SetPixelViaPixelInfo(image,image->colormap+(ssize_t)
3126 GetPixelIndex(image,q),q);
3127 q+=(ptrdiff_t) GetPixelChannels(image);
3136 for (x=0; x < (ssize_t) number_pixels; x++)
3138 p=PushCharPixel(p,&pixel);
3139 SetPixelIndex(image,PushColormapIndex(image,pixel,&range_exception),q);
3140 SetPixelViaPixelInfo(image,image->colormap+(ssize_t)
3141 GetPixelIndex(image,q),q);
3142 p+=(ptrdiff_t) quantum_info->pad;
3143 q+=(ptrdiff_t) GetPixelChannels(image);
3152 if (quantum_info->format == FloatingPointQuantumFormat)
3154 for (x=0; x < (ssize_t) number_pixels; x++)
3156 p=PushShortPixel(quantum_info->endian,p,&pixel);
3157 SetPixelIndex(image,PushColormapIndex(image,(
size_t)
3158 ClampToQuantum((
double) QuantumRange*(
double)
3159 HalfToSinglePrecision(pixel)),&range_exception),q);
3160 SetPixelViaPixelInfo(image,image->colormap+(ssize_t)
3161 GetPixelIndex(image,q),q);
3162 p+=(ptrdiff_t) quantum_info->pad;
3163 q+=(ptrdiff_t) GetPixelChannels(image);
3167 for (x=0; x < (ssize_t) number_pixels; x++)
3169 p=PushShortPixel(quantum_info->endian,p,&pixel);
3170 SetPixelIndex(image,PushColormapIndex(image,pixel,&range_exception),q);
3171 SetPixelViaPixelInfo(image,image->colormap+(ssize_t)
3172 GetPixelIndex(image,q),q);
3173 p+=(ptrdiff_t) quantum_info->pad;
3174 q+=(ptrdiff_t) GetPixelChannels(image);
3180 if (quantum_info->format == FloatingPointQuantumFormat)
3185 for (x=0; x < (ssize_t) number_pixels; x++)
3187 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3188 SetPixelIndex(image,PushColormapIndex(image,(
size_t)
3189 ClampToQuantum(pixel),&range_exception),q);
3190 SetPixelViaPixelInfo(image,image->colormap+(ssize_t)
3191 GetPixelIndex(image,q),q);
3192 p+=(ptrdiff_t) quantum_info->pad;
3193 q+=(ptrdiff_t) GetPixelChannels(image);
3202 for (x=0; x < (ssize_t) number_pixels; x++)
3204 p=PushLongPixel(quantum_info->endian,p,&pixel);
3205 SetPixelIndex(image,PushColormapIndex(image,pixel,
3206 &range_exception),q);
3207 SetPixelViaPixelInfo(image,image->colormap+(ssize_t)
3208 GetPixelIndex(image,q),q);
3209 p+=(ptrdiff_t) quantum_info->pad;
3210 q+=(ptrdiff_t) GetPixelChannels(image);
3217 if (quantum_info->format == FloatingPointQuantumFormat)
3222 for (x=0; x < (ssize_t) number_pixels; x++)
3224 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3225 SetPixelIndex(image,PushColormapIndex(image,(
size_t)
3226 ClampToQuantum(pixel),&range_exception),q);
3227 SetPixelViaPixelInfo(image,image->colormap+(ssize_t)
3228 GetPixelIndex(image,q),q);
3229 p+=(ptrdiff_t) quantum_info->pad;
3230 q+=(ptrdiff_t) GetPixelChannels(image);
3238 if (quantum_info->format == FloatingPointQuantumFormat)
3243 for (x=0; x < (ssize_t) number_pixels; x++)
3245 p=PushDoublePixel(quantum_info,p,&pixel);
3246 SetPixelIndex(image,PushColormapIndex(image,(
size_t)
3247 ClampToQuantum(pixel),&range_exception),q);
3248 SetPixelViaPixelInfo(image,image->colormap+(ssize_t)
3249 GetPixelIndex(image,q),q);
3250 p+=(ptrdiff_t) quantum_info->pad;
3251 q+=(ptrdiff_t) GetPixelChannels(image);
3262 for (x=0; x < (ssize_t) number_pixels; x++)
3264 p=PushQuantumPixel(quantum_info,p,&pixel);
3265 SetPixelIndex(image,PushColormapIndex(image,pixel,&range_exception),q);
3266 SetPixelViaPixelInfo(image,image->colormap+(ssize_t)
3267 GetPixelIndex(image,q),q);
3268 p+=(ptrdiff_t) quantum_info->pad;
3269 q+=(ptrdiff_t) GetPixelChannels(image);
3274 if (range_exception != MagickFalse)
3275 (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError,
3276 "InvalidColormapIndex",
"`%s'",image->filename);
3279static void ImportIndexAlphaQuantum(
const Image *image,
3280 QuantumInfo *quantum_info,
const MagickSizeType number_pixels,
3281 const unsigned char *magick_restrict p,Quantum *magick_restrict q,
3296 if (image->storage_class != PseudoClass)
3298 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
3299 "ColormappedImageRequired",
"`%s'",image->filename);
3302 range_exception=MagickFalse;
3303 switch (quantum_info->depth)
3310 for (x=((ssize_t) number_pixels-3); x > 0; x-=4)
3312 for (bit=0; bit < 8; bit+=2)
3314 if (quantum_info->min_is_white == MagickFalse)
3315 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) == 0 ? 0x00 : 0x01);
3317 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
3318 SetPixelGray(image,(Quantum) (pixel == 0 ? 0 : QuantumRange),q);
3319 SetPixelAlpha(image,((*p) & (1UL << (
unsigned char) (6-bit))) == 0 ?
3320 TransparentAlpha : OpaqueAlpha,q);
3321 SetPixelIndex(image,(Quantum) (pixel == 0 ? 0 : 1),q);
3322 q+=(ptrdiff_t) GetPixelChannels(image);
3325 if ((number_pixels % 4) != 0)
3326 for (bit=3; bit >= (ssize_t) (4-(number_pixels % 4)); bit-=2)
3328 if (quantum_info->min_is_white == MagickFalse)
3329 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) == 0 ? 0x00 : 0x01);
3331 pixel=(
unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
3332 SetPixelIndex(image,(Quantum) (pixel == 0 ? 0 : 1),q);
3333 SetPixelGray(image,(Quantum) (pixel == 0 ? 0 : QuantumRange),q);
3334 SetPixelAlpha(image,((*p) & (1UL << (
unsigned char) (6-bit))) == 0 ?
3335 TransparentAlpha : OpaqueAlpha,q);
3336 q+=(ptrdiff_t) GetPixelChannels(image);
3345 range=GetQuantumRange(quantum_info->depth);
3346 for (x=0; x < (ssize_t) number_pixels; x++)
3348 pixel=(
unsigned char) ((*p >> 4) & 0xf);
3349 SetPixelIndex(image,PushColormapIndex(image,pixel,&range_exception),q);
3350 SetPixelViaPixelInfo(image,image->colormap+(ssize_t)
3351 GetPixelIndex(image,q),q);
3352 pixel=(
unsigned char) ((*p) & 0xf);
3353 SetPixelAlpha(image,ScaleAnyToQuantum(pixel,range),q);
3355 q+=(ptrdiff_t) GetPixelChannels(image);
3364 for (x=0; x < (ssize_t) number_pixels; x++)
3366 p=PushCharPixel(p,&pixel);
3367 SetPixelIndex(image,PushColormapIndex(image,pixel,&range_exception),q);
3368 SetPixelViaPixelInfo(image,image->colormap+(ssize_t)
3369 GetPixelIndex(image,q),q);
3370 p=PushCharPixel(p,&pixel);
3371 SetPixelAlpha(image,ScaleCharToQuantum(pixel),q);
3372 p+=(ptrdiff_t) quantum_info->pad;
3373 q+=(ptrdiff_t) GetPixelChannels(image);
3382 if (quantum_info->format == FloatingPointQuantumFormat)
3384 for (x=0; x < (ssize_t) number_pixels; x++)
3386 p=PushShortPixel(quantum_info->endian,p,&pixel);
3387 SetPixelIndex(image,PushColormapIndex(image,(
size_t)
3388 ClampToQuantum((
double) QuantumRange*(
double)
3389 HalfToSinglePrecision(pixel)),&range_exception),q);
3390 SetPixelViaPixelInfo(image,image->colormap+(ssize_t)
3391 GetPixelIndex(image,q),q);
3392 p=PushShortPixel(quantum_info->endian,p,&pixel);
3393 SetPixelAlpha(image,ClampToQuantum((
double) QuantumRange*(
double)
3394 HalfToSinglePrecision(pixel)),q);
3395 p+=(ptrdiff_t) quantum_info->pad;
3396 q+=(ptrdiff_t) GetPixelChannels(image);
3400 for (x=0; x < (ssize_t) number_pixels; x++)
3402 p=PushShortPixel(quantum_info->endian,p,&pixel);
3403 SetPixelIndex(image,PushColormapIndex(image,pixel,&range_exception),q);
3404 SetPixelViaPixelInfo(image,image->colormap+(ssize_t)
3405 GetPixelIndex(image,q),q);
3406 p=PushShortPixel(quantum_info->endian,p,&pixel);
3407 SetPixelAlpha(image,ScaleShortToQuantum(pixel),q);
3408 p+=(ptrdiff_t) quantum_info->pad;
3409 q+=(ptrdiff_t) GetPixelChannels(image);
3415 if (quantum_info->format == FloatingPointQuantumFormat)
3420 for (x=0; x < (ssize_t) number_pixels; x++)
3422 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3423 SetPixelIndex(image,PushColormapIndex(image,(
size_t)
3424 ClampToQuantum(pixel),&range_exception),q);
3425 SetPixelViaPixelInfo(image,image->colormap+(ssize_t)
3426 GetPixelIndex(image,q),q);
3427 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3428 SetPixelAlpha(image,ClampToQuantum(pixel),q);
3429 p+=(ptrdiff_t) quantum_info->pad;
3430 q+=(ptrdiff_t) GetPixelChannels(image);
3439 for (x=0; x < (ssize_t) number_pixels; x++)
3441 p=PushLongPixel(quantum_info->endian,p,&pixel);
3442 SetPixelIndex(image,PushColormapIndex(image,pixel,
3443 &range_exception),q);
3444 SetPixelViaPixelInfo(image,image->colormap+(ssize_t)
3445 GetPixelIndex(image,q),q);
3446 p=PushLongPixel(quantum_info->endian,p,&pixel);
3447 SetPixelAlpha(image,ScaleLongToQuantum(pixel),q);
3448 p+=(ptrdiff_t) quantum_info->pad;
3449 q+=(ptrdiff_t) GetPixelChannels(image);
3456 if (quantum_info->format == FloatingPointQuantumFormat)
3461 for (x=0; x < (ssize_t) number_pixels; x++)
3463 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3464 SetPixelIndex(image,PushColormapIndex(image,(
size_t)
3465 ClampToQuantum(pixel),&range_exception),q);
3466 SetPixelViaPixelInfo(image,image->colormap+(ssize_t)
3467 GetPixelIndex(image,q),q);
3468 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3469 SetPixelAlpha(image,ClampToQuantum(pixel),q);
3470 p+=(ptrdiff_t) quantum_info->pad;
3471 q+=(ptrdiff_t) GetPixelChannels(image);
3479 if (quantum_info->format == FloatingPointQuantumFormat)
3484 for (x=0; x < (ssize_t) number_pixels; x++)
3486 p=PushDoublePixel(quantum_info,p,&pixel);
3487 SetPixelIndex(image,PushColormapIndex(image,(
size_t)
3488 ClampToQuantum(pixel),&range_exception),q);
3489 SetPixelViaPixelInfo(image,image->colormap+(ssize_t)
3490 GetPixelIndex(image,q),q);
3491 p=PushDoublePixel(quantum_info,p,&pixel);
3492 SetPixelAlpha(image,ClampToQuantum(pixel),q);
3493 p+=(ptrdiff_t) quantum_info->pad;
3494 q+=(ptrdiff_t) GetPixelChannels(image);
3505 range=GetQuantumRange(quantum_info->depth);
3506 for (x=0; x < (ssize_t) number_pixels; x++)
3508 p=PushQuantumPixel(quantum_info,p,&pixel);
3509 SetPixelIndex(image,PushColormapIndex(image,pixel,&range_exception),q);
3510 SetPixelViaPixelInfo(image,image->colormap+(ssize_t)
3511 GetPixelIndex(image,q),q);
3512 p=PushQuantumPixel(quantum_info,p,&pixel);
3513 SetPixelAlpha(image,ScaleAnyToQuantum(pixel,range),q);
3514 p+=(ptrdiff_t) quantum_info->pad;
3515 q+=(ptrdiff_t) GetPixelChannels(image);
3520 if (range_exception != MagickFalse)
3521 (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError,
3522 "InvalidColormapIndex",
"`%s'",image->filename);
3525static void ImportMultispectralQuantum(
const Image *image,
3526 QuantumInfo *quantum_info,
const MagickSizeType number_pixels,
3527 const unsigned char *magick_restrict p,Quantum *magick_restrict q,
3537 if (image->number_meta_channels == 0)
3539 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
3540 "MultispectralImageRequired",
"`%s'",image->filename);
3543 switch (quantum_info->depth)
3550 for (x=0; x < (ssize_t) number_pixels; x++)
3552 for (i=0; i < (ssize_t) GetImageChannels(image); i++)
3554 p=PushCharPixel(p,&pixel);
3555 q[i]=ScaleCharToQuantum(pixel);
3557 p+=(ptrdiff_t) quantum_info->pad;
3558 q+=(ptrdiff_t) GetPixelChannels(image);
3567 if (quantum_info->format == FloatingPointQuantumFormat)
3569 for (x=0; x < (ssize_t) number_pixels; x++)
3571 for (i=0; i < (ssize_t) GetImageChannels(image); i++)
3573 p=PushShortPixel(quantum_info->endian,p,&pixel);
3574 q[i]=ClampToQuantum((
double) QuantumRange*(
double)HalfToSinglePrecision(pixel));
3576 p+=(ptrdiff_t) quantum_info->pad;
3577 q+=(ptrdiff_t) GetPixelChannels(image);
3581 for (x=0; x < (ssize_t) number_pixels; x++)
3583 for (i=0; i < (ssize_t) GetImageChannels(image); i++)
3585 p=PushShortPixel(quantum_info->endian,p,&pixel);
3586 q[i]=ScaleShortToQuantum(pixel);
3588 p+=(ptrdiff_t) quantum_info->pad;
3589 q+=(ptrdiff_t) GetPixelChannels(image);
3595 if (quantum_info->format == FloatingPointQuantumFormat)
3600 for (x=0; x < (ssize_t) number_pixels; x++)
3602 for (i=0; i < (ssize_t) GetImageChannels(image); i++)
3604 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3605 q[i]=ClampToQuantum(pixel);
3607 p+=(ptrdiff_t) quantum_info->pad;
3608 q+=(ptrdiff_t) GetPixelChannels(image);
3617 for (x=0; x < (ssize_t) number_pixels; x++)
3619 for (i=0; i < (ssize_t) GetImageChannels(image); i++)
3621 p=PushLongPixel(quantum_info->endian,p,&pixel);
3622 q[i]=ScaleLongToQuantum(pixel);
3624 p+=(ptrdiff_t) quantum_info->pad;
3625 q+=(ptrdiff_t) GetPixelChannels(image);
3632 if (quantum_info->format == FloatingPointQuantumFormat)
3637 for (x=0; x < (ssize_t) number_pixels; x++)
3639 for (i=0; i < (ssize_t) GetImageChannels(image); i++)
3641 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3642 q[i]=ClampToQuantum(pixel);
3644 p+=(ptrdiff_t) quantum_info->pad;
3645 q+=(ptrdiff_t) GetPixelChannels(image);
3653 if (quantum_info->format == FloatingPointQuantumFormat)
3658 for (x=0; x < (ssize_t) number_pixels; x++)
3660 for (i=0; i < (ssize_t) GetImageChannels(image); i++)
3662 p=PushDoublePixel(quantum_info,p,&pixel);
3663 q[i]=ClampToQuantum(pixel);
3665 p+=(ptrdiff_t) quantum_info->pad;
3666 q+=(ptrdiff_t) GetPixelChannels(image);
3677 range=GetQuantumRange(quantum_info->depth);
3678 for (x=0; x < (ssize_t) number_pixels; x++)
3680 for (i=0; i < (ssize_t) GetImageChannels(image); i++)
3682 p=PushQuantumPixel(quantum_info,p,&pixel);
3683 q[i]=ScaleAnyToQuantum(pixel,range);
3685 q+=(ptrdiff_t) GetPixelChannels(image);
3692static void ImportOpacityQuantum(
const Image *image,
QuantumInfo *quantum_info,
3693 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
3694 Quantum *magick_restrict q)
3702 assert(image != (
Image *) NULL);
3703 assert(image->signature == MagickCoreSignature);
3704 switch (quantum_info->depth)
3711 for (x=0; x < (ssize_t) number_pixels; x++)
3713 p=PushCharPixel(p,&pixel);
3714 SetPixelOpacity(image,ScaleCharToQuantum(pixel),q);
3715 p+=(ptrdiff_t) quantum_info->pad;
3716 q+=(ptrdiff_t) GetPixelChannels(image);
3725 if (quantum_info->format == FloatingPointQuantumFormat)
3727 for (x=0; x < (ssize_t) number_pixels; x++)
3729 p=PushShortPixel(quantum_info->endian,p,&pixel);
3730 SetPixelOpacity(image,ClampToQuantum((
double) QuantumRange*(
double)
3731 HalfToSinglePrecision(pixel)),q);
3732 p+=(ptrdiff_t) quantum_info->pad;
3733 q+=(ptrdiff_t) GetPixelChannels(image);
3737 for (x=0; x < (ssize_t) number_pixels; x++)
3739 p=PushShortPixel(quantum_info->endian,p,&pixel);
3740 SetPixelOpacity(image,ScaleShortToQuantum(pixel),q);
3741 p+=(ptrdiff_t) quantum_info->pad;
3742 q+=(ptrdiff_t) GetPixelChannels(image);
3748 if (quantum_info->format == FloatingPointQuantumFormat)
3753 for (x=0; x < (ssize_t) number_pixels; x++)
3755 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3756 SetPixelOpacity(image,ClampToQuantum(pixel),q);
3757 p+=(ptrdiff_t) quantum_info->pad;
3758 q+=(ptrdiff_t) GetPixelChannels(image);
3767 for (x=0; x < (ssize_t) number_pixels; x++)
3769 p=PushLongPixel(quantum_info->endian,p,&pixel);
3770 SetPixelOpacity(image,ScaleLongToQuantum(pixel),q);
3771 p+=(ptrdiff_t) quantum_info->pad;
3772 q+=(ptrdiff_t) GetPixelChannels(image);
3779 if (quantum_info->format == FloatingPointQuantumFormat)
3784 for (x=0; x < (ssize_t) number_pixels; x++)
3786 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3787 SetPixelOpacity(image,ClampToQuantum(pixel),q);
3788 p+=(ptrdiff_t) quantum_info->pad;
3789 q+=(ptrdiff_t) GetPixelChannels(image);
3797 if (quantum_info->format == FloatingPointQuantumFormat)
3802 for (x=0; x < (ssize_t) number_pixels; x++)
3804 p=PushDoublePixel(quantum_info,p,&pixel);
3805 SetPixelOpacity(image,ClampToQuantum(pixel),q);
3806 p+=(ptrdiff_t) quantum_info->pad;
3807 q+=(ptrdiff_t) GetPixelChannels(image);
3818 range=GetQuantumRange(quantum_info->depth);
3819 for (x=0; x < (ssize_t) number_pixels; x++)
3821 p=PushQuantumPixel(quantum_info,p,&pixel);
3822 SetPixelOpacity(image,ScaleAnyToQuantum(pixel,range),q);
3823 p+=(ptrdiff_t) quantum_info->pad;
3824 q+=(ptrdiff_t) GetPixelChannels(image);
3832 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
3833 Quantum *magick_restrict q)
3841 assert(image != (
Image *) NULL);
3842 assert(image->signature == MagickCoreSignature);
3843 switch (quantum_info->depth)
3850 for (x=0; x < (ssize_t) number_pixels; x++)
3852 p=PushCharPixel(p,&pixel);
3853 SetPixelRed(image,ScaleCharToQuantum(pixel),q);
3854 p+=(ptrdiff_t) quantum_info->pad;
3855 q+=(ptrdiff_t) GetPixelChannels(image);
3864 if (quantum_info->format == FloatingPointQuantumFormat)
3866 for (x=0; x < (ssize_t) number_pixels; x++)
3868 p=PushShortPixel(quantum_info->endian,p,&pixel);
3869 SetPixelRed(image,ClampToQuantum((
double) QuantumRange*(
double)
3870 HalfToSinglePrecision(pixel)),q);
3871 p+=(ptrdiff_t) quantum_info->pad;
3872 q+=(ptrdiff_t) GetPixelChannels(image);
3876 for (x=0; x < (ssize_t) number_pixels; x++)
3878 p=PushShortPixel(quantum_info->endian,p,&pixel);
3879 SetPixelRed(image,ScaleShortToQuantum(pixel),q);
3880 p+=(ptrdiff_t) quantum_info->pad;
3881 q+=(ptrdiff_t) GetPixelChannels(image);
3887 if (quantum_info->format == FloatingPointQuantumFormat)
3892 for (x=0; x < (ssize_t) number_pixels; x++)
3894 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
3895 SetPixelRed(image,ClampToQuantum(pixel),q);
3896 p+=(ptrdiff_t) quantum_info->pad;
3897 q+=(ptrdiff_t) GetPixelChannels(image);
3906 for (x=0; x < (ssize_t) number_pixels; x++)
3908 p=PushLongPixel(quantum_info->endian,p,&pixel);
3909 SetPixelRed(image,ScaleLongToQuantum(pixel),q);
3910 p+=(ptrdiff_t) quantum_info->pad;
3911 q+=(ptrdiff_t) GetPixelChannels(image);
3918 if (quantum_info->format == FloatingPointQuantumFormat)
3923 for (x=0; x < (ssize_t) number_pixels; x++)
3925 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
3926 SetPixelRed(image,ClampToQuantum(pixel),q);
3927 p+=(ptrdiff_t) quantum_info->pad;
3928 q+=(ptrdiff_t) GetPixelChannels(image);
3936 if (quantum_info->format == FloatingPointQuantumFormat)
3941 for (x=0; x < (ssize_t) number_pixels; x++)
3943 p=PushDoublePixel(quantum_info,p,&pixel);
3944 SetPixelRed(image,ClampToQuantum(pixel),q);
3945 p+=(ptrdiff_t) quantum_info->pad;
3946 q+=(ptrdiff_t) GetPixelChannels(image);
3957 range=GetQuantumRange(quantum_info->depth);
3958 for (x=0; x < (ssize_t) number_pixels; x++)
3960 p=PushQuantumPixel(quantum_info,p,&pixel);
3961 SetPixelRed(image,ScaleAnyToQuantum(pixel,range),q);
3962 p+=(ptrdiff_t) quantum_info->pad;
3963 q+=(ptrdiff_t) GetPixelChannels(image);
3971 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
3972 Quantum *magick_restrict q)
3983 assert(image != (
Image *) NULL);
3984 assert(image->signature == MagickCoreSignature);
3985 switch (quantum_info->depth)
3992 for (x=0; x < (ssize_t) number_pixels; x++)
3994 p=PushCharPixel(p,&pixel);
3995 SetPixelRed(image,ScaleCharToQuantum(pixel),q);
3996 p=PushCharPixel(p,&pixel);
3997 SetPixelGreen(image,ScaleCharToQuantum(pixel),q);
3998 p=PushCharPixel(p,&pixel);
3999 SetPixelBlue(image,ScaleCharToQuantum(pixel),q);
4000 SetPixelAlpha(image,OpaqueAlpha,q);
4001 p+=(ptrdiff_t) quantum_info->pad;
4002 q+=(ptrdiff_t) GetPixelChannels(image);
4011 range=GetQuantumRange(quantum_info->depth);
4012 if (quantum_info->pack == MagickFalse)
4014 for (x=0; x < (ssize_t) number_pixels; x++)
4016 p=PushLongPixel(quantum_info->endian,p,&pixel);
4017 SetPixelRed(image,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range),q);
4018 SetPixelGreen(image,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range),
4020 SetPixelBlue(image,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range),q);
4021 p+=(ptrdiff_t) quantum_info->pad;
4022 q+=(ptrdiff_t) GetPixelChannels(image);
4026 if (quantum_info->quantum == 32U)
4028 for (x=0; x < (ssize_t) number_pixels; x++)
4030 p=PushQuantumLongPixel(quantum_info,p,&pixel);
4031 SetPixelRed(image,ScaleAnyToQuantum(pixel,range),q);
4032 p=PushQuantumLongPixel(quantum_info,p,&pixel);
4033 SetPixelGreen(image,ScaleAnyToQuantum(pixel,range),q);
4034 p=PushQuantumLongPixel(quantum_info,p,&pixel);
4035 SetPixelBlue(image,ScaleAnyToQuantum(pixel,range),q);
4036 q+=(ptrdiff_t) GetPixelChannels(image);
4040 for (x=0; x < (ssize_t) number_pixels; x++)
4042 p=PushQuantumPixel(quantum_info,p,&pixel);
4043 SetPixelRed(image,ScaleAnyToQuantum(pixel,range),q);
4044 p=PushQuantumPixel(quantum_info,p,&pixel);
4045 SetPixelGreen(image,ScaleAnyToQuantum(pixel,range),q);
4046 p=PushQuantumPixel(quantum_info,p,&pixel);
4047 SetPixelBlue(image,ScaleAnyToQuantum(pixel,range),q);
4048 q+=(ptrdiff_t) GetPixelChannels(image);
4054 range=GetQuantumRange(quantum_info->depth);
4055 if (quantum_info->pack == MagickFalse)
4060 for (x=0; x < (ssize_t) (3*number_pixels-1); x+=2)
4062 p=PushShortPixel(quantum_info->endian,p,&pixel);
4068 SetPixelRed(image,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
4074 SetPixelGreen(image,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
4080 SetPixelBlue(image,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
4082 q+=(ptrdiff_t) GetPixelChannels(image);
4086 p=PushShortPixel(quantum_info->endian,p,&pixel);
4092 SetPixelRed(image,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
4098 SetPixelGreen(image,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
4104 SetPixelBlue(image,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
4106 q+=(ptrdiff_t) GetPixelChannels(image);
4110 p+=(ptrdiff_t) quantum_info->pad;
4112 for (bit=0; bit < (ssize_t) (3*number_pixels % 2); bit++)
4114 p=PushShortPixel(quantum_info->endian,p,&pixel);
4115 switch ((x+bit) % 3)
4120 SetPixelRed(image,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
4126 SetPixelGreen(image,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
4132 SetPixelBlue(image,ScaleAnyToQuantum((QuantumAny) (pixel >> 4),
4134 q+=(ptrdiff_t) GetPixelChannels(image);
4138 p+=(ptrdiff_t) quantum_info->pad;
4149 if (quantum_info->quantum == 32U)
4151 for (x=0; x < (ssize_t) number_pixels; x++)
4153 p=PushQuantumLongPixel(quantum_info,p,&pixel);
4154 SetPixelRed(image,ScaleAnyToQuantum(pixel,range),q);
4155 p=PushQuantumLongPixel(quantum_info,p,&pixel);
4156 SetPixelGreen(image,ScaleAnyToQuantum(pixel,range),q);
4157 p=PushQuantumLongPixel(quantum_info,p,&pixel);
4158 SetPixelBlue(image,ScaleAnyToQuantum(pixel,range),q);
4159 q+=(ptrdiff_t) GetPixelChannels(image);
4163 for (x=0; x < (ssize_t) number_pixels; x++)
4165 p=PushQuantumPixel(quantum_info,p,&pixel);
4166 SetPixelRed(image,ScaleAnyToQuantum(pixel,range),q);
4167 p=PushQuantumPixel(quantum_info,p,&pixel);
4168 SetPixelGreen(image,ScaleAnyToQuantum(pixel,range),q);
4169 p=PushQuantumPixel(quantum_info,p,&pixel);
4170 SetPixelBlue(image,ScaleAnyToQuantum(pixel,range),q);
4171 q+=(ptrdiff_t) GetPixelChannels(image);
4181 if (quantum_info->format == FloatingPointQuantumFormat)
4183 for (x=0; x < (ssize_t) number_pixels; x++)
4185 p=PushShortPixel(quantum_info->endian,p,&pixel);
4186 SetPixelRed(image,ClampToQuantum((
double) QuantumRange*(
double)
4187 HalfToSinglePrecision(pixel)),q);
4188 p=PushShortPixel(quantum_info->endian,p,&pixel);
4189 SetPixelGreen(image,ClampToQuantum((
double) QuantumRange*(
double)
4190 HalfToSinglePrecision(pixel)),q);
4191 p=PushShortPixel(quantum_info->endian,p,&pixel);
4192 SetPixelBlue(image,ClampToQuantum((
double) QuantumRange*(
double)
4193 HalfToSinglePrecision(pixel)),q);
4194 p+=(ptrdiff_t) quantum_info->pad;
4195 q+=(ptrdiff_t) GetPixelChannels(image);
4199 for (x=0; x < (ssize_t) number_pixels; x++)
4201 p=PushShortPixel(quantum_info->endian,p,&pixel);
4202 SetPixelRed(image,ScaleShortToQuantum(pixel),q);
4203 p=PushShortPixel(quantum_info->endian,p,&pixel);
4204 SetPixelGreen(image,ScaleShortToQuantum(pixel),q);
4205 p=PushShortPixel(quantum_info->endian,p,&pixel);
4206 SetPixelBlue(image,ScaleShortToQuantum(pixel),q);
4207 p+=(ptrdiff_t) quantum_info->pad;
4208 q+=(ptrdiff_t) GetPixelChannels(image);
4214 if (quantum_info->format == FloatingPointQuantumFormat)
4219 for (x=0; x < (ssize_t) number_pixels; x++)
4221 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4222 SetPixelRed(image,ClampToQuantum(pixel),q);
4223 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4224 SetPixelGreen(image,ClampToQuantum(pixel),q);
4225 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4226 SetPixelBlue(image,ClampToQuantum(pixel),q);
4227 p+=(ptrdiff_t) quantum_info->pad;
4228 q+=(ptrdiff_t) GetPixelChannels(image);
4237 for (x=0; x < (ssize_t) number_pixels; x++)
4239 p=PushLongPixel(quantum_info->endian,p,&pixel);
4240 SetPixelRed(image,ScaleLongToQuantum(pixel),q);
4241 p=PushLongPixel(quantum_info->endian,p,&pixel);
4242 SetPixelGreen(image,ScaleLongToQuantum(pixel),q);
4243 p=PushLongPixel(quantum_info->endian,p,&pixel);
4244 SetPixelBlue(image,ScaleLongToQuantum(pixel),q);
4245 p+=(ptrdiff_t) quantum_info->pad;
4246 q+=(ptrdiff_t) GetPixelChannels(image);
4253 if (quantum_info->format == FloatingPointQuantumFormat)
4258 for (x=0; x < (ssize_t) number_pixels; x++)
4260 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4261 SetPixelRed(image,ClampToQuantum(pixel),q);
4262 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4263 SetPixelGreen(image,ClampToQuantum(pixel),q);
4264 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4265 SetPixelBlue(image,ClampToQuantum(pixel),q);
4266 p+=(ptrdiff_t) quantum_info->pad;
4267 q+=(ptrdiff_t) GetPixelChannels(image);
4275 if (quantum_info->format == FloatingPointQuantumFormat)
4280 for (x=0; x < (ssize_t) number_pixels; x++)
4282 p=PushDoublePixel(quantum_info,p,&pixel);
4283 SetPixelRed(image,ClampToQuantum(pixel),q);
4284 p=PushDoublePixel(quantum_info,p,&pixel);
4285 SetPixelGreen(image,ClampToQuantum(pixel),q);
4286 p=PushDoublePixel(quantum_info,p,&pixel);
4287 SetPixelBlue(image,ClampToQuantum(pixel),q);
4288 p+=(ptrdiff_t) quantum_info->pad;
4289 q+=(ptrdiff_t) GetPixelChannels(image);
4300 range=GetQuantumRange(quantum_info->depth);
4301 for (x=0; x < (ssize_t) number_pixels; x++)
4303 p=PushQuantumPixel(quantum_info,p,&pixel);
4304 SetPixelRed(image,ScaleAnyToQuantum(pixel,range),q);
4305 p=PushQuantumPixel(quantum_info,p,&pixel);
4306 SetPixelGreen(image,ScaleAnyToQuantum(pixel,range),q);
4307 p=PushQuantumPixel(quantum_info,p,&pixel);
4308 SetPixelBlue(image,ScaleAnyToQuantum(pixel,range),q);
4309 q+=(ptrdiff_t) GetPixelChannels(image);
4317 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
4318 Quantum *magick_restrict q)
4326 assert(image != (
Image *) NULL);
4327 assert(image->signature == MagickCoreSignature);
4328 switch (quantum_info->depth)
4335 for (x=0; x < (ssize_t) number_pixels; x++)
4337 p=PushCharPixel(p,&pixel);
4338 SetPixelRed(image,ScaleCharToQuantum(pixel),q);
4339 p=PushCharPixel(p,&pixel);
4340 SetPixelGreen(image,ScaleCharToQuantum(pixel),q);
4341 p=PushCharPixel(p,&pixel);
4342 SetPixelBlue(image,ScaleCharToQuantum(pixel),q);
4343 p=PushCharPixel(p,&pixel);
4344 SetPixelAlpha(image,ScaleCharToQuantum(pixel),q);
4345 p+=(ptrdiff_t) quantum_info->pad;
4346 q+=(ptrdiff_t) GetPixelChannels(image);
4356 if (quantum_info->pack == MagickFalse)
4369 for (x=0; x < (ssize_t) number_pixels; x++)
4371 for (i=0; i < 4; i++)
4377 p=PushLongPixel(quantum_info->endian,p,&pixel);
4378 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
4379 (((pixel >> 22) & 0x3ff) << 6)));
4384 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
4385 (((pixel >> 12) & 0x3ff) << 6)));
4390 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
4391 (((pixel >> 2) & 0x3ff) << 6)));
4397 case 0: SetPixelRed(image,(Quantum) quantum,q);
break;
4398 case 1: SetPixelGreen(image,(Quantum) quantum,q);
break;
4399 case 2: SetPixelBlue(image,(Quantum) quantum,q);
break;
4400 case 3: SetPixelAlpha(image,(Quantum) quantum,q);
break;
4404 p+=(ptrdiff_t) quantum_info->pad;
4405 q+=(ptrdiff_t) GetPixelChannels(image);
4409 for (x=0; x < (ssize_t) number_pixels; x++)
4411 p=PushQuantumPixel(quantum_info,p,&pixel);
4412 SetPixelRed(image,ScaleShortToQuantum((
unsigned short) (pixel << 6)),q);
4413 p=PushQuantumPixel(quantum_info,p,&pixel);
4414 SetPixelGreen(image,ScaleShortToQuantum((
unsigned short) (pixel << 6)),
4416 p=PushQuantumPixel(quantum_info,p,&pixel);
4417 SetPixelBlue(image,ScaleShortToQuantum((
unsigned short) (pixel << 6)),
4419 p=PushQuantumPixel(quantum_info,p,&pixel);
4420 SetPixelAlpha(image,ScaleShortToQuantum((
unsigned short) (pixel << 6)),
4422 q+=(ptrdiff_t) GetPixelChannels(image);
4431 if (quantum_info->format == FloatingPointQuantumFormat)
4433 for (x=0; x < (ssize_t) number_pixels; x++)
4435 p=PushShortPixel(quantum_info->endian,p,&pixel);
4436 SetPixelRed(image,ClampToQuantum((
double) QuantumRange*(
double)
4437 HalfToSinglePrecision(pixel)),q);
4438 p=PushShortPixel(quantum_info->endian,p,&pixel);
4439 SetPixelGreen(image,ClampToQuantum((
double) QuantumRange*(
double)
4440 HalfToSinglePrecision(pixel)),q);
4441 p=PushShortPixel(quantum_info->endian,p,&pixel);
4442 SetPixelBlue(image,ClampToQuantum((
double) QuantumRange*(
double)
4443 HalfToSinglePrecision(pixel)),q);
4444 p=PushShortPixel(quantum_info->endian,p,&pixel);
4445 SetPixelAlpha(image,ClampToQuantum((
double) QuantumRange*(
double)
4446 HalfToSinglePrecision(pixel)),q);
4447 p+=(ptrdiff_t) quantum_info->pad;
4448 q+=(ptrdiff_t) GetPixelChannels(image);
4452 for (x=0; x < (ssize_t) number_pixels; x++)
4454 p=PushShortPixel(quantum_info->endian,p,&pixel);
4455 SetPixelRed(image,ScaleShortToQuantum(pixel),q);
4456 p=PushShortPixel(quantum_info->endian,p,&pixel);
4457 SetPixelGreen(image,ScaleShortToQuantum(pixel),q);
4458 p=PushShortPixel(quantum_info->endian,p,&pixel);
4459 SetPixelBlue(image,ScaleShortToQuantum(pixel),q);
4460 p=PushShortPixel(quantum_info->endian,p,&pixel);
4461 SetPixelAlpha(image,ScaleShortToQuantum(pixel),q);
4462 p+=(ptrdiff_t) quantum_info->pad;
4463 q+=(ptrdiff_t) GetPixelChannels(image);
4469 if (quantum_info->format == FloatingPointQuantumFormat)
4474 for (x=0; x < (ssize_t) number_pixels; x++)
4476 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4477 SetPixelRed(image,ClampToQuantum(pixel),q);
4478 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4479 SetPixelGreen(image,ClampToQuantum(pixel),q);
4480 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4481 SetPixelBlue(image,ClampToQuantum(pixel),q);
4482 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4483 SetPixelAlpha(image,ClampToQuantum(pixel),q);
4484 p+=(ptrdiff_t) quantum_info->pad;
4485 q+=(ptrdiff_t) GetPixelChannels(image);
4494 for (x=0; x < (ssize_t) number_pixels; x++)
4496 p=PushLongPixel(quantum_info->endian,p,&pixel);
4497 SetPixelRed(image,ScaleLongToQuantum(pixel),q);
4498 p=PushLongPixel(quantum_info->endian,p,&pixel);
4499 SetPixelGreen(image,ScaleLongToQuantum(pixel),q);
4500 p=PushLongPixel(quantum_info->endian,p,&pixel);
4501 SetPixelBlue(image,ScaleLongToQuantum(pixel),q);
4502 p=PushLongPixel(quantum_info->endian,p,&pixel);
4503 SetPixelAlpha(image,ScaleLongToQuantum(pixel),q);
4504 p+=(ptrdiff_t) quantum_info->pad;
4505 q+=(ptrdiff_t) GetPixelChannels(image);
4512 if (quantum_info->format == FloatingPointQuantumFormat)
4517 for (x=0; x < (ssize_t) number_pixels; x++)
4519 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4520 SetPixelRed(image,ClampToQuantum(pixel),q);
4521 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4522 SetPixelGreen(image,ClampToQuantum(pixel),q);
4523 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4524 SetPixelBlue(image,ClampToQuantum(pixel),q);
4525 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4526 SetPixelAlpha(image,ClampToQuantum(pixel),q);
4527 p+=(ptrdiff_t) quantum_info->pad;
4528 q+=(ptrdiff_t) GetPixelChannels(image);
4536 if (quantum_info->format == FloatingPointQuantumFormat)
4541 for (x=0; x < (ssize_t) number_pixels; x++)
4543 p=PushDoublePixel(quantum_info,p,&pixel);
4544 SetPixelRed(image,ClampToQuantum(pixel),q);
4545 p=PushDoublePixel(quantum_info,p,&pixel);
4546 SetPixelGreen(image,ClampToQuantum(pixel),q);
4547 p=PushDoublePixel(quantum_info,p,&pixel);
4548 SetPixelBlue(image,ClampToQuantum(pixel),q);
4549 p=PushDoublePixel(quantum_info,p,&pixel);
4550 SetPixelAlpha(image,ClampToQuantum(pixel),q);
4551 p+=(ptrdiff_t) quantum_info->pad;
4552 q+=(ptrdiff_t) GetPixelChannels(image);
4563 range=GetQuantumRange(quantum_info->depth);
4564 for (x=0; x < (ssize_t) number_pixels; x++)
4566 p=PushQuantumPixel(quantum_info,p,&pixel);
4567 SetPixelRed(image,ScaleAnyToQuantum(pixel,range),q);
4568 p=PushQuantumPixel(quantum_info,p,&pixel);
4569 SetPixelGreen(image,ScaleAnyToQuantum(pixel,range),q);
4570 p=PushQuantumPixel(quantum_info,p,&pixel);
4571 SetPixelBlue(image,ScaleAnyToQuantum(pixel,range),q);
4572 p=PushQuantumPixel(quantum_info,p,&pixel);
4573 SetPixelAlpha(image,ScaleAnyToQuantum(pixel,range),q);
4574 q+=(ptrdiff_t) GetPixelChannels(image);
4582 const MagickSizeType number_pixels,
const unsigned char *magick_restrict p,
4583 Quantum *magick_restrict q)
4591 assert(image != (
Image *) NULL);
4592 assert(image->signature == MagickCoreSignature);
4593 switch (quantum_info->depth)
4600 for (x=0; x < (ssize_t) number_pixels; x++)
4602 p=PushCharPixel(p,&pixel);
4603 SetPixelRed(image,ScaleCharToQuantum(pixel),q);
4604 p=PushCharPixel(p,&pixel);
4605 SetPixelGreen(image,ScaleCharToQuantum(pixel),q);
4606 p=PushCharPixel(p,&pixel);
4607 SetPixelBlue(image,ScaleCharToQuantum(pixel),q);
4608 p=PushCharPixel(p,&pixel);
4609 SetPixelOpacity(image,ScaleCharToQuantum(pixel),q);
4610 p+=(ptrdiff_t) quantum_info->pad;
4611 q+=(ptrdiff_t) GetPixelChannels(image);
4621 if (quantum_info->pack == MagickFalse)
4634 for (x=0; x < (ssize_t) number_pixels; x++)
4636 for (i=0; i < 4; i++)
4642 p=PushLongPixel(quantum_info->endian,p,&pixel);
4643 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
4644 (((pixel >> 22) & 0x3ff) << 6)));
4649 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
4650 (((pixel >> 12) & 0x3ff) << 6)));
4655 quantum=(size_t) (ScaleShortToQuantum((
unsigned short)
4656 (((pixel >> 2) & 0x3ff) << 6)));
4662 case 0: SetPixelRed(image,(Quantum) quantum,q);
break;
4663 case 1: SetPixelGreen(image,(Quantum) quantum,q);
break;
4664 case 2: SetPixelBlue(image,(Quantum) quantum,q);
break;
4665 case 3: SetPixelOpacity(image,(Quantum) quantum,q);
break;
4669 p+=(ptrdiff_t) quantum_info->pad;
4670 q+=(ptrdiff_t) GetPixelChannels(image);
4674 for (x=0; x < (ssize_t) number_pixels; x++)
4676 p=PushQuantumPixel(quantum_info,p,&pixel);
4677 SetPixelRed(image,ScaleShortToQuantum((
unsigned short) (pixel << 6)),q);
4678 p=PushQuantumPixel(quantum_info,p,&pixel);
4679 SetPixelGreen(image,ScaleShortToQuantum((
unsigned short) (pixel << 6)),
4681 p=PushQuantumPixel(quantum_info,p,&pixel);
4682 SetPixelBlue(image,ScaleShortToQuantum((
unsigned short) (pixel << 6)),
4684 p=PushQuantumPixel(quantum_info,p,&pixel);
4685 SetPixelOpacity(image,ScaleShortToQuantum((
unsigned short) (pixel << 6)),
4687 q+=(ptrdiff_t) GetPixelChannels(image);
4696 if (quantum_info->format == FloatingPointQuantumFormat)
4698 for (x=0; x < (ssize_t) number_pixels; x++)
4700 p=PushShortPixel(quantum_info->endian,p,&pixel);
4701 SetPixelRed(image,ClampToQuantum((
double) QuantumRange*(
double)
4702 HalfToSinglePrecision(pixel)),q);
4703 p=PushShortPixel(quantum_info->endian,p,&pixel);
4704 SetPixelGreen(image,ClampToQuantum((
double) QuantumRange*(
double)
4705 HalfToSinglePrecision(pixel)),q);
4706 p=PushShortPixel(quantum_info->endian,p,&pixel);
4707 SetPixelBlue(image,ClampToQuantum((
double) QuantumRange*(
double)
4708 HalfToSinglePrecision(pixel)),q);
4709 p=PushShortPixel(quantum_info->endian,p,&pixel);
4710 SetPixelOpacity(image,ClampToQuantum((
double) QuantumRange*(
double)
4711 HalfToSinglePrecision(pixel)),q);
4712 p+=(ptrdiff_t) quantum_info->pad;
4713 q+=(ptrdiff_t) GetPixelChannels(image);
4717 for (x=0; x < (ssize_t) number_pixels; x++)
4719 p=PushShortPixel(quantum_info->endian,p,&pixel);
4720 SetPixelRed(image,ScaleShortToQuantum(pixel),q);
4721 p=PushShortPixel(quantum_info->endian,p,&pixel);
4722 SetPixelGreen(image,ScaleShortToQuantum(pixel),q);
4723 p=PushShortPixel(quantum_info->endian,p,&pixel);
4724 SetPixelBlue(image,ScaleShortToQuantum(pixel),q);
4725 p=PushShortPixel(quantum_info->endian,p,&pixel);
4726 SetPixelOpacity(image,ScaleShortToQuantum(pixel),q);
4727 p+=(ptrdiff_t) quantum_info->pad;
4728 q+=(ptrdiff_t) GetPixelChannels(image);
4734 if (quantum_info->format == FloatingPointQuantumFormat)
4739 for (x=0; x < (ssize_t) number_pixels; x++)
4741 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4742 SetPixelRed(image,ClampToQuantum(pixel),q);
4743 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4744 SetPixelGreen(image,ClampToQuantum(pixel),q);
4745 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4746 SetPixelBlue(image,ClampToQuantum(pixel),q);
4747 p=PushQuantumFloatPixel(quantum_info,p,&pixel);
4748 SetPixelOpacity(image,ClampToQuantum(pixel),q);
4749 p+=(ptrdiff_t) quantum_info->pad;
4750 q+=(ptrdiff_t) GetPixelChannels(image);
4759 for (x=0; x < (ssize_t) number_pixels; x++)
4761 p=PushLongPixel(quantum_info->endian,p,&pixel);
4762 SetPixelRed(image,ScaleLongToQuantum(pixel),q);
4763 p=PushLongPixel(quantum_info->endian,p,&pixel);
4764 SetPixelGreen(image,ScaleLongToQuantum(pixel),q);
4765 p=PushLongPixel(quantum_info->endian,p,&pixel);
4766 SetPixelBlue(image,ScaleLongToQuantum(pixel),q);
4767 p=PushLongPixel(quantum_info->endian,p,&pixel);
4768 SetPixelOpacity(image,ScaleLongToQuantum(pixel),q);
4769 p+=(ptrdiff_t) quantum_info->pad;
4770 q+=(ptrdiff_t) GetPixelChannels(image);
4777 if (quantum_info->format == FloatingPointQuantumFormat)
4782 for (x=0; x < (ssize_t) number_pixels; x++)
4784 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4785 SetPixelRed(image,ClampToQuantum(pixel),q);
4786 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4787 SetPixelGreen(image,ClampToQuantum(pixel),q);
4788 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4789 SetPixelBlue(image,ClampToQuantum(pixel),q);
4790 p=PushQuantumFloat24Pixel(quantum_info,p,&pixel);
4791 SetPixelOpacity(image,ClampToQuantum(pixel),q);
4792 p+=(ptrdiff_t) quantum_info->pad;
4793 q+=(ptrdiff_t) GetPixelChannels(image);
4801 if (quantum_info->format == FloatingPointQuantumFormat)
4806 for (x=0; x < (ssize_t) number_pixels; x++)
4808 p=PushDoublePixel(quantum_info,p,&pixel);
4809 SetPixelRed(image,ClampToQuantum(pixel),q);
4810 p=PushDoublePixel(quantum_info,p,&pixel);
4811 SetPixelGreen(image,ClampToQuantum(pixel),q);
4812 p=PushDoublePixel(quantum_info,p,&pixel);
4813 SetPixelBlue(image,ClampToQuantum(pixel),q);
4814 p=PushDoublePixel(quantum_info,p,&pixel);
4815 SetPixelOpacity(image,ClampToQuantum(pixel),q);
4816 p+=(ptrdiff_t) quantum_info->pad;
4817 q+=(ptrdiff_t) GetPixelChannels(image);
4828 range=GetQuantumRange(quantum_info->depth);
4829 for (x=0; x < (ssize_t) number_pixels; x++)
4831 p=PushQuantumPixel(quantum_info,p,&pixel);
4832 SetPixelRed(image,ScaleAnyToQuantum(pixel,range),q);
4833 p=PushQuantumPixel(quantum_info,p,&pixel);
4834 SetPixelGreen(image,ScaleAnyToQuantum(pixel,range),q);
4835 p=PushQuantumPixel(quantum_info,p,&pixel);
4836 SetPixelBlue(image,ScaleAnyToQuantum(pixel,range),q);
4837 p=PushQuantumPixel(quantum_info,p,&pixel);
4838 SetPixelOpacity(image,ScaleAnyToQuantum(pixel,range),q);
4839 q+=(ptrdiff_t) GetPixelChannels(image);
4846MagickExport
size_t ImportQuantumPixels(
const Image *image,
4848 const QuantumType quantum_type,
const unsigned char *magick_restrict pixels,
4866 assert(image != (
Image *) NULL);
4867 assert(image->signature == MagickCoreSignature);
4869 assert(quantum_info->signature == MagickCoreSignature);
4870 if (IsEventLogging() != MagickFalse)
4871 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
4872 if (pixels == (
const unsigned char *) NULL)
4873 pixels=(
const unsigned char *) GetQuantumPixels(quantum_info);
4878 number_pixels=GetImageExtent(image);
4879 q=GetAuthenticPixelQueue(image);
4883 number_pixels=GetCacheViewExtent(image_view);
4884 q=GetCacheViewAuthenticPixelQueue(image_view);
4886 ResetQuantumState(quantum_info);
4887 extent=GetQuantumExtent(image,quantum_info,quantum_type);
4888 switch (quantum_type)
4892 ImportAlphaQuantum(image,quantum_info,number_pixels,p,q);
4897 ImportBGRQuantum(image,quantum_info,number_pixels,p,q);
4902 ImportBGRAQuantum(image,quantum_info,number_pixels,p,q);
4907 ImportBGROQuantum(image,quantum_info,number_pixels,p,q);
4912 ImportBlackQuantum(image,quantum_info,number_pixels,p,q,exception);
4918 ImportBlueQuantum(image,quantum_info,number_pixels,p,q);
4923 ImportCMYKQuantum(image,quantum_info,number_pixels,p,q,exception);
4928 ImportCMYKAQuantum(image,quantum_info,number_pixels,p,q,exception);
4931 case MultispectralQuantum:
4933 ImportMultispectralQuantum(image,quantum_info,number_pixels,p,q,exception);
4938 ImportCMYKOQuantum(image,quantum_info,number_pixels,p,q,exception);
4943 ImportCbYCrYQuantum(image,quantum_info,number_pixels,p,q);
4948 ImportGrayQuantum(image,quantum_info,number_pixels,p,q);
4951 case GrayAlphaQuantum:
4953 ImportGrayAlphaQuantum(image,quantum_info,number_pixels,p,q);
4957 case MagentaQuantum:
4959 ImportGreenQuantum(image,quantum_info,number_pixels,p,q);
4964 ImportIndexQuantum(image,quantum_info,number_pixels,p,q,exception);
4967 case IndexAlphaQuantum:
4969 ImportIndexAlphaQuantum(image,quantum_info,number_pixels,p,q,exception);
4972 case OpacityQuantum:
4974 ImportOpacityQuantum(image,quantum_info,number_pixels,p,q);
4980 ImportRedQuantum(image,quantum_info,number_pixels,p,q);
4986 ImportRGBQuantum(image,quantum_info,number_pixels,p,q);
4992 ImportRGBAQuantum(image,quantum_info,number_pixels,p,q);
4997 ImportRGBOQuantum(image,quantum_info,number_pixels,p,q);
5003 if ((quantum_type == CbYCrQuantum) || (quantum_type == CbYCrAQuantum))
5008 q=GetAuthenticPixelQueue(image);
5010 q=GetCacheViewAuthenticPixelQueue(image_view);
5011 for (x=0; x < (ssize_t) number_pixels; x++)
5013 quantum=GetPixelRed(image,q);
5014 SetPixelRed(image,GetPixelGreen(image,q),q);
5015 SetPixelGreen(image,quantum,q);
5016 q+=(ptrdiff_t) GetPixelChannels(image);
5019 if (quantum_info->alpha_type == AssociatedQuantumAlpha)
5028 q=GetAuthenticPixelQueue(image);
5030 q=GetCacheViewAuthenticPixelQueue(image_view);
5031 for (x=0; x < (ssize_t) number_pixels; x++)
5036 Sa=QuantumScale*(double) GetPixelAlpha(image,q);
5037 gamma=PerceptibleReciprocal(Sa);
5038 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
5040 PixelChannel channel = GetPixelChannelChannel(image,i);
5041 PixelTrait traits = GetPixelChannelTraits(image,channel);
5042 if ((channel == AlphaPixelChannel) ||
5043 ((traits & UpdatePixelTrait) == 0))
5045 q[i]=ClampToQuantum(gamma*(
double) q[i]);
5047 q+=(ptrdiff_t) GetPixelChannels(image);