2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % QQQ U U AAA N N TTTTT U U M M %
7 % Q Q U U A A NN N T U U MM MM %
8 % Q Q U U AAAAA N N N T U U M M M %
9 % Q QQ U U A A N NN T U U M M %
10 % QQQQ UUU A A N N T UUU M M %
12 % IIIII M M PPPP OOO RRRR TTTTT %
13 % I MM MM P P O O R R T %
14 % I M M M PPPP O O RRRR T %
16 % IIIII M M P OOO R R T %
18 % MagickCore Methods to Import Quantum Pixels %
25 % Copyright 1999-2008 ImageMagick Studio LLC, a non-profit organization %
26 % dedicated to making software imaging solutions freely available. %
28 % You may not use this file except in compliance with the License. You may %
29 % obtain a copy of the License at %
31 % http://www.imagemagick.org/script/license.php %
33 % Unless required by applicable law or agreed to in writing, software %
34 % distributed under the License is distributed on an "AS IS" BASIS, %
35 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
36 % See the License for the specific language governing permissions and %
37 % limitations under the License. %
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47 #include "magick/studio.h"
48 #include "magick/property.h"
49 #include "magick/blob.h"
50 #include "magick/blob-private.h"
51 #include "magick/color-private.h"
52 #include "magick/exception.h"
53 #include "magick/exception-private.h"
54 #include "magick/cache.h"
55 #include "magick/constitute.h"
56 #include "magick/delegate.h"
57 #include "magick/geometry.h"
58 #include "magick/list.h"
59 #include "magick/magick.h"
60 #include "magick/memory_.h"
61 #include "magick/monitor.h"
62 #include "magick/option.h"
63 #include "magick/pixel.h"
64 #include "magick/pixel-private.h"
65 #include "magick/quantum.h"
66 #include "magick/quantum-private.h"
67 #include "magick/resource_.h"
68 #include "magick/semaphore.h"
69 #include "magick/statistic.h"
70 #include "magick/stream.h"
71 #include "magick/string_.h"
72 #include "magick/utility.h"
75 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
79 % I m p o r t Q u a n t u m P i x e l s %
83 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
85 % ImportQuantumPixels() transfers one or more pixel components from a user
86 % supplied buffer into the image pixel cache of an image. The pixels are
87 % expected in network byte order. It returns MagickTrue if the pixels are
88 % successfully transferred, otherwise MagickFalse.
90 % The format of the ImportQuantumPixels method is:
92 % size_t ImportQuantumPixels(Image *image,CacheView *image_view,
93 % const QuantumInfo *quantum_info,const QuantumType quantum_type,
94 % const unsigned char *pixels,ExceptionInfo *exception)
96 % A description of each parameter follows:
100 % o image_view: the image cache view.
102 % o quantum_info: the quantum info.
104 % o quantum_type: Declare which pixel components to transfer (red, green,
105 % blue, opacity, RGB, or RGBA).
107 % o pixels: The pixel components are transferred from this buffer.
109 % o exception: return any errors or warnings in this structure.
113 static inline IndexPacket PushColormapIndex(Image *image,
114 const size_t index,MagickBooleanType *range_exception)
116 if (index < image->colors)
117 return((IndexPacket) index);
118 *range_exception=MagickTrue;
119 return((IndexPacket) 0);
122 static inline const unsigned char *PushDoublePixel(
123 const QuantumState *quantum_state,const unsigned char *pixels,double *pixel)
131 if (quantum_state->endian != LSBEndian)
133 quantum[7]=(*pixels++);
134 quantum[6]=(*pixels++);
135 quantum[5]=(*pixels++);
136 quantum[5]=(*pixels++);
137 quantum[3]=(*pixels++);
138 quantum[2]=(*pixels++);
139 quantum[1]=(*pixels++);
140 quantum[0]=(*pixels++);
141 p=(double *) quantum;
143 *pixel-=quantum_state->minimum;
144 *pixel*=quantum_state->scale;
147 quantum[0]=(*pixels++);
148 quantum[1]=(*pixels++);
149 quantum[2]=(*pixels++);
150 quantum[3]=(*pixels++);
151 quantum[4]=(*pixels++);
152 quantum[5]=(*pixels++);
153 quantum[6]=(*pixels++);
154 quantum[7]=(*pixels++);
155 p=(double *) quantum;
157 *pixel-=quantum_state->minimum;
158 *pixel*=quantum_state->scale;
162 static inline const unsigned char *PushFloatPixel(
163 const QuantumState *quantum_state,const unsigned char *pixels,float *pixel)
171 if (quantum_state->endian != LSBEndian)
173 quantum[3]=(*pixels++);
174 quantum[2]=(*pixels++);
175 quantum[1]=(*pixels++);
176 quantum[0]=(*pixels++);
179 *pixel-=quantum_state->minimum;
180 *pixel*=quantum_state->scale;
183 quantum[0]=(*pixels++);
184 quantum[1]=(*pixels++);
185 quantum[2]=(*pixels++);
186 quantum[3]=(*pixels++);
189 *pixel-=quantum_state->minimum;
190 *pixel*=quantum_state->scale;
194 static inline const unsigned char *PushQuantumPixel(
195 QuantumState *quantum_state,const size_t depth,
196 const unsigned char *pixels,unsigned int *quantum)
204 *quantum=(QuantumAny) 0;
205 for (i=(ssize_t) depth; i > 0L; )
207 if (quantum_state->bits == 0UL)
209 quantum_state->pixel=(*pixels++);
210 quantum_state->bits=8UL;
212 quantum_bits=(size_t) i;
213 if (quantum_bits > quantum_state->bits)
214 quantum_bits=quantum_state->bits;
215 i-=(ssize_t) quantum_bits;
216 quantum_state->bits-=quantum_bits;
217 *quantum=(unsigned int) ((*quantum << quantum_bits) |
218 ((quantum_state->pixel >> quantum_state->bits) &~ ((~0UL) <<
224 static inline const unsigned char *PushQuantumLongPixel(
225 QuantumState *quantum_state,const size_t depth,
226 const unsigned char *pixels,unsigned int *quantum)
235 for (i=(ssize_t) depth; i > 0; )
237 if (quantum_state->bits == 0)
239 pixels=PushLongPixel(quantum_state->endian,pixels,
240 &quantum_state->pixel);
241 quantum_state->bits=32U;
243 quantum_bits=(size_t) i;
244 if (quantum_bits > quantum_state->bits)
245 quantum_bits=quantum_state->bits;
246 *quantum|=(((quantum_state->pixel >> (32U-quantum_state->bits)) &
247 quantum_state->mask[quantum_bits]) << (depth-i));
248 i-=(ssize_t) quantum_bits;
249 quantum_state->bits-=quantum_bits;
254 MagickExport size_t ImportQuantumPixels(Image *image,CacheView *image_view,
255 const QuantumInfo *quantum_info,const QuantumType quantum_type,
256 const unsigned char *pixels,ExceptionInfo *exception)
270 register const unsigned char
291 assert(image != (Image *) NULL);
292 assert(image->signature == MagickSignature);
293 if (image->debug != MagickFalse)
294 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
295 assert(quantum_info != (QuantumInfo *) NULL);
296 assert(quantum_info->signature == MagickSignature);
297 if (pixels == (const unsigned char *) NULL)
298 pixels=GetQuantumPixels(quantum_info);
301 if (image_view == (CacheView *) NULL)
303 number_pixels=GetImageExtent(image);
304 q=GetAuthenticPixelQueue(image);
305 indexes=GetAuthenticIndexQueue(image);
309 number_pixels=GetCacheViewExtent(image_view);
310 q=GetCacheViewAuthenticPixelQueue(image_view);
311 indexes=GetCacheViewAuthenticIndexQueue(image_view);
313 InitializeQuantumState(quantum_info,image->endian,&quantum_state);
314 extent=GetQuantumExtent(image,quantum_info,quantum_type);
315 endian=quantum_state.endian;
316 switch (quantum_type)
323 if (image->storage_class != PseudoClass)
325 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
326 "ColormappedImageRequired","`%s'",image->filename);
329 range_exception=MagickFalse;
330 switch (quantum_info->depth)
334 register unsigned char
337 for (x=0; x < ((ssize_t) number_pixels-7); x+=8)
339 for (bit=0; bit < 8; bit++)
341 if (quantum_info->min_is_white == MagickFalse)
342 pixel=(unsigned char) (((*p) & (1 << (7-bit))) == 0 ?
345 pixel=(unsigned char) (((*p) & (1 << (7-bit))) != 0 ?
347 indexes[x+bit]=PushColormapIndex(image,pixel,&range_exception);
348 *q=image->colormap[(ssize_t) indexes[x+bit]];
353 for (bit=0; bit < (ssize_t) (number_pixels % 8); bit++)
355 if (quantum_info->min_is_white == MagickFalse)
356 pixel=(unsigned char) (((*p) & (1 << (7-bit))) == 0 ?
359 pixel=(unsigned char) (((*p) & (1 << (7-bit))) != 0 ?
361 indexes[x+bit]=PushColormapIndex(image,pixel,&range_exception);
362 *q=image->colormap[(ssize_t) indexes[x+bit]];
369 register unsigned char
372 for (x=0; x < ((ssize_t) number_pixels-1); x+=2)
374 pixel=(unsigned char) ((*p >> 4) & 0xf);
375 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
376 *q=image->colormap[(ssize_t) indexes[x]];
378 pixel=(unsigned char) ((*p) & 0xf);
379 indexes[x+1]=PushColormapIndex(image,pixel,&range_exception);
380 *q=image->colormap[(ssize_t) indexes[x+1]];
384 for (bit=0; bit < (ssize_t) (number_pixels % 2); bit++)
386 pixel=(unsigned char) ((*p++ >> 4) & 0xf);
387 indexes[x+bit]=PushColormapIndex(image,pixel,&range_exception);
388 *q=image->colormap[(ssize_t) indexes[x+bit]];
398 for (x=0; x < (ssize_t) number_pixels; x++)
400 p=PushCharPixel(p,&pixel);
401 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
402 *q=image->colormap[(ssize_t) indexes[x]];
403 p+=quantum_info->pad;
413 if (quantum_info->format == FloatingPointQuantumFormat)
415 for (x=0; x < (ssize_t) number_pixels; x++)
417 p=PushShortPixel(endian,p,&pixel);
418 indexes[x]=PushColormapIndex(image,ClampToQuantum(
419 (MagickRealType) QuantumRange*HalfToSinglePrecision(pixel)),
421 *q=image->colormap[(ssize_t) indexes[x]];
422 p+=quantum_info->pad;
427 for (x=0; x < (ssize_t) number_pixels; x++)
429 p=PushShortPixel(endian,p,&pixel);
430 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
431 *q=image->colormap[(ssize_t) indexes[x]];
432 p+=quantum_info->pad;
442 if (quantum_info->format == FloatingPointQuantumFormat)
447 for (x=0; x < (ssize_t) number_pixels; x++)
449 p=PushFloatPixel(&quantum_state,p,&pixel);
450 indexes[x]=PushColormapIndex(image,ClampToQuantum(pixel),
452 *q=image->colormap[(ssize_t) indexes[x]];
453 p+=quantum_info->pad;
458 for (x=0; x < (ssize_t) number_pixels; x++)
460 p=PushLongPixel(endian,p,&pixel);
461 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
462 *q=image->colormap[(ssize_t) indexes[x]];
463 p+=quantum_info->pad;
470 if (quantum_info->format == FloatingPointQuantumFormat)
475 for (x=0; x < (ssize_t) number_pixels; x++)
477 p=PushDoublePixel(&quantum_state,p,&pixel);
478 indexes[x]=PushColormapIndex(image,ClampToQuantum(pixel),
480 *q=image->colormap[(ssize_t) indexes[x]];
481 p+=quantum_info->pad;
489 for (x=0; x < (ssize_t) number_pixels; x++)
491 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
492 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
493 *q=image->colormap[(ssize_t) indexes[x]];
494 p+=quantum_info->pad;
500 if (range_exception != MagickFalse)
501 (void) ThrowMagickException(exception,GetMagickModule(),
502 CorruptImageError,"InvalidColormapIndex","`%s'",image->filename);
505 case IndexAlphaQuantum:
510 if (image->storage_class != PseudoClass)
512 (void) ThrowMagickException(exception,GetMagickModule(),
513 ImageError,"ColormappedImageRequired","`%s'",image->filename);
516 range_exception=MagickFalse;
517 switch (quantum_info->depth)
521 register unsigned char
524 for (x=0; x < ((ssize_t) number_pixels-3); x+=4)
526 for (bit=0; bit < 8; bit+=2)
528 if (quantum_info->min_is_white == MagickFalse)
529 pixel=(unsigned char) (((*p) & (1 << (7-bit))) == 0 ?
532 pixel=(unsigned char) (((*p) & (1 << (7-bit))) != 0 ?
534 indexes[x+bit/2]=(IndexPacket) (pixel == 0 ? 0 : 1);
535 q->red=(Quantum) (pixel == 0 ? 0 : QuantumRange);
538 q->opacity=(Quantum) (((*p) & (1UL << (unsigned char) (6-bit)))
539 == 0 ? TransparentOpacity : OpaqueOpacity);
543 for (bit=0; bit < (ssize_t) (number_pixels % 4); bit+=2)
545 if (quantum_info->min_is_white == MagickFalse)
546 pixel=(unsigned char) (((*p) & (1 << (7-bit))) == 0 ?
549 pixel=(unsigned char) (((*p) & (1 << (7-bit))) != 0 ?
551 indexes[x+bit/2]=(IndexPacket) (pixel == 0 ? 0 : 1);
552 q->red=(Quantum) (pixel == 0 ? 0 : QuantumRange);
555 q->opacity=(Quantum) (((*p) & (1UL << (unsigned char) (6-bit))) ==
556 0 ? TransparentOpacity : OpaqueOpacity);
563 register unsigned char
566 range=GetQuantumRange(image->depth);
567 for (x=0; x < (ssize_t) number_pixels; x++)
569 pixel=(unsigned char) ((*p >> 4) & 0xf);
570 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
571 *q=image->colormap[(ssize_t) indexes[x]];
572 pixel=(unsigned char) ((*p) & 0xf);
573 q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range));
584 for (x=0; x < (ssize_t) number_pixels; x++)
586 p=PushCharPixel(p,&pixel);
587 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
588 *q=image->colormap[(ssize_t) indexes[x]];
589 p=PushCharPixel(p,&pixel);
590 q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel));
591 p+=quantum_info->pad;
601 if (quantum_info->format == FloatingPointQuantumFormat)
603 for (x=0; x < (ssize_t) number_pixels; x++)
605 p=PushShortPixel(endian,p,&pixel);
606 indexes[x]=PushColormapIndex(image,ClampToQuantum(
607 (MagickRealType) QuantumRange*HalfToSinglePrecision(pixel)),
609 *q=image->colormap[(ssize_t) indexes[x]];
610 p=PushShortPixel(endian,p,&pixel);
611 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(
612 (MagickRealType) QuantumRange*HalfToSinglePrecision(pixel)));
613 p+=quantum_info->pad;
618 for (x=0; x < (ssize_t) number_pixels; x++)
620 p=PushShortPixel(endian,p,&pixel);
621 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
622 *q=image->colormap[(ssize_t) indexes[x]];
623 p=PushShortPixel(endian,p,&pixel);
624 q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel));
625 p+=quantum_info->pad;
635 if (quantum_info->format == FloatingPointQuantumFormat)
640 for (x=0; x < (ssize_t) number_pixels; x++)
642 p=PushFloatPixel(&quantum_state,p,&pixel);
643 indexes[x]=PushColormapIndex(image,ClampToQuantum(pixel),
645 *q=image->colormap[(ssize_t) indexes[x]];
646 p=PushFloatPixel(&quantum_state,p,&pixel);
647 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel));
648 p+=quantum_info->pad;
653 for (x=0; x < (ssize_t) number_pixels; x++)
655 p=PushLongPixel(endian,p,&pixel);
656 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
657 *q=image->colormap[(ssize_t) indexes[x]];
658 p=PushLongPixel(endian,p,&pixel);
659 q->opacity=(Quantum) (QuantumRange-ScaleLongToQuantum(pixel));
660 p+=quantum_info->pad;
667 if (quantum_info->format == FloatingPointQuantumFormat)
672 for (x=0; x < (ssize_t) number_pixels; x++)
674 p=PushDoublePixel(&quantum_state,p,&pixel);
675 indexes[x]=PushColormapIndex(image,ClampToQuantum(pixel),
677 *q=image->colormap[(ssize_t) indexes[x]];
678 p=PushDoublePixel(&quantum_state,p,&pixel);
679 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel));
680 p+=quantum_info->pad;
688 range=GetQuantumRange(image->depth);
689 for (x=0; x < (ssize_t) number_pixels; x++)
691 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
692 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
693 *q=image->colormap[(ssize_t) indexes[x]];
694 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
695 q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range));
696 p+=quantum_info->pad;
702 if (range_exception != MagickFalse)
703 (void) ThrowMagickException(exception,GetMagickModule(),
704 CorruptImageError,"InvalidColormapIndex","`%s'",image->filename);
709 switch (quantum_info->depth)
716 for (x=0; x < (ssize_t) number_pixels; x++)
718 p=PushCharPixel(p,&pixel);
719 SetBluePixelComponent(q,ScaleCharToQuantum(pixel));
720 p=PushCharPixel(p,&pixel);
721 SetGreenPixelComponent(q,ScaleCharToQuantum(pixel));
722 p=PushCharPixel(p,&pixel);
723 SetRedPixelComponent(q,ScaleCharToQuantum(pixel));
724 SetOpacityPixelComponent(q,OpaqueOpacity);
725 p+=quantum_info->pad;
732 range=GetQuantumRange(image->depth);
733 if (quantum_info->pack == MagickFalse)
735 for (x=0; x < (ssize_t) number_pixels; x++)
737 p=PushLongPixel(endian,p,&pixel);
738 q->red=ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range);
739 q->green=ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range);
740 q->blue=ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range);
741 p+=quantum_info->pad;
746 if (quantum_info->quantum == 32U)
748 for (x=0; x < (ssize_t) number_pixels; x++)
750 p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel);
751 SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range));
752 p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel);
753 SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
754 p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel);
755 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
760 for (x=0; x < (ssize_t) number_pixels; x++)
762 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
763 SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range));
764 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
765 SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
766 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
767 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
774 range=GetQuantumRange(image->depth);
775 if (quantum_info->pack == MagickFalse)
780 for (x=0; x < (ssize_t) (3*number_pixels-1); x+=2)
782 p=PushShortPixel(endian,p,&pixel);
788 q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
793 q->green=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
798 q->blue=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
803 p=PushShortPixel(endian,p,&pixel);
809 q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
814 q->green=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
819 q->blue=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
824 p+=quantum_info->pad;
826 for (bit=0; bit < (ssize_t) (3*number_pixels % 2); bit++)
828 p=PushShortPixel(endian,p,&pixel);
834 q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
839 q->green=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
844 q->blue=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
849 p+=quantum_info->pad;
855 if (quantum_info->quantum == 32U)
857 for (x=0; x < (ssize_t) number_pixels; x++)
859 p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel);
860 SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range));
861 p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel);
862 SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
863 p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel);
864 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
869 for (x=0; x < (ssize_t) number_pixels; x++)
871 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
872 SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range));
873 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
874 SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
875 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
876 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
886 if (quantum_info->format == FloatingPointQuantumFormat)
888 for (x=0; x < (ssize_t) number_pixels; x++)
890 p=PushShortPixel(endian,p,&pixel);
891 q->red=ClampToQuantum((MagickRealType) QuantumRange*
892 HalfToSinglePrecision(pixel));
893 p=PushShortPixel(endian,p,&pixel);
894 q->green=ClampToQuantum((MagickRealType) QuantumRange*
895 HalfToSinglePrecision(pixel));
896 p=PushShortPixel(endian,p,&pixel);
897 q->blue=ClampToQuantum((MagickRealType) QuantumRange*
898 HalfToSinglePrecision(pixel));
899 p+=quantum_info->pad;
904 for (x=0; x < (ssize_t) number_pixels; x++)
906 p=PushShortPixel(endian,p,&pixel);
907 SetBluePixelComponent(q,ScaleShortToQuantum(pixel));
908 p=PushShortPixel(endian,p,&pixel);
909 SetGreenPixelComponent(q,ScaleShortToQuantum(pixel));
910 p=PushShortPixel(endian,p,&pixel);
911 SetRedPixelComponent(q,ScaleShortToQuantum(pixel));
912 p+=quantum_info->pad;
922 if (quantum_info->format == FloatingPointQuantumFormat)
927 for (x=0; x < (ssize_t) number_pixels; x++)
929 p=PushFloatPixel(&quantum_state,p,&pixel);
930 q->red=ClampToQuantum(pixel);
931 p=PushFloatPixel(&quantum_state,p,&pixel);
932 q->green=ClampToQuantum(pixel);
933 p=PushFloatPixel(&quantum_state,p,&pixel);
934 q->blue=ClampToQuantum(pixel);
935 p+=quantum_info->pad;
940 for (x=0; x < (ssize_t) number_pixels; x++)
942 p=PushLongPixel(endian,p,&pixel);
943 SetBluePixelComponent(q,ScaleLongToQuantum(pixel));
944 p=PushLongPixel(endian,p,&pixel);
945 SetGreenPixelComponent(q,ScaleLongToQuantum(pixel));
946 p=PushLongPixel(endian,p,&pixel);
947 SetRedPixelComponent(q,ScaleLongToQuantum(pixel));
948 p+=quantum_info->pad;
955 if (quantum_info->format == FloatingPointQuantumFormat)
960 for (x=0; x < (ssize_t) number_pixels; x++)
962 p=PushDoublePixel(&quantum_state,p,&pixel);
963 q->red=ClampToQuantum(pixel);
964 p=PushDoublePixel(&quantum_state,p,&pixel);
965 q->green=ClampToQuantum(pixel);
966 p=PushDoublePixel(&quantum_state,p,&pixel);
967 q->blue=ClampToQuantum(pixel);
968 p+=quantum_info->pad;
976 range=GetQuantumRange(image->depth);
977 for (x=0; x < (ssize_t) number_pixels; x++)
979 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
980 SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range));
981 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
982 SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
983 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
984 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
995 switch (quantum_info->depth)
1002 for (x=0; x < (ssize_t) number_pixels; x++)
1004 p=PushCharPixel(p,&pixel);
1005 SetBluePixelComponent(q,ScaleCharToQuantum(pixel));
1006 p=PushCharPixel(p,&pixel);
1007 SetGreenPixelComponent(q,ScaleCharToQuantum(pixel));
1008 p=PushCharPixel(p,&pixel);
1009 SetRedPixelComponent(q,ScaleCharToQuantum(pixel));
1010 p=PushCharPixel(p,&pixel);
1011 q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel));
1012 p+=quantum_info->pad;
1020 if (quantum_info->pack == MagickFalse)
1033 for (x=0; x < (ssize_t) number_pixels; x++)
1035 for (i=0; i < 4; i++)
1041 p=PushLongPixel(endian,p,&pixel);
1042 quantum=(size_t) (ScaleShortToQuantum(
1043 (unsigned short) (((pixel >> 22) & 0x3ff) << 6)));
1048 quantum=(size_t) (ScaleShortToQuantum(
1049 (unsigned short) (((pixel >> 12) & 0x3ff) << 6)));
1054 quantum=(size_t) (ScaleShortToQuantum(
1055 (unsigned short) (((pixel >> 2) & 0x3ff) << 6)));
1061 case 0: q->red=(Quantum) (quantum); break;
1062 case 1: q->green=(Quantum) (quantum); break;
1063 case 2: q->blue=(Quantum) (quantum); break;
1064 case 3: q->opacity=(Quantum) (QuantumRange-quantum); break;
1068 p+=quantum_info->pad;
1073 for (x=0; x < (ssize_t) number_pixels; x++)
1075 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1076 q->red=ScaleShortToQuantum((unsigned short) (pixel << 6));
1077 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1078 q->green=ScaleShortToQuantum((unsigned short) (pixel << 6));
1079 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1080 q->blue=ScaleShortToQuantum((unsigned short) (pixel << 6));
1081 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1082 q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(
1083 (unsigned short) (pixel << 6)));
1093 if (quantum_info->format == FloatingPointQuantumFormat)
1095 for (x=0; x < (ssize_t) number_pixels; x++)
1097 p=PushShortPixel(endian,p,&pixel);
1098 q->red=ClampToQuantum((MagickRealType) QuantumRange*
1099 HalfToSinglePrecision(pixel));
1100 p=PushShortPixel(endian,p,&pixel);
1101 q->green=ClampToQuantum((MagickRealType) QuantumRange*
1102 HalfToSinglePrecision(pixel));
1103 p=PushShortPixel(endian,p,&pixel);
1104 q->blue=ClampToQuantum((MagickRealType) QuantumRange*
1105 HalfToSinglePrecision(pixel));
1106 p=PushShortPixel(endian,p,&pixel);
1107 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(
1108 (MagickRealType) QuantumRange*HalfToSinglePrecision(pixel)));
1109 p+=quantum_info->pad;
1114 for (x=0; x < (ssize_t) number_pixels; x++)
1116 p=PushShortPixel(endian,p,&pixel);
1117 SetBluePixelComponent(q,ScaleShortToQuantum(pixel));
1118 p=PushShortPixel(endian,p,&pixel);
1119 SetGreenPixelComponent(q,ScaleShortToQuantum(pixel));
1120 p=PushShortPixel(endian,p,&pixel);
1121 SetRedPixelComponent(q,ScaleShortToQuantum(pixel));
1122 p=PushShortPixel(endian,p,&pixel);
1123 q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel));
1124 p+=quantum_info->pad;
1134 if (quantum_info->format == FloatingPointQuantumFormat)
1139 for (x=0; x < (ssize_t) number_pixels; x++)
1141 p=PushFloatPixel(&quantum_state,p,&pixel);
1142 q->red=ClampToQuantum(pixel);
1143 p=PushFloatPixel(&quantum_state,p,&pixel);
1144 q->green=ClampToQuantum(pixel);
1145 p=PushFloatPixel(&quantum_state,p,&pixel);
1146 q->blue=ClampToQuantum(pixel);
1147 p=PushFloatPixel(&quantum_state,p,&pixel);
1148 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel));
1149 p+=quantum_info->pad;
1154 for (x=0; x < (ssize_t) number_pixels; x++)
1156 p=PushLongPixel(endian,p,&pixel);
1157 SetBluePixelComponent(q,ScaleLongToQuantum(pixel));
1158 p=PushLongPixel(endian,p,&pixel);
1159 SetGreenPixelComponent(q,ScaleLongToQuantum(pixel));
1160 p=PushLongPixel(endian,p,&pixel);
1161 SetRedPixelComponent(q,ScaleLongToQuantum(pixel));
1162 p=PushLongPixel(endian,p,&pixel);
1163 q->opacity=(Quantum) (QuantumRange-ScaleLongToQuantum(pixel));
1164 p+=quantum_info->pad;
1171 if (quantum_info->format == FloatingPointQuantumFormat)
1176 for (x=0; x < (ssize_t) number_pixels; x++)
1178 p=PushDoublePixel(&quantum_state,p,&pixel);
1179 q->red=ClampToQuantum(pixel);
1180 p=PushDoublePixel(&quantum_state,p,&pixel);
1181 q->green=ClampToQuantum(pixel);
1182 p=PushDoublePixel(&quantum_state,p,&pixel);
1183 q->blue=ClampToQuantum(pixel);
1184 p=PushDoublePixel(&quantum_state,p,&pixel);
1185 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel));
1186 p+=quantum_info->pad;
1194 range=GetQuantumRange(image->depth);
1195 for (x=0; x < (ssize_t) number_pixels; x++)
1197 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1198 SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range));
1199 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1200 SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1201 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1202 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1203 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1204 q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range));
1214 switch (quantum_info->depth)
1223 white=(Quantum) QuantumRange;
1224 if (quantum_info->min_is_white != MagickFalse)
1226 black=(Quantum) QuantumRange;
1229 for (x=0; x < ((ssize_t) number_pixels-7); x+=8)
1231 for (bit=0; bit < 8; bit++)
1233 q->red=(((*p) & (1 << (7-bit))) == 0 ? black : white);
1240 for (bit=0; bit < (ssize_t) (number_pixels % 8); bit++)
1242 q->red=(((*p) & (0x01 << (7-bit))) == 0 ? black : white);
1253 register unsigned char
1256 range=GetQuantumRange(image->depth);
1257 for (x=0; x < ((ssize_t) number_pixels-1); x+=2)
1259 pixel=(unsigned char) ((*p >> 4) & 0xf);
1260 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1264 pixel=(unsigned char) ((*p) & 0xf);
1265 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1271 for (bit=0; bit < (ssize_t) (number_pixels % 2); bit++)
1273 pixel=(unsigned char) (*p++ >> 4);
1274 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1286 if (quantum_info->min_is_white != MagickFalse)
1288 for (x=0; x < (ssize_t) number_pixels; x++)
1290 p=PushCharPixel(p,&pixel);
1291 q->red=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel));
1294 SetOpacityPixelComponent(q,OpaqueOpacity);
1295 p+=quantum_info->pad;
1300 for (x=0; x < (ssize_t) number_pixels; x++)
1302 p=PushCharPixel(p,&pixel);
1303 SetRedPixelComponent(q,ScaleCharToQuantum(pixel));
1306 SetOpacityPixelComponent(q,OpaqueOpacity);
1307 p+=quantum_info->pad;
1314 range=GetQuantumRange(image->depth);
1315 if (quantum_info->pack == MagickFalse)
1317 if (image->endian != LSBEndian)
1319 for (x=0; x < (ssize_t) (number_pixels-2); x+=3)
1321 p=PushLongPixel(endian,p,&pixel);
1322 q->red=ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range);
1326 q->red=ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range);
1330 q->red=ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range);
1333 p+=quantum_info->pad;
1336 p=PushLongPixel(endian,p,&pixel);
1337 if (x++ < (ssize_t) (number_pixels-1))
1339 q->red=ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range);
1344 if (x++ < (ssize_t) number_pixels)
1346 q->red=ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range);
1353 for (x=0; x < (ssize_t) (number_pixels-2); x+=3)
1355 p=PushLongPixel(endian,p,&pixel);
1356 q->red=ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range);
1360 q->red=ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range);
1364 q->red=ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range);
1367 p+=quantum_info->pad;
1370 p=PushLongPixel(endian,p,&pixel);
1371 if (x++ < (ssize_t) (number_pixels-1))
1373 q->red=ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range);
1378 if (x++ < (ssize_t) number_pixels)
1380 q->red=ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range);
1387 for (x=0; x < (ssize_t) number_pixels; x++)
1389 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1390 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1393 p+=quantum_info->pad;
1400 range=GetQuantumRange(image->depth);
1401 if (quantum_info->pack == MagickFalse)
1406 for (x=0; x < (ssize_t) (number_pixels-1); x+=2)
1408 p=PushShortPixel(endian,p,&pixel);
1409 q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
1413 p=PushShortPixel(endian,p,&pixel);
1414 q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
1417 p+=quantum_info->pad;
1420 for (bit=0; bit < (ssize_t) (number_pixels % 2); bit++)
1422 p=PushShortPixel(endian,p,&pixel);
1423 q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
1426 p+=quantum_info->pad;
1433 for (x=0; x < (ssize_t) number_pixels; x++)
1435 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1436 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1439 p+=quantum_info->pad;
1449 if (quantum_info->min_is_white != MagickFalse)
1451 for (x=0; x < (ssize_t) number_pixels; x++)
1453 p=PushShortPixel(endian,p,&pixel);
1454 q->red=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel));
1457 p+=quantum_info->pad;
1462 if (quantum_info->format == FloatingPointQuantumFormat)
1464 for (x=0; x < (ssize_t) number_pixels; x++)
1466 p=PushShortPixel(endian,p,&pixel);
1467 q->red=ClampToQuantum((MagickRealType) QuantumRange*
1468 HalfToSinglePrecision(pixel));
1471 p+=quantum_info->pad;
1476 for (x=0; x < (ssize_t) number_pixels; x++)
1478 p=PushShortPixel(endian,p,&pixel);
1479 SetRedPixelComponent(q,ScaleShortToQuantum(pixel));
1482 p+=quantum_info->pad;
1492 if (quantum_info->format == FloatingPointQuantumFormat)
1497 for (x=0; x < (ssize_t) number_pixels; x++)
1499 p=PushFloatPixel(&quantum_state,p,&pixel);
1500 q->red=ClampToQuantum(pixel);
1503 p+=quantum_info->pad;
1508 for (x=0; x < (ssize_t) number_pixels; x++)
1510 p=PushLongPixel(endian,p,&pixel);
1511 SetRedPixelComponent(q,ScaleLongToQuantum(pixel));
1514 p+=quantum_info->pad;
1521 if (quantum_info->format == FloatingPointQuantumFormat)
1526 for (x=0; x < (ssize_t) number_pixels; x++)
1528 p=PushDoublePixel(&quantum_state,p,&pixel);
1529 q->red=ClampToQuantum(pixel);
1532 p+=quantum_info->pad;
1540 range=GetQuantumRange(image->depth);
1541 for (x=0; x < (ssize_t) number_pixels; x++)
1543 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1544 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1547 p+=quantum_info->pad;
1555 case GrayAlphaQuantum:
1557 switch (quantum_info->depth)
1561 register unsigned char
1564 for (x=0; x < ((ssize_t) number_pixels-3); x+=4)
1566 for (bit=0; bit < 8; bit+=2)
1568 pixel=(unsigned char)
1569 (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
1570 q->red=(Quantum) (pixel == 0 ? 0 : QuantumRange);
1573 q->opacity=(Quantum) (((*p) & (1UL << (unsigned char) (6-bit)))
1574 == 0 ? TransparentOpacity : OpaqueOpacity);
1579 for (bit=0; bit <= (ssize_t) (number_pixels % 4); bit+=2)
1581 pixel=(unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
1582 q->red=(Quantum) (pixel != 0 ? 0 : QuantumRange);
1585 q->opacity=(Quantum) (((*p) & (1UL << (unsigned char) (6-bit)))
1586 == 0 ? TransparentOpacity : OpaqueOpacity);
1595 register unsigned char
1598 range=GetQuantumRange(image->depth);
1599 for (x=0; x < (ssize_t) number_pixels; x++)
1601 pixel=(unsigned char) ((*p >> 4) & 0xf);
1602 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1605 pixel=(unsigned char) ((*p) & 0xf);
1606 q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range));
1617 for (x=0; x < (ssize_t) number_pixels; x++)
1619 p=PushCharPixel(p,&pixel);
1620 SetRedPixelComponent(q,ScaleCharToQuantum(pixel));
1623 p=PushCharPixel(p,&pixel);
1624 q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel));
1625 p+=quantum_info->pad;
1632 range=GetQuantumRange(image->depth);
1633 for (x=0; x < (ssize_t) number_pixels; x++)
1635 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1636 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1639 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1640 SetOpacityPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1641 p+=quantum_info->pad;
1648 range=GetQuantumRange(image->depth);
1649 for (x=0; x < (ssize_t) number_pixels; x++)
1651 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1652 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1655 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1656 SetOpacityPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1657 p+=quantum_info->pad;
1667 if (quantum_info->format == FloatingPointQuantumFormat)
1669 for (x=0; x < (ssize_t) number_pixels; x++)
1671 p=PushShortPixel(endian,p,&pixel);
1672 q->red=ClampToQuantum((MagickRealType) QuantumRange*
1673 HalfToSinglePrecision(pixel));
1676 p=PushShortPixel(endian,p,&pixel);
1677 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(
1678 (MagickRealType) QuantumRange*HalfToSinglePrecision(pixel)));
1679 p+=quantum_info->pad;
1684 for (x=0; x < (ssize_t) number_pixels; x++)
1686 p=PushShortPixel(endian,p,&pixel);
1687 SetRedPixelComponent(q,ScaleShortToQuantum(pixel));
1690 p=PushShortPixel(endian,p,&pixel);
1691 q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel));
1692 p+=quantum_info->pad;
1702 if (quantum_info->format == FloatingPointQuantumFormat)
1707 for (x=0; x < (ssize_t) number_pixels; x++)
1709 p=PushFloatPixel(&quantum_state,p,&pixel);
1710 q->red=ClampToQuantum(pixel);
1713 p=PushFloatPixel(&quantum_state,p,&pixel);
1714 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel));
1715 p+=quantum_info->pad;
1720 for (x=0; x < (ssize_t) number_pixels; x++)
1722 p=PushLongPixel(endian,p,&pixel);
1723 SetRedPixelComponent(q,ScaleLongToQuantum(pixel));
1726 p=PushLongPixel(endian,p,&pixel);
1727 q->opacity=(Quantum) (QuantumRange-ScaleLongToQuantum(pixel));
1728 p+=quantum_info->pad;
1735 if (quantum_info->format == FloatingPointQuantumFormat)
1740 for (x=0; x < (ssize_t) number_pixels; x++)
1742 p=PushDoublePixel(&quantum_state,p,&pixel);
1743 q->red=ClampToQuantum(pixel);
1746 p=PushDoublePixel(&quantum_state,p,&pixel);
1747 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel));
1748 p+=quantum_info->pad;
1756 range=GetQuantumRange(image->depth);
1757 for (x=0; x < (ssize_t) number_pixels; x++)
1759 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1760 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1763 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1764 q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range));
1765 p+=quantum_info->pad;
1776 switch (quantum_info->depth)
1783 for (x=0; x < (ssize_t) number_pixels; x++)
1785 p=PushCharPixel(p,&pixel);
1786 SetRedPixelComponent(q,ScaleCharToQuantum(pixel));
1787 p+=quantum_info->pad;
1797 if (quantum_info->format == FloatingPointQuantumFormat)
1799 for (x=0; x < (ssize_t) number_pixels; x++)
1801 p=PushShortPixel(endian,p,&pixel);
1802 q->red=ClampToQuantum((MagickRealType) QuantumRange*
1803 HalfToSinglePrecision(pixel));
1804 p+=quantum_info->pad;
1809 for (x=0; x < (ssize_t) number_pixels; x++)
1811 p=PushShortPixel(endian,p,&pixel);
1812 SetRedPixelComponent(q,ScaleShortToQuantum(pixel));
1813 p+=quantum_info->pad;
1823 if (quantum_info->format == FloatingPointQuantumFormat)
1828 for (x=0; x < (ssize_t) number_pixels; x++)
1830 p=PushFloatPixel(&quantum_state,p,&pixel);
1831 q->red=ClampToQuantum(pixel);
1832 p+=quantum_info->pad;
1837 for (x=0; x < (ssize_t) number_pixels; x++)
1839 p=PushLongPixel(endian,p,&pixel);
1840 SetRedPixelComponent(q,ScaleLongToQuantum(pixel));
1841 p+=quantum_info->pad;
1848 if (quantum_info->format == FloatingPointQuantumFormat)
1853 for (x=0; x < (ssize_t) number_pixels; x++)
1855 p=PushDoublePixel(&quantum_state,p,&pixel);
1856 q->red=ClampToQuantum(pixel);
1857 p+=quantum_info->pad;
1865 range=GetQuantumRange(image->depth);
1866 for (x=0; x < (ssize_t) number_pixels; x++)
1868 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1869 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1870 p+=quantum_info->pad;
1879 case MagentaQuantum:
1881 switch (quantum_info->depth)
1888 for (x=0; x < (ssize_t) number_pixels; x++)
1890 p=PushCharPixel(p,&pixel);
1891 SetGreenPixelComponent(q,ScaleCharToQuantum(pixel));
1892 p+=quantum_info->pad;
1902 if (quantum_info->format == FloatingPointQuantumFormat)
1904 for (x=0; x < (ssize_t) number_pixels; x++)
1906 p=PushShortPixel(endian,p,&pixel);
1907 q->green=ClampToQuantum((MagickRealType) QuantumRange*
1908 HalfToSinglePrecision(pixel));
1909 p+=quantum_info->pad;
1914 for (x=0; x < (ssize_t) number_pixels; x++)
1916 p=PushShortPixel(endian,p,&pixel);
1917 SetGreenPixelComponent(q,ScaleShortToQuantum(pixel));
1918 p+=quantum_info->pad;
1928 if (quantum_info->format == FloatingPointQuantumFormat)
1933 for (x=0; x < (ssize_t) number_pixels; x++)
1935 p=PushFloatPixel(&quantum_state,p,&pixel);
1936 q->green=ClampToQuantum(pixel);
1937 p+=quantum_info->pad;
1942 for (x=0; x < (ssize_t) number_pixels; x++)
1944 p=PushLongPixel(endian,p,&pixel);
1945 SetGreenPixelComponent(q,ScaleLongToQuantum(pixel));
1946 p+=quantum_info->pad;
1953 if (quantum_info->format == FloatingPointQuantumFormat)
1958 for (x=0; x < (ssize_t) number_pixels; x++)
1960 p=PushDoublePixel(&quantum_state,p,&pixel);
1961 q->green=ClampToQuantum(pixel);
1962 p+=quantum_info->pad;
1970 range=GetQuantumRange(image->depth);
1971 for (x=0; x < (ssize_t) number_pixels; x++)
1973 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1974 SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1975 p+=quantum_info->pad;
1986 switch (quantum_info->depth)
1993 for (x=0; x < (ssize_t) number_pixels; x++)
1995 p=PushCharPixel(p,&pixel);
1996 SetBluePixelComponent(q,ScaleCharToQuantum(pixel));
1997 p+=quantum_info->pad;
2007 if (quantum_info->format == FloatingPointQuantumFormat)
2009 for (x=0; x < (ssize_t) number_pixels; x++)
2011 p=PushShortPixel(endian,p,&pixel);
2012 q->blue=ClampToQuantum((MagickRealType) QuantumRange*
2013 HalfToSinglePrecision(pixel));
2014 p+=quantum_info->pad;
2019 for (x=0; x < (ssize_t) number_pixels; x++)
2021 p=PushShortPixel(endian,p,&pixel);
2022 SetBluePixelComponent(q,ScaleShortToQuantum(pixel));
2023 p+=quantum_info->pad;
2033 if (quantum_info->format == FloatingPointQuantumFormat)
2038 for (x=0; x < (ssize_t) number_pixels; x++)
2040 p=PushFloatPixel(&quantum_state,p,&pixel);
2041 q->blue=ClampToQuantum(pixel);
2042 p+=quantum_info->pad;
2047 for (x=0; x < (ssize_t) number_pixels; x++)
2049 p=PushLongPixel(endian,p,&pixel);
2050 SetBluePixelComponent(q,ScaleLongToQuantum(pixel));
2051 p+=quantum_info->pad;
2058 if (quantum_info->format == FloatingPointQuantumFormat)
2063 for (x=0; x < (ssize_t) number_pixels; x++)
2065 p=PushDoublePixel(&quantum_state,p,&pixel);
2066 q->blue=ClampToQuantum(pixel);
2067 p+=quantum_info->pad;
2075 range=GetQuantumRange(image->depth);
2076 for (x=0; x < (ssize_t) number_pixels; x++)
2078 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2079 SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range));
2080 p+=quantum_info->pad;
2090 switch (quantum_info->depth)
2097 for (x=0; x < (ssize_t) number_pixels; x++)
2099 p=PushCharPixel(p,&pixel);
2100 q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel));
2101 p+=quantum_info->pad;
2111 if (quantum_info->format == FloatingPointQuantumFormat)
2113 for (x=0; x < (ssize_t) number_pixels; x++)
2115 p=PushShortPixel(endian,p,&pixel);
2116 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(
2117 (MagickRealType) QuantumRange*HalfToSinglePrecision(pixel)));
2118 p+=quantum_info->pad;
2123 for (x=0; x < (ssize_t) number_pixels; x++)
2125 p=PushShortPixel(endian,p,&pixel);
2126 q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel));
2127 p+=quantum_info->pad;
2137 if (quantum_info->format == FloatingPointQuantumFormat)
2142 for (x=0; x < (ssize_t) number_pixels; x++)
2144 p=PushFloatPixel(&quantum_state,p,&pixel);
2145 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel));
2146 p+=quantum_info->pad;
2151 for (x=0; x < (ssize_t) number_pixels; x++)
2153 p=PushLongPixel(endian,p,&pixel);
2154 q->opacity=(Quantum) (QuantumRange-ScaleLongToQuantum(pixel));
2155 p+=quantum_info->pad;
2162 if (quantum_info->format == FloatingPointQuantumFormat)
2167 for (x=0; x < (ssize_t) number_pixels; x++)
2169 p=PushDoublePixel(&quantum_state,p,&pixel);
2170 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel));
2171 p+=quantum_info->pad;
2179 range=GetQuantumRange(image->depth);
2180 for (x=0; x < (ssize_t) number_pixels; x++)
2182 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2183 q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range));
2184 p+=quantum_info->pad;
2194 if (image->colorspace != CMYKColorspace)
2196 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
2197 "ColorSeparatedImageRequired","`%s'",image->filename);
2200 switch (quantum_info->depth)
2207 for (x=0; x < (ssize_t) number_pixels; x++)
2209 p=PushCharPixel(p,&pixel);
2210 indexes[x]=ScaleCharToQuantum(pixel);
2211 p+=quantum_info->pad;
2220 if (quantum_info->format == FloatingPointQuantumFormat)
2222 for (x=0; x < (ssize_t) number_pixels; x++)
2224 p=PushShortPixel(endian,p,&pixel);
2225 indexes[x]=ClampToQuantum((MagickRealType) QuantumRange*
2226 HalfToSinglePrecision(pixel));
2227 p+=quantum_info->pad;
2231 for (x=0; x < (ssize_t) number_pixels; x++)
2233 p=PushShortPixel(endian,p,&pixel);
2234 indexes[x]=ScaleShortToQuantum(pixel);
2235 p+=quantum_info->pad;
2244 if (quantum_info->format == FloatingPointQuantumFormat)
2249 for (x=0; x < (ssize_t) number_pixels; x++)
2251 p=PushFloatPixel(&quantum_state,p,&pixel);
2252 indexes[x]=ClampToQuantum(pixel);
2253 p+=quantum_info->pad;
2258 for (x=0; x < (ssize_t) number_pixels; x++)
2260 p=PushLongPixel(endian,p,&pixel);
2261 indexes[x]=ScaleLongToQuantum(pixel);
2262 p+=quantum_info->pad;
2269 if (quantum_info->format == FloatingPointQuantumFormat)
2274 for (x=0; x < (ssize_t) number_pixels; x++)
2276 p=PushDoublePixel(&quantum_state,p,&pixel);
2277 indexes[x]=ClampToQuantum(pixel);
2278 p+=quantum_info->pad;
2286 range=GetQuantumRange(image->depth);
2287 for (x=0; x < (ssize_t) number_pixels; x++)
2289 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2290 indexes[x]=ScaleAnyToQuantum(pixel,range);
2291 p+=quantum_info->pad;
2302 switch (quantum_info->depth)
2309 for (x=0; x < (ssize_t) number_pixels; x++)
2311 p=PushCharPixel(p,&pixel);
2312 SetRedPixelComponent(q,ScaleCharToQuantum(pixel));
2313 p=PushCharPixel(p,&pixel);
2314 SetGreenPixelComponent(q,ScaleCharToQuantum(pixel));
2315 p=PushCharPixel(p,&pixel);
2316 SetBluePixelComponent(q,ScaleCharToQuantum(pixel));
2317 SetOpacityPixelComponent(q,OpaqueOpacity);
2318 p+=quantum_info->pad;
2325 range=GetQuantumRange(image->depth);
2326 if (quantum_info->pack == MagickFalse)
2328 for (x=0; x < (ssize_t) number_pixels; x++)
2330 p=PushLongPixel(endian,p,&pixel);
2331 q->red=ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range);
2332 q->green=ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range);
2333 q->blue=ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range);
2334 p+=quantum_info->pad;
2339 if (quantum_info->quantum == 32U)
2341 for (x=0; x < (ssize_t) number_pixels; x++)
2343 p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel);
2344 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
2345 p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel);
2346 SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
2347 p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel);
2348 SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range));
2353 for (x=0; x < (ssize_t) number_pixels; x++)
2355 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2356 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
2357 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2358 SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
2359 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2360 SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range));
2367 range=GetQuantumRange(image->depth);
2368 if (quantum_info->pack == MagickFalse)
2373 for (x=0; x < (ssize_t) (3*number_pixels-1); x+=2)
2375 p=PushShortPixel(endian,p,&pixel);
2381 q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
2386 q->green=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
2391 q->blue=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
2396 p=PushShortPixel(endian,p,&pixel);
2402 q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
2407 q->green=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
2412 q->blue=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
2417 p+=quantum_info->pad;
2419 for (bit=0; bit < (ssize_t) (3*number_pixels % 2); bit++)
2421 p=PushShortPixel(endian,p,&pixel);
2422 switch ((x+bit) % 3)
2427 q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
2432 q->green=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
2437 q->blue=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
2442 p+=quantum_info->pad;
2448 if (quantum_info->quantum == 32U)
2450 for (x=0; x < (ssize_t) number_pixels; x++)
2452 p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel);
2453 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
2454 p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel);
2455 SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
2456 p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel);
2457 SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range));
2462 for (x=0; x < (ssize_t) number_pixels; x++)
2464 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2465 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
2466 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2467 SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
2468 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2469 SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range));
2479 if (quantum_info->format == FloatingPointQuantumFormat)
2481 for (x=0; x < (ssize_t) number_pixels; x++)
2483 p=PushShortPixel(endian,p,&pixel);
2484 q->red=ClampToQuantum((MagickRealType) QuantumRange*
2485 HalfToSinglePrecision(pixel));
2486 p=PushShortPixel(endian,p,&pixel);
2487 q->green=ClampToQuantum((MagickRealType) QuantumRange*
2488 HalfToSinglePrecision(pixel));
2489 p=PushShortPixel(endian,p,&pixel);
2490 q->blue=ClampToQuantum((MagickRealType) QuantumRange*
2491 HalfToSinglePrecision(pixel));
2492 p+=quantum_info->pad;
2497 for (x=0; x < (ssize_t) number_pixels; x++)
2499 p=PushShortPixel(endian,p,&pixel);
2500 SetRedPixelComponent(q,ScaleShortToQuantum(pixel));
2501 p=PushShortPixel(endian,p,&pixel);
2502 SetGreenPixelComponent(q,ScaleShortToQuantum(pixel));
2503 p=PushShortPixel(endian,p,&pixel);
2504 SetBluePixelComponent(q,ScaleShortToQuantum(pixel));
2505 p+=quantum_info->pad;
2515 if (quantum_info->format == FloatingPointQuantumFormat)
2520 for (x=0; x < (ssize_t) number_pixels; x++)
2522 p=PushFloatPixel(&quantum_state,p,&pixel);
2523 q->red=ClampToQuantum(pixel);
2524 p=PushFloatPixel(&quantum_state,p,&pixel);
2525 q->green=ClampToQuantum(pixel);
2526 p=PushFloatPixel(&quantum_state,p,&pixel);
2527 q->blue=ClampToQuantum(pixel);
2528 p+=quantum_info->pad;
2533 for (x=0; x < (ssize_t) number_pixels; x++)
2535 p=PushLongPixel(endian,p,&pixel);
2536 SetRedPixelComponent(q,ScaleLongToQuantum(pixel));
2537 p=PushLongPixel(endian,p,&pixel);
2538 SetGreenPixelComponent(q,ScaleLongToQuantum(pixel));
2539 p=PushLongPixel(endian,p,&pixel);
2540 SetBluePixelComponent(q,ScaleLongToQuantum(pixel));
2541 p+=quantum_info->pad;
2548 if (quantum_info->format == FloatingPointQuantumFormat)
2553 for (x=0; x < (ssize_t) number_pixels; x++)
2555 p=PushDoublePixel(&quantum_state,p,&pixel);
2556 q->red=ClampToQuantum(pixel);
2557 p=PushDoublePixel(&quantum_state,p,&pixel);
2558 q->green=ClampToQuantum(pixel);
2559 p=PushDoublePixel(&quantum_state,p,&pixel);
2560 q->blue=ClampToQuantum(pixel);
2561 p+=quantum_info->pad;
2569 range=GetQuantumRange(image->depth);
2570 for (x=0; x < (ssize_t) number_pixels; x++)
2572 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2573 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
2574 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2575 SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
2576 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2577 SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range));
2589 switch (quantum_info->depth)
2596 for (x=0; x < (ssize_t) number_pixels; x++)
2598 p=PushCharPixel(p,&pixel);
2599 SetRedPixelComponent(q,ScaleCharToQuantum(pixel));
2600 p=PushCharPixel(p,&pixel);
2601 SetGreenPixelComponent(q,ScaleCharToQuantum(pixel));
2602 p=PushCharPixel(p,&pixel);
2603 SetBluePixelComponent(q,ScaleCharToQuantum(pixel));
2604 p=PushCharPixel(p,&pixel);
2605 q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel));
2606 p+=quantum_info->pad;
2614 if (quantum_info->pack == MagickFalse)
2627 for (x=0; x < (ssize_t) number_pixels; x++)
2629 for (i=0; i < 4; i++)
2635 p=PushLongPixel(endian,p,&pixel);
2636 quantum=(size_t) (ScaleShortToQuantum(
2637 (unsigned short) (((pixel >> 22) & 0x3ff) << 6)));
2642 quantum=(size_t) (ScaleShortToQuantum(
2643 (unsigned short) (((pixel >> 12) & 0x3ff) << 6)));
2648 quantum=(size_t) (ScaleShortToQuantum(
2649 (unsigned short) (((pixel >> 2) & 0x3ff) << 6)));
2655 case 0: q->red=(Quantum) (quantum); break;
2656 case 1: q->green=(Quantum) (quantum); break;
2657 case 2: q->blue=(Quantum) (quantum); break;
2658 case 3: q->opacity=(Quantum) (QuantumRange-quantum); break;
2662 p+=quantum_info->pad;
2667 for (x=0; x < (ssize_t) number_pixels; x++)
2669 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2670 q->red=ScaleShortToQuantum((unsigned short) (pixel << 6));
2671 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2672 q->green=ScaleShortToQuantum((unsigned short) (pixel << 6));
2673 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2674 q->blue=ScaleShortToQuantum((unsigned short) (pixel << 6));
2675 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2676 q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(
2677 (unsigned short) (pixel << 6)));
2687 if (quantum_info->format == FloatingPointQuantumFormat)
2689 for (x=0; x < (ssize_t) number_pixels; x++)
2691 p=PushShortPixel(endian,p,&pixel);
2692 q->red=ClampToQuantum((MagickRealType) QuantumRange*
2693 HalfToSinglePrecision(pixel));
2694 p=PushShortPixel(endian,p,&pixel);
2695 q->green=ClampToQuantum((MagickRealType) QuantumRange*
2696 HalfToSinglePrecision(pixel));
2697 p=PushShortPixel(endian,p,&pixel);
2698 q->blue=ClampToQuantum((MagickRealType) QuantumRange*
2699 HalfToSinglePrecision(pixel));
2700 p=PushShortPixel(endian,p,&pixel);
2701 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(
2702 (MagickRealType) QuantumRange*HalfToSinglePrecision(pixel)));
2703 p+=quantum_info->pad;
2708 for (x=0; x < (ssize_t) number_pixels; x++)
2710 p=PushShortPixel(endian,p,&pixel);
2711 SetRedPixelComponent(q,ScaleShortToQuantum(pixel));
2712 p=PushShortPixel(endian,p,&pixel);
2713 SetGreenPixelComponent(q,ScaleShortToQuantum(pixel));
2714 p=PushShortPixel(endian,p,&pixel);
2715 SetBluePixelComponent(q,ScaleShortToQuantum(pixel));
2716 p=PushShortPixel(endian,p,&pixel);
2717 q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel));
2718 p+=quantum_info->pad;
2728 if (quantum_info->format == FloatingPointQuantumFormat)
2733 for (x=0; x < (ssize_t) number_pixels; x++)
2735 p=PushFloatPixel(&quantum_state,p,&pixel);
2736 q->red=ClampToQuantum(pixel);
2737 p=PushFloatPixel(&quantum_state,p,&pixel);
2738 q->green=ClampToQuantum(pixel);
2739 p=PushFloatPixel(&quantum_state,p,&pixel);
2740 q->blue=ClampToQuantum(pixel);
2741 p=PushFloatPixel(&quantum_state,p,&pixel);
2742 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel));
2743 p+=quantum_info->pad;
2748 for (x=0; x < (ssize_t) number_pixels; x++)
2750 p=PushLongPixel(endian,p,&pixel);
2751 SetRedPixelComponent(q,ScaleLongToQuantum(pixel));
2752 p=PushLongPixel(endian,p,&pixel);
2753 SetGreenPixelComponent(q,ScaleLongToQuantum(pixel));
2754 p=PushLongPixel(endian,p,&pixel);
2755 SetBluePixelComponent(q,ScaleLongToQuantum(pixel));
2756 p=PushLongPixel(endian,p,&pixel);
2757 q->opacity=(Quantum) (QuantumRange-ScaleLongToQuantum(pixel));
2758 p+=quantum_info->pad;
2765 if (quantum_info->format == FloatingPointQuantumFormat)
2770 for (x=0; x < (ssize_t) number_pixels; x++)
2772 p=PushDoublePixel(&quantum_state,p,&pixel);
2773 q->red=ClampToQuantum(pixel);
2774 p=PushDoublePixel(&quantum_state,p,&pixel);
2775 q->green=ClampToQuantum(pixel);
2776 p=PushDoublePixel(&quantum_state,p,&pixel);
2777 q->blue=ClampToQuantum(pixel);
2778 p=PushDoublePixel(&quantum_state,p,&pixel);
2779 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel));
2780 p+=quantum_info->pad;
2788 range=GetQuantumRange(image->depth);
2789 for (x=0; x < (ssize_t) number_pixels; x++)
2791 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2792 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
2793 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2794 SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
2795 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2796 SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range));
2797 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2798 q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range));
2808 if (image->colorspace != CMYKColorspace)
2810 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
2811 "ColorSeparatedImageRequired","`%s'",image->filename);
2814 switch (quantum_info->depth)
2821 for (x=0; x < (ssize_t) number_pixels; x++)
2823 p=PushCharPixel(p,&pixel);
2824 SetRedPixelComponent(q,ScaleCharToQuantum(pixel));
2825 p=PushCharPixel(p,&pixel);
2826 SetGreenPixelComponent(q,ScaleCharToQuantum(pixel));
2827 p=PushCharPixel(p,&pixel);
2828 SetBluePixelComponent(q,ScaleCharToQuantum(pixel));
2829 p=PushCharPixel(p,&pixel);
2830 indexes[x]=ScaleCharToQuantum(pixel);
2831 p+=quantum_info->pad;
2841 if (quantum_info->format == FloatingPointQuantumFormat)
2843 for (x=0; x < (ssize_t) number_pixels; x++)
2845 p=PushShortPixel(endian,p,&pixel);
2846 q->red=ClampToQuantum((MagickRealType) QuantumRange*
2847 HalfToSinglePrecision(pixel));
2848 p=PushShortPixel(endian,p,&pixel);
2849 q->green=ClampToQuantum((MagickRealType) QuantumRange*
2850 HalfToSinglePrecision(pixel));
2851 p=PushShortPixel(endian,p,&pixel);
2852 q->blue=ClampToQuantum((MagickRealType) QuantumRange*
2853 HalfToSinglePrecision(pixel));
2854 p=PushShortPixel(endian,p,&pixel);
2855 indexes[x]=ClampToQuantum((MagickRealType) QuantumRange*
2856 HalfToSinglePrecision(pixel));
2857 p+=quantum_info->pad;
2862 for (x=0; x < (ssize_t) number_pixels; x++)
2864 p=PushShortPixel(endian,p,&pixel);
2865 SetRedPixelComponent(q,ScaleShortToQuantum(pixel));
2866 p=PushShortPixel(endian,p,&pixel);
2867 SetGreenPixelComponent(q,ScaleShortToQuantum(pixel));
2868 p=PushShortPixel(endian,p,&pixel);
2869 SetBluePixelComponent(q,ScaleShortToQuantum(pixel));
2870 p=PushShortPixel(endian,p,&pixel);
2871 indexes[x]=ScaleShortToQuantum(pixel);
2872 p+=quantum_info->pad;
2882 if (quantum_info->format == FloatingPointQuantumFormat)
2887 for (x=0; x < (ssize_t) number_pixels; x++)
2889 p=PushFloatPixel(&quantum_state,p,&pixel);
2890 q->red=ClampToQuantum(pixel);
2891 p=PushFloatPixel(&quantum_state,p,&pixel);
2892 q->green=ClampToQuantum(pixel);
2893 p=PushFloatPixel(&quantum_state,p,&pixel);
2894 q->blue=ClampToQuantum(pixel);
2895 p=PushFloatPixel(&quantum_state,p,&pixel);
2896 indexes[x]=(IndexPacket) ClampToQuantum(pixel);
2897 p+=quantum_info->pad;
2902 for (x=0; x < (ssize_t) number_pixels; x++)
2904 p=PushLongPixel(endian,p,&pixel);
2905 SetRedPixelComponent(q,ScaleLongToQuantum(pixel));
2906 p=PushLongPixel(endian,p,&pixel);
2907 SetGreenPixelComponent(q,ScaleLongToQuantum(pixel));
2908 p=PushLongPixel(endian,p,&pixel);
2909 SetBluePixelComponent(q,ScaleLongToQuantum(pixel));
2910 p=PushLongPixel(endian,p,&pixel);
2911 indexes[x]=ScaleLongToQuantum(pixel);
2912 p+=quantum_info->pad;
2919 if (quantum_info->format == FloatingPointQuantumFormat)
2924 for (x=0; x < (ssize_t) number_pixels; x++)
2926 p=PushDoublePixel(&quantum_state,p,&pixel);
2927 q->red=ClampToQuantum(pixel);
2928 p=PushDoublePixel(&quantum_state,p,&pixel);
2929 q->green=ClampToQuantum(pixel);
2930 p=PushDoublePixel(&quantum_state,p,&pixel);
2931 q->blue=ClampToQuantum(pixel);
2932 p=PushDoublePixel(&quantum_state,p,&pixel);
2933 indexes[x]=(IndexPacket) ClampToQuantum(pixel);
2934 p+=quantum_info->pad;
2942 range=GetQuantumRange(image->depth);
2943 for (x=0; x < (ssize_t) number_pixels; x++)
2945 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2946 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
2947 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2948 SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
2949 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2950 SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range));
2951 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2952 indexes[x]=ScaleAnyToQuantum(pixel,range);
2963 if (image->colorspace != CMYKColorspace)
2965 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
2966 "ColorSeparatedImageRequired","`%s'",image->filename);
2969 switch (quantum_info->depth)
2976 for (x=0; x < (ssize_t) number_pixels; x++)
2978 p=PushCharPixel(p,&pixel);
2979 SetRedPixelComponent(q,ScaleCharToQuantum(pixel));
2980 p=PushCharPixel(p,&pixel);
2981 SetGreenPixelComponent(q,ScaleCharToQuantum(pixel));
2982 p=PushCharPixel(p,&pixel);
2983 SetBluePixelComponent(q,ScaleCharToQuantum(pixel));
2984 p=PushCharPixel(p,&pixel);
2985 indexes[x]=ScaleCharToQuantum(pixel);
2986 p=PushCharPixel(p,&pixel);
2987 q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel));
2988 p+=quantum_info->pad;
2998 if (quantum_info->format == FloatingPointQuantumFormat)
3000 for (x=0; x < (ssize_t) number_pixels; x++)
3002 p=PushShortPixel(endian,p,&pixel);
3003 q->red=ClampToQuantum((MagickRealType) QuantumRange*
3004 HalfToSinglePrecision(pixel));
3005 p=PushShortPixel(endian,p,&pixel);
3006 q->green=ClampToQuantum((MagickRealType) QuantumRange*
3007 HalfToSinglePrecision(pixel));
3008 p=PushShortPixel(endian,p,&pixel);
3009 q->blue=ClampToQuantum((MagickRealType) QuantumRange*
3010 HalfToSinglePrecision(pixel));
3011 p=PushShortPixel(endian,p,&pixel);
3012 indexes[x]=ClampToQuantum((MagickRealType) QuantumRange*
3013 HalfToSinglePrecision(pixel));
3014 p=PushShortPixel(endian,p,&pixel);
3015 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(
3016 (MagickRealType) QuantumRange*HalfToSinglePrecision(pixel)));
3017 p+=quantum_info->pad;
3022 for (x=0; x < (ssize_t) number_pixels; x++)
3024 p=PushShortPixel(endian,p,&pixel);
3025 SetRedPixelComponent(q,ScaleShortToQuantum(pixel));
3026 p=PushShortPixel(endian,p,&pixel);
3027 SetGreenPixelComponent(q,ScaleShortToQuantum(pixel));
3028 p=PushShortPixel(endian,p,&pixel);
3029 SetBluePixelComponent(q,ScaleShortToQuantum(pixel));
3030 p=PushShortPixel(endian,p,&pixel);
3031 indexes[x]=ScaleShortToQuantum(pixel);
3032 p=PushShortPixel(endian,p,&pixel);
3033 q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel));
3034 p+=quantum_info->pad;
3044 if (quantum_info->format == FloatingPointQuantumFormat)
3049 for (x=0; x < (ssize_t) number_pixels; x++)
3051 p=PushFloatPixel(&quantum_state,p,&pixel);
3052 q->red=ClampToQuantum(pixel);
3053 p=PushFloatPixel(&quantum_state,p,&pixel);
3054 q->green=ClampToQuantum(pixel);
3055 p=PushFloatPixel(&quantum_state,p,&pixel);
3056 q->blue=ClampToQuantum(pixel);
3057 p=PushFloatPixel(&quantum_state,p,&pixel);
3058 indexes[x]=(IndexPacket) ClampToQuantum(pixel);
3059 p=PushFloatPixel(&quantum_state,p,&pixel);
3060 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel));
3061 p+=quantum_info->pad;
3066 for (x=0; x < (ssize_t) number_pixels; x++)
3068 p=PushLongPixel(endian,p,&pixel);
3069 SetRedPixelComponent(q,ScaleLongToQuantum(pixel));
3070 p=PushLongPixel(endian,p,&pixel);
3071 SetGreenPixelComponent(q,ScaleLongToQuantum(pixel));
3072 p=PushLongPixel(endian,p,&pixel);
3073 SetBluePixelComponent(q,ScaleLongToQuantum(pixel));
3074 p=PushLongPixel(endian,p,&pixel);
3075 indexes[x]=ScaleLongToQuantum(pixel);
3076 p=PushLongPixel(endian,p,&pixel);
3077 q->opacity=(Quantum) (QuantumRange-ScaleLongToQuantum(pixel));
3078 p+=quantum_info->pad;
3085 if (quantum_info->format == FloatingPointQuantumFormat)
3090 for (x=0; x < (ssize_t) number_pixels; x++)
3092 p=PushDoublePixel(&quantum_state,p,&pixel);
3093 q->red=ClampToQuantum(pixel);
3094 p=PushDoublePixel(&quantum_state,p,&pixel);
3095 q->green=ClampToQuantum(pixel);
3096 p=PushDoublePixel(&quantum_state,p,&pixel);
3097 q->blue=ClampToQuantum(pixel);
3098 p=PushDoublePixel(&quantum_state,p,&pixel);
3099 indexes[x]=(IndexPacket) ClampToQuantum(pixel);
3100 p=PushDoublePixel(&quantum_state,p,&pixel);
3101 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel));
3102 p=PushDoublePixel(&quantum_state,p,&pixel);
3103 p+=quantum_info->pad;
3111 range=GetQuantumRange(image->depth);
3112 for (x=0; x < (ssize_t) number_pixels; x++)
3114 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
3115 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
3116 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
3117 SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
3118 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
3119 SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range));
3120 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
3121 indexes[x]=ScaleAnyToQuantum(pixel,range);
3122 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
3123 q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range));
3133 switch (quantum_info->depth)
3141 if (quantum_info->pack == MagickFalse)
3154 for (x=0; x < (ssize_t) number_pixels; x+=2)
3156 for (i=0; i < 4; i++)
3162 p=PushLongPixel(endian,p,&pixel);
3163 quantum=(size_t) (ScaleShortToQuantum(
3164 (unsigned short) (((pixel >> 22) & 0x3ff) << 6)));
3169 quantum=(size_t) (ScaleShortToQuantum(
3170 (unsigned short) (((pixel >> 12) & 0x3ff) << 6)));
3175 quantum=(size_t) (ScaleShortToQuantum(
3176 (unsigned short) (((pixel >> 2) & 0x3ff) << 6)));
3180 cbcr[i]=(Quantum) (quantum);
3183 p+=quantum_info->pad;
3198 range=GetQuantumRange(image->depth);
3199 for (x=0; x < (ssize_t) number_pixels; x++)
3201 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
3202 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
3203 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
3204 SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
3215 if ((quantum_type == CbYCrQuantum) || (quantum_type == CbYCrAQuantum))
3220 register PixelPacket
3223 q=GetAuthenticPixelQueue(image);
3224 if (image_view != (CacheView *) NULL)
3225 q=GetCacheViewAuthenticPixelQueue(image_view);
3226 for (x=0; x < (ssize_t) number_pixels; x++)
3234 if ((quantum_type == RGBOQuantum) || (quantum_type == CMYKOQuantum))
3236 register PixelPacket
3239 q=GetAuthenticPixelQueue(image);
3240 if (image_view != (CacheView *) NULL)
3241 q=GetCacheViewAuthenticPixelQueue(image_view);
3242 for (x=0; x < (ssize_t) number_pixels; x++)
3244 q->opacity=(Quantum) GetAlphaPixelComponent(q);
3248 if (quantum_info->alpha_type == DisassociatedQuantumAlpha)
3253 register PixelPacket
3259 q=GetAuthenticPixelQueue(image);
3260 if (image_view != (CacheView *) NULL)
3261 q=GetCacheViewAuthenticPixelQueue(image_view);
3262 for (x=0; x < (ssize_t) number_pixels; x++)
3264 alpha=QuantumScale*((MagickRealType) QuantumRange-q->opacity);
3265 alpha=1.0/(fabs(alpha) <= MagickEpsilon ? 1.0 : alpha);
3266 q->red=ClampToQuantum(alpha*q->red);
3267 q->green=ClampToQuantum(alpha*q->green);
3268 q->blue=ClampToQuantum(alpha*q->blue);