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 unsigned long 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 unsigned long depth,
196 const unsigned char *pixels,unsigned long *quantum)
201 register unsigned long
204 *quantum=(QuantumAny) 0;
205 for (i=(long) depth; i > 0L; )
207 if (quantum_state->bits == 0UL)
209 quantum_state->pixel=(*pixels++);
210 quantum_state->bits=8UL;
212 quantum_bits=(unsigned long) i;
213 if (quantum_bits > quantum_state->bits)
214 quantum_bits=quantum_state->bits;
216 quantum_state->bits-=quantum_bits;
217 *quantum=(*quantum << quantum_bits) | ((quantum_state->pixel >>
218 quantum_state->bits) &~ ((~0UL) << quantum_bits));
223 static inline const unsigned char *PushQuantumLongPixel(
224 QuantumState *quantum_state,const unsigned long depth,
225 const unsigned char *pixels,unsigned long *quantum)
230 register unsigned long
234 for (i=(long) depth; i > 0; )
236 if (quantum_state->bits == 0)
238 pixels=PushLongPixel(quantum_state->endian,pixels,
239 &quantum_state->pixel);
240 quantum_state->bits=32UL;
242 quantum_bits=(unsigned long) i;
243 if (quantum_bits > quantum_state->bits)
244 quantum_bits=quantum_state->bits;
245 *quantum|=(((quantum_state->pixel >> (32UL-quantum_state->bits)) &
246 quantum_state->mask[quantum_bits]) << (depth-i));
248 quantum_state->bits-=quantum_bits;
253 MagickExport size_t ImportQuantumPixels(Image *image,CacheView *image_view,
254 const QuantumInfo *quantum_info,const QuantumType quantum_type,
255 const unsigned char *pixels,ExceptionInfo *exception)
272 register const unsigned char
290 assert(image != (Image *) NULL);
291 assert(image->signature == MagickSignature);
292 if (image->debug != MagickFalse)
293 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
294 assert(quantum_info != (QuantumInfo *) NULL);
295 assert(quantum_info->signature == MagickSignature);
296 if (pixels == (const unsigned char *) NULL)
297 pixels=GetQuantumPixels(quantum_info);
300 number_pixels=GetImageExtent(image);
301 q=GetAuthenticPixelQueue(image);
302 indexes=GetAuthenticIndexQueue(image);
303 if (image_view != (CacheView *) NULL)
305 number_pixels=GetCacheViewExtent(image_view);
306 q=GetCacheViewAuthenticPixelQueue(image_view);
307 indexes=GetCacheViewAuthenticIndexQueue(image_view);
309 InitializeQuantumState(quantum_info,image->endian,&quantum_state);
310 extent=GetQuantumExtent(image,quantum_info,quantum_type);
311 endian=quantum_state.endian;
312 switch (quantum_type)
319 if (image->storage_class != PseudoClass)
321 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
322 "ColormappedImageRequired","`%s'",image->filename);
325 range_exception=MagickFalse;
326 switch (quantum_info->depth)
330 register unsigned char
333 for (x=0; x < ((long) number_pixels-7); x+=8)
335 for (bit=0; bit < 8; bit++)
337 if (quantum_info->min_is_white == MagickFalse)
338 pixel=(unsigned char) (((*p) & (1 << (7-bit))) == 0 ?
341 pixel=(unsigned char) (((*p) & (1 << (7-bit))) != 0 ?
343 indexes[x+bit]=PushColormapIndex(image,pixel,&range_exception);
344 *q=image->colormap[(long) indexes[x+bit]];
349 for (bit=0; bit < (long) (number_pixels % 8); bit++)
351 if (quantum_info->min_is_white == MagickFalse)
352 pixel=(unsigned char) (((*p) & (1 << (7-bit))) == 0 ?
355 pixel=(unsigned char) (((*p) & (1 << (7-bit))) != 0 ?
357 indexes[x+bit]=PushColormapIndex(image,pixel,&range_exception);
358 *q=image->colormap[(long) indexes[x+bit]];
365 register unsigned char
368 for (x=0; x < ((long) number_pixels-1); x+=2)
370 pixel=(unsigned char) ((*p >> 4) & 0xf);
371 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
372 *q=image->colormap[(long) indexes[x]];
374 pixel=(unsigned char) ((*p) & 0xf);
375 indexes[x+1]=PushColormapIndex(image,pixel,&range_exception);
376 *q=image->colormap[(long) indexes[x+1]];
380 for (bit=0; bit < (long) (number_pixels % 2); bit++)
382 pixel=(unsigned char) ((*p++ >> 4) & 0xf);
383 indexes[x+bit]=PushColormapIndex(image,pixel,&range_exception);
384 *q=image->colormap[(long) indexes[x+bit]];
394 for (x=0; x < (long) number_pixels; x++)
396 p=PushCharPixel(p,&pixel);
397 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
398 *q=image->colormap[(long) indexes[x]];
399 p+=quantum_info->pad;
409 if (quantum_info->format == FloatingPointQuantumFormat)
411 for (x=0; x < (long) number_pixels; x++)
413 p=PushShortPixel(endian,p,&pixel);
414 indexes[x]=PushColormapIndex(image,ClampToQuantum(
415 (MagickRealType) QuantumRange*
416 Binary16ToSinglePrecision(pixel)),&range_exception);
417 *q=image->colormap[(long) indexes[x]];
418 p+=quantum_info->pad;
423 for (x=0; x < (long) number_pixels; x++)
425 p=PushShortPixel(endian,p,&pixel);
426 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
427 *q=image->colormap[(long) indexes[x]];
428 p+=quantum_info->pad;
438 if (quantum_info->format == FloatingPointQuantumFormat)
443 for (x=0; x < (long) number_pixels; x++)
445 p=PushFloatPixel(&quantum_state,p,&pixel);
446 indexes[x]=PushColormapIndex(image,ClampToQuantum(pixel),
448 *q=image->colormap[(long) indexes[x]];
449 p+=quantum_info->pad;
454 for (x=0; x < (long) number_pixels; x++)
456 p=PushLongPixel(endian,p,&pixel);
457 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
458 *q=image->colormap[(long) indexes[x]];
459 p+=quantum_info->pad;
466 if (quantum_info->format == FloatingPointQuantumFormat)
471 for (x=0; x < (long) number_pixels; x++)
473 p=PushDoublePixel(&quantum_state,p,&pixel);
474 indexes[x]=PushColormapIndex(image,ClampToQuantum(pixel),
476 *q=image->colormap[(long) indexes[x]];
477 p+=quantum_info->pad;
485 for (x=0; x < (long) number_pixels; x++)
487 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
488 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
489 *q=image->colormap[(long) indexes[x]];
490 p+=quantum_info->pad;
496 if (range_exception != MagickFalse)
497 (void) ThrowMagickException(exception,GetMagickModule(),
498 CorruptImageError,"InvalidColormapIndex","`%s'",image->filename);
501 case IndexAlphaQuantum:
506 if (image->storage_class != PseudoClass)
508 (void) ThrowMagickException(exception,GetMagickModule(),
509 ImageError,"ColormappedImageRequired","`%s'",image->filename);
512 range_exception=MagickFalse;
513 switch (quantum_info->depth)
517 register unsigned char
520 for (x=0; x < ((long) number_pixels-3); x+=4)
522 for (bit=0; bit < 8; bit+=2)
524 if (quantum_info->min_is_white == MagickFalse)
525 pixel=(unsigned char) (((*p) & (1 << (7-bit))) == 0 ?
528 pixel=(unsigned char) (((*p) & (1 << (7-bit))) != 0 ?
530 indexes[x+bit/2]=(IndexPacket) (pixel == 0 ? 0 : 1);
531 q->red=(Quantum) (pixel == 0 ? 0 : QuantumRange);
534 q->opacity=(Quantum) (((*p) & (1UL << (unsigned char) (6-bit)))
535 == 0 ? TransparentOpacity : OpaqueOpacity);
539 for (bit=0; bit < (long) (number_pixels % 4); bit+=2)
541 if (quantum_info->min_is_white == MagickFalse)
542 pixel=(unsigned char) (((*p) & (1 << (7-bit))) == 0 ?
545 pixel=(unsigned char) (((*p) & (1 << (7-bit))) != 0 ?
547 indexes[x+bit/2]=(IndexPacket) (pixel == 0 ? 0 : 1);
548 q->red=(Quantum) (pixel == 0 ? 0 : QuantumRange);
551 q->opacity=(Quantum) (((*p) & (1UL << (unsigned char) (6-bit))) ==
552 0 ? TransparentOpacity : OpaqueOpacity);
559 register unsigned char
562 range=GetQuantumRange(image->depth);
563 for (x=0; x < (long) number_pixels; x++)
565 pixel=(unsigned char) ((*p >> 4) & 0xf);
566 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
567 *q=image->colormap[(long) indexes[x]];
568 pixel=(unsigned char) ((*p) & 0xf);
569 q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range));
580 for (x=0; x < (long) number_pixels; x++)
582 p=PushCharPixel(p,&pixel);
583 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
584 *q=image->colormap[(long) indexes[x]];
585 p=PushCharPixel(p,&pixel);
586 q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel));
587 p+=quantum_info->pad;
597 if (quantum_info->format == FloatingPointQuantumFormat)
599 for (x=0; x < (long) number_pixels; x++)
601 p=PushShortPixel(endian,p,&pixel);
602 indexes[x]=PushColormapIndex(image,ClampToQuantum(
603 (MagickRealType) QuantumRange*
604 Binary16ToSinglePrecision(pixel)),&range_exception);
605 *q=image->colormap[(long) indexes[x]];
606 p=PushShortPixel(endian,p,&pixel);
607 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(
608 (MagickRealType) QuantumRange*
609 Binary16ToSinglePrecision(pixel)));
610 p+=quantum_info->pad;
615 for (x=0; x < (long) number_pixels; x++)
617 p=PushShortPixel(endian,p,&pixel);
618 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
619 *q=image->colormap[(long) indexes[x]];
620 p=PushShortPixel(endian,p,&pixel);
621 q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel));
622 p+=quantum_info->pad;
632 if (quantum_info->format == FloatingPointQuantumFormat)
637 for (x=0; x < (long) number_pixels; x++)
639 p=PushFloatPixel(&quantum_state,p,&pixel);
640 indexes[x]=PushColormapIndex(image,ClampToQuantum(pixel),
642 *q=image->colormap[(long) indexes[x]];
643 p=PushFloatPixel(&quantum_state,p,&pixel);
644 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel));
645 p+=quantum_info->pad;
650 for (x=0; x < (long) number_pixels; x++)
652 p=PushLongPixel(endian,p,&pixel);
653 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
654 *q=image->colormap[(long) indexes[x]];
655 p=PushLongPixel(endian,p,&pixel);
656 q->opacity=(Quantum) (QuantumRange-ScaleLongToQuantum(pixel));
657 p+=quantum_info->pad;
664 if (quantum_info->format == FloatingPointQuantumFormat)
669 for (x=0; x < (long) number_pixels; x++)
671 p=PushDoublePixel(&quantum_state,p,&pixel);
672 indexes[x]=PushColormapIndex(image,ClampToQuantum(pixel),
674 *q=image->colormap[(long) indexes[x]];
675 p=PushDoublePixel(&quantum_state,p,&pixel);
676 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel));
677 p+=quantum_info->pad;
685 range=GetQuantumRange(image->depth);
686 for (x=0; x < (long) number_pixels; x++)
688 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
689 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
690 *q=image->colormap[(long) indexes[x]];
691 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
692 q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range));
693 p+=quantum_info->pad;
699 if (range_exception != MagickFalse)
700 (void) ThrowMagickException(exception,GetMagickModule(),
701 CorruptImageError,"InvalidColormapIndex","`%s'",image->filename);
706 switch (quantum_info->depth)
715 white=(Quantum) QuantumRange;
716 if (quantum_info->min_is_white != MagickFalse)
718 black=(Quantum) QuantumRange;
721 for (x=0; x < ((long) number_pixels-7); x+=8)
723 for (bit=0; bit < 8; bit++)
725 q->red=(((*p) & (1 << (7-bit))) == 0 ? black : white);
732 for (bit=0; bit < (long) (number_pixels % 8); bit++)
734 q->red=(((*p) & (1 << (7-bit))) == 0 ? black : white);
745 register unsigned char
748 range=GetQuantumRange(image->depth);
749 for (x=0; x < ((long) number_pixels-1); x+=2)
751 pixel=(unsigned char) ((*p >> 4) & 0xf);
752 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
756 pixel=(unsigned char) ((*p) & 0xf);
757 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
763 for (bit=0; bit < (long) (number_pixels % 2); bit++)
765 pixel=(unsigned char) (*p++ >> 4);
766 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
778 if (quantum_info->min_is_white != MagickFalse)
780 for (x=0; x < (long) number_pixels; x++)
782 p=PushCharPixel(p,&pixel);
783 q->red=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel));
786 SetOpacityPixelComponent(q,OpaqueOpacity);
787 p+=quantum_info->pad;
792 for (x=0; x < (long) number_pixels; x++)
794 p=PushCharPixel(p,&pixel);
795 SetRedPixelComponent(q,ScaleCharToQuantum(pixel));
798 SetOpacityPixelComponent(q,OpaqueOpacity);
799 p+=quantum_info->pad;
806 range=GetQuantumRange(image->depth);
807 if (quantum_info->pack == MagickFalse)
809 if (image->endian != LSBEndian)
811 for (x=0; x < (long) number_pixels/3; x++)
813 p=PushLongPixel(endian,p,&pixel);
814 q->red=ScaleAnyToQuantum((pixel >> 0) & 0x3ff,range);
818 q->red=ScaleAnyToQuantum((pixel >> 10) & 0x3ff,range);
822 q->red=ScaleAnyToQuantum((pixel >> 20) & 0x3ff,range);
825 p+=quantum_info->pad;
830 for (x=0; x < (long) number_pixels/3; x++)
832 p=PushLongPixel(endian,p,&pixel);
833 q->red=ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range);
837 q->red=ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range);
841 q->red=ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range);
844 p+=quantum_info->pad;
849 for (x=0; x < (long) number_pixels; x++)
851 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
852 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
855 p+=quantum_info->pad;
862 range=GetQuantumRange(image->depth);
863 if (quantum_info->pack == MagickFalse)
868 for (x=0; x < (long) (number_pixels-1); x+=2)
870 p=PushShortPixel(endian,p,&pixel);
871 q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
875 p=PushShortPixel(endian,p,&pixel);
876 q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
879 p+=quantum_info->pad;
882 for (bit=0; bit < (long) (number_pixels % 2); bit++)
884 p=PushShortPixel(endian,p,&pixel);
885 q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
888 p+=quantum_info->pad;
895 for (x=0; x < (long) number_pixels; x++)
897 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
898 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
901 p+=quantum_info->pad;
911 if (quantum_info->min_is_white != MagickFalse)
913 for (x=0; x < (long) number_pixels; x++)
915 p=PushShortPixel(endian,p,&pixel);
916 q->red=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel));
919 p+=quantum_info->pad;
924 if (quantum_info->format == FloatingPointQuantumFormat)
926 for (x=0; x < (long) number_pixels; x++)
928 p=PushShortPixel(endian,p,&pixel);
929 q->red=ClampToQuantum((MagickRealType) QuantumRange*
930 Binary16ToSinglePrecision(pixel));
933 p+=quantum_info->pad;
938 for (x=0; x < (long) number_pixels; x++)
940 p=PushShortPixel(endian,p,&pixel);
941 SetRedPixelComponent(q,ScaleShortToQuantum(pixel));
944 p+=quantum_info->pad;
954 if (quantum_info->format == FloatingPointQuantumFormat)
959 for (x=0; x < (long) number_pixels; x++)
961 p=PushFloatPixel(&quantum_state,p,&pixel);
962 q->red=ClampToQuantum(pixel);
965 p+=quantum_info->pad;
970 for (x=0; x < (long) number_pixels; x++)
972 p=PushLongPixel(endian,p,&pixel);
973 SetRedPixelComponent(q,ScaleLongToQuantum(pixel));
976 p+=quantum_info->pad;
983 if (quantum_info->format == FloatingPointQuantumFormat)
988 for (x=0; x < (long) number_pixels; x++)
990 p=PushDoublePixel(&quantum_state,p,&pixel);
991 q->red=ClampToQuantum(pixel);
994 p+=quantum_info->pad;
1002 range=GetQuantumRange(image->depth);
1003 for (x=0; x < (long) number_pixels; x++)
1005 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1006 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1009 p+=quantum_info->pad;
1017 case GrayAlphaQuantum:
1019 switch (quantum_info->depth)
1023 register unsigned char
1026 for (x=0; x < ((long) number_pixels-3); x+=4)
1028 for (bit=0; bit < 8; bit+=2)
1030 pixel=(unsigned char)
1031 (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
1032 q->red=(Quantum) (pixel == 0 ? 0 : QuantumRange);
1035 q->opacity=(Quantum) (((*p) & (1UL << (unsigned char) (6-bit)))
1036 == 0 ? TransparentOpacity : OpaqueOpacity);
1041 for (bit=0; bit < (long) (number_pixels % 4); bit+=2)
1043 pixel=(unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
1044 q->red=(Quantum) (pixel == 0 ? 0 : QuantumRange);
1047 q->opacity=(Quantum) (((*p) & (1UL << (unsigned char) (6-bit))) == 0
1048 ? TransparentOpacity : OpaqueOpacity);
1057 register unsigned char
1060 range=GetQuantumRange(image->depth);
1061 for (x=0; x < (long) number_pixels; x++)
1063 pixel=(unsigned char) ((*p >> 4) & 0xf);
1064 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1067 pixel=(unsigned char) ((*p) & 0xf);
1068 q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range));
1079 for (x=0; x < (long) number_pixels; x++)
1081 p=PushCharPixel(p,&pixel);
1082 SetRedPixelComponent(q,ScaleCharToQuantum(pixel));
1085 p=PushCharPixel(p,&pixel);
1086 q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel));
1087 p+=quantum_info->pad;
1094 range=GetQuantumRange(image->depth);
1095 for (x=0; x < (long) number_pixels; x++)
1097 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1098 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1101 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1102 SetOpacityPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1103 p+=quantum_info->pad;
1110 range=GetQuantumRange(image->depth);
1111 for (x=0; x < (long) number_pixels; x++)
1113 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1114 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1117 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1118 SetOpacityPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1119 p+=quantum_info->pad;
1129 if (quantum_info->format == FloatingPointQuantumFormat)
1131 for (x=0; x < (long) number_pixels; x++)
1133 p=PushShortPixel(endian,p,&pixel);
1134 q->red=ClampToQuantum((MagickRealType) QuantumRange*
1135 Binary16ToSinglePrecision(pixel));
1138 p=PushShortPixel(endian,p,&pixel);
1139 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(
1140 (MagickRealType) QuantumRange*
1141 Binary16ToSinglePrecision(pixel)));
1142 p+=quantum_info->pad;
1147 for (x=0; x < (long) number_pixels; x++)
1149 p=PushShortPixel(endian,p,&pixel);
1150 SetRedPixelComponent(q,ScaleShortToQuantum(pixel));
1153 p=PushShortPixel(endian,p,&pixel);
1154 q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel));
1155 p+=quantum_info->pad;
1165 if (quantum_info->format == FloatingPointQuantumFormat)
1170 for (x=0; x < (long) number_pixels; x++)
1172 p=PushFloatPixel(&quantum_state,p,&pixel);
1173 q->red=ClampToQuantum(pixel);
1176 p=PushFloatPixel(&quantum_state,p,&pixel);
1177 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel));
1178 p+=quantum_info->pad;
1183 for (x=0; x < (long) number_pixels; x++)
1185 p=PushLongPixel(endian,p,&pixel);
1186 SetRedPixelComponent(q,ScaleLongToQuantum(pixel));
1189 p=PushLongPixel(endian,p,&pixel);
1190 q->opacity=(Quantum) (QuantumRange-ScaleLongToQuantum(pixel));
1191 p+=quantum_info->pad;
1198 if (quantum_info->format == FloatingPointQuantumFormat)
1203 for (x=0; x < (long) number_pixels; x++)
1205 p=PushDoublePixel(&quantum_state,p,&pixel);
1206 q->red=ClampToQuantum(pixel);
1209 p=PushDoublePixel(&quantum_state,p,&pixel);
1210 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel));
1211 p+=quantum_info->pad;
1219 range=GetQuantumRange(image->depth);
1220 for (x=0; x < (long) number_pixels; x++)
1222 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1223 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1226 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1227 q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range));
1228 p+=quantum_info->pad;
1239 switch (quantum_info->depth)
1246 for (x=0; x < (long) number_pixels; x++)
1248 p=PushCharPixel(p,&pixel);
1249 SetRedPixelComponent(q,ScaleCharToQuantum(pixel));
1250 p+=quantum_info->pad;
1260 if (quantum_info->format == FloatingPointQuantumFormat)
1262 for (x=0; x < (long) number_pixels; x++)
1264 p=PushShortPixel(endian,p,&pixel);
1265 q->red=ClampToQuantum((MagickRealType) QuantumRange*
1266 Binary16ToSinglePrecision(pixel));
1267 p+=quantum_info->pad;
1272 for (x=0; x < (long) number_pixels; x++)
1274 p=PushShortPixel(endian,p,&pixel);
1275 SetRedPixelComponent(q,ScaleShortToQuantum(pixel));
1276 p+=quantum_info->pad;
1286 if (quantum_info->format == FloatingPointQuantumFormat)
1291 for (x=0; x < (long) number_pixels; x++)
1293 p=PushFloatPixel(&quantum_state,p,&pixel);
1294 q->red=ClampToQuantum(pixel);
1295 p+=quantum_info->pad;
1300 for (x=0; x < (long) number_pixels; x++)
1302 p=PushLongPixel(endian,p,&pixel);
1303 SetRedPixelComponent(q,ScaleLongToQuantum(pixel));
1304 p+=quantum_info->pad;
1311 if (quantum_info->format == FloatingPointQuantumFormat)
1316 for (x=0; x < (long) number_pixels; x++)
1318 p=PushDoublePixel(&quantum_state,p,&pixel);
1319 q->red=ClampToQuantum(pixel);
1320 p+=quantum_info->pad;
1328 range=GetQuantumRange(image->depth);
1329 for (x=0; x < (long) number_pixels; x++)
1331 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1332 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1333 p+=quantum_info->pad;
1342 case MagentaQuantum:
1344 switch (quantum_info->depth)
1351 for (x=0; x < (long) number_pixels; x++)
1353 p=PushCharPixel(p,&pixel);
1354 SetGreenPixelComponent(q,ScaleCharToQuantum(pixel));
1355 p+=quantum_info->pad;
1365 if (quantum_info->format == FloatingPointQuantumFormat)
1367 for (x=0; x < (long) number_pixels; x++)
1369 p=PushShortPixel(endian,p,&pixel);
1370 q->green=ClampToQuantum((MagickRealType) QuantumRange*
1371 Binary16ToSinglePrecision(pixel));
1372 p+=quantum_info->pad;
1377 for (x=0; x < (long) number_pixels; x++)
1379 p=PushShortPixel(endian,p,&pixel);
1380 SetGreenPixelComponent(q,ScaleShortToQuantum(pixel));
1381 p+=quantum_info->pad;
1391 if (quantum_info->format == FloatingPointQuantumFormat)
1396 for (x=0; x < (long) number_pixels; x++)
1398 p=PushFloatPixel(&quantum_state,p,&pixel);
1399 q->green=ClampToQuantum(pixel);
1400 p+=quantum_info->pad;
1405 for (x=0; x < (long) number_pixels; x++)
1407 p=PushLongPixel(endian,p,&pixel);
1408 SetGreenPixelComponent(q,ScaleLongToQuantum(pixel));
1409 p+=quantum_info->pad;
1416 if (quantum_info->format == FloatingPointQuantumFormat)
1421 for (x=0; x < (long) number_pixels; x++)
1423 p=PushDoublePixel(&quantum_state,p,&pixel);
1424 q->green=ClampToQuantum(pixel);
1425 p+=quantum_info->pad;
1433 range=GetQuantumRange(image->depth);
1434 for (x=0; x < (long) number_pixels; x++)
1436 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1437 SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1438 p+=quantum_info->pad;
1449 switch (quantum_info->depth)
1456 for (x=0; x < (long) number_pixels; x++)
1458 p=PushCharPixel(p,&pixel);
1459 SetBluePixelComponent(q,ScaleCharToQuantum(pixel));
1460 p+=quantum_info->pad;
1470 if (quantum_info->format == FloatingPointQuantumFormat)
1472 for (x=0; x < (long) number_pixels; x++)
1474 p=PushShortPixel(endian,p,&pixel);
1475 q->blue=ClampToQuantum((MagickRealType) QuantumRange*
1476 Binary16ToSinglePrecision(pixel));
1477 p+=quantum_info->pad;
1482 for (x=0; x < (long) number_pixels; x++)
1484 p=PushShortPixel(endian,p,&pixel);
1485 SetBluePixelComponent(q,ScaleShortToQuantum(pixel));
1486 p+=quantum_info->pad;
1496 if (quantum_info->format == FloatingPointQuantumFormat)
1501 for (x=0; x < (long) number_pixels; x++)
1503 p=PushFloatPixel(&quantum_state,p,&pixel);
1504 q->blue=ClampToQuantum(pixel);
1505 p+=quantum_info->pad;
1510 for (x=0; x < (long) number_pixels; x++)
1512 p=PushLongPixel(endian,p,&pixel);
1513 SetBluePixelComponent(q,ScaleLongToQuantum(pixel));
1514 p+=quantum_info->pad;
1521 if (quantum_info->format == FloatingPointQuantumFormat)
1526 for (x=0; x < (long) number_pixels; x++)
1528 p=PushDoublePixel(&quantum_state,p,&pixel);
1529 q->blue=ClampToQuantum(pixel);
1530 p+=quantum_info->pad;
1538 range=GetQuantumRange(image->depth);
1539 for (x=0; x < (long) number_pixels; x++)
1541 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1542 SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range));
1543 p+=quantum_info->pad;
1553 switch (quantum_info->depth)
1560 for (x=0; x < (long) number_pixels; x++)
1562 p=PushCharPixel(p,&pixel);
1563 q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel));
1564 p+=quantum_info->pad;
1574 if (quantum_info->format == FloatingPointQuantumFormat)
1576 for (x=0; x < (long) number_pixels; x++)
1578 p=PushShortPixel(endian,p,&pixel);
1579 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(
1580 (MagickRealType) QuantumRange*
1581 Binary16ToSinglePrecision(pixel)));
1582 p+=quantum_info->pad;
1587 for (x=0; x < (long) number_pixels; x++)
1589 p=PushShortPixel(endian,p,&pixel);
1590 q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel));
1591 p+=quantum_info->pad;
1601 if (quantum_info->format == FloatingPointQuantumFormat)
1606 for (x=0; x < (long) number_pixels; x++)
1608 p=PushFloatPixel(&quantum_state,p,&pixel);
1609 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel));
1610 p+=quantum_info->pad;
1615 for (x=0; x < (long) number_pixels; x++)
1617 p=PushLongPixel(endian,p,&pixel);
1618 q->opacity=(Quantum) (QuantumRange-ScaleLongToQuantum(pixel));
1619 p+=quantum_info->pad;
1626 if (quantum_info->format == FloatingPointQuantumFormat)
1631 for (x=0; x < (long) number_pixels; x++)
1633 p=PushDoublePixel(&quantum_state,p,&pixel);
1634 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel));
1635 p+=quantum_info->pad;
1643 range=GetQuantumRange(image->depth);
1644 for (x=0; x < (long) number_pixels; x++)
1646 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1647 q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range));
1648 p+=quantum_info->pad;
1658 if (image->colorspace != CMYKColorspace)
1660 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1661 "ColorSeparatedImageRequired","`%s'",image->filename);
1664 switch (quantum_info->depth)
1671 for (x=0; x < (long) number_pixels; x++)
1673 p=PushCharPixel(p,&pixel);
1674 indexes[x]=ScaleCharToQuantum(pixel);
1675 p+=quantum_info->pad;
1684 if (quantum_info->format == FloatingPointQuantumFormat)
1686 for (x=0; x < (long) number_pixels; x++)
1688 p=PushShortPixel(endian,p,&pixel);
1689 indexes[x]=ClampToQuantum((MagickRealType) QuantumRange*
1690 Binary16ToSinglePrecision(pixel));
1691 p+=quantum_info->pad;
1695 for (x=0; x < (long) number_pixels; x++)
1697 p=PushShortPixel(endian,p,&pixel);
1698 indexes[x]=ScaleShortToQuantum(pixel);
1699 p+=quantum_info->pad;
1708 if (quantum_info->format == FloatingPointQuantumFormat)
1713 for (x=0; x < (long) number_pixels; x++)
1715 p=PushFloatPixel(&quantum_state,p,&pixel);
1716 indexes[x]=ClampToQuantum(pixel);
1717 p+=quantum_info->pad;
1722 for (x=0; x < (long) number_pixels; x++)
1724 p=PushLongPixel(endian,p,&pixel);
1725 indexes[x]=ScaleLongToQuantum(pixel);
1726 p+=quantum_info->pad;
1733 if (quantum_info->format == FloatingPointQuantumFormat)
1738 for (x=0; x < (long) number_pixels; x++)
1740 p=PushDoublePixel(&quantum_state,p,&pixel);
1741 indexes[x]=ClampToQuantum(pixel);
1742 p+=quantum_info->pad;
1750 range=GetQuantumRange(image->depth);
1751 for (x=0; x < (long) number_pixels; x++)
1753 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1754 indexes[x]=ScaleAnyToQuantum(pixel,range);
1755 p+=quantum_info->pad;
1766 switch (quantum_info->depth)
1773 for (x=0; x < (long) number_pixels; x++)
1775 p=PushCharPixel(p,&pixel);
1776 SetRedPixelComponent(q,ScaleCharToQuantum(pixel));
1777 p=PushCharPixel(p,&pixel);
1778 SetGreenPixelComponent(q,ScaleCharToQuantum(pixel));
1779 p=PushCharPixel(p,&pixel);
1780 SetBluePixelComponent(q,ScaleCharToQuantum(pixel));
1781 SetOpacityPixelComponent(q,OpaqueOpacity);
1782 p+=quantum_info->pad;
1789 range=GetQuantumRange(image->depth);
1790 if (quantum_info->pack == MagickFalse)
1792 for (x=0; x < (long) number_pixels; x++)
1794 p=PushLongPixel(endian,p,&pixel);
1795 q->red=ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range);
1796 q->green=ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range);
1797 q->blue=ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range);
1798 p+=quantum_info->pad;
1803 if (quantum_info->quantum == 32UL)
1805 for (x=0; x < (long) number_pixels; x++)
1807 p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel);
1808 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1809 p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel);
1810 SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1811 p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel);
1812 SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range));
1817 for (x=0; x < (long) number_pixels; x++)
1819 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1820 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1821 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1822 SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1823 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1824 SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range));
1831 range=GetQuantumRange(image->depth);
1832 if (quantum_info->pack == MagickFalse)
1837 for (x=0; x < (long) (3*number_pixels-1); x+=2)
1839 p=PushShortPixel(endian,p,&pixel);
1845 q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
1850 q->green=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
1855 q->blue=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
1860 p=PushShortPixel(endian,p,&pixel);
1866 q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
1871 q->green=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
1876 q->blue=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
1881 p+=quantum_info->pad;
1883 for (bit=0; bit < (long) (3*number_pixels % 2); bit++)
1885 p=PushShortPixel(endian,p,&pixel);
1886 switch ((x+bit) % 3)
1891 q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
1896 q->green=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
1901 q->blue=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
1906 p+=quantum_info->pad;
1912 if (quantum_info->quantum == 32UL)
1914 for (x=0; x < (long) number_pixels; x++)
1916 p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel);
1917 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1918 p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel);
1919 SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1920 p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel);
1921 SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range));
1926 for (x=0; x < (long) number_pixels; x++)
1928 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1929 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1930 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1931 SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
1932 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
1933 SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range));
1943 if (quantum_info->format == FloatingPointQuantumFormat)
1945 for (x=0; x < (long) number_pixels; x++)
1947 p=PushShortPixel(endian,p,&pixel);
1948 q->red=ClampToQuantum((MagickRealType) QuantumRange*
1949 Binary16ToSinglePrecision(pixel));
1950 p=PushShortPixel(endian,p,&pixel);
1951 q->green=ClampToQuantum((MagickRealType) QuantumRange*
1952 Binary16ToSinglePrecision(pixel));
1953 p=PushShortPixel(endian,p,&pixel);
1954 q->blue=ClampToQuantum((MagickRealType) QuantumRange*
1955 Binary16ToSinglePrecision(pixel));
1956 p+=quantum_info->pad;
1961 for (x=0; x < (long) number_pixels; x++)
1963 p=PushShortPixel(endian,p,&pixel);
1964 SetRedPixelComponent(q,ScaleShortToQuantum(pixel));
1965 p=PushShortPixel(endian,p,&pixel);
1966 SetGreenPixelComponent(q,ScaleShortToQuantum(pixel));
1967 p=PushShortPixel(endian,p,&pixel);
1968 SetBluePixelComponent(q,ScaleShortToQuantum(pixel));
1969 p+=quantum_info->pad;
1979 if (quantum_info->format == FloatingPointQuantumFormat)
1984 for (x=0; x < (long) number_pixels; x++)
1986 p=PushFloatPixel(&quantum_state,p,&pixel);
1987 q->red=ClampToQuantum(pixel);
1988 p=PushFloatPixel(&quantum_state,p,&pixel);
1989 q->green=ClampToQuantum(pixel);
1990 p=PushFloatPixel(&quantum_state,p,&pixel);
1991 q->blue=ClampToQuantum(pixel);
1992 p+=quantum_info->pad;
1997 for (x=0; x < (long) number_pixels; x++)
1999 p=PushLongPixel(endian,p,&pixel);
2000 SetRedPixelComponent(q,ScaleLongToQuantum(pixel));
2001 p=PushLongPixel(endian,p,&pixel);
2002 SetGreenPixelComponent(q,ScaleLongToQuantum(pixel));
2003 p=PushLongPixel(endian,p,&pixel);
2004 SetBluePixelComponent(q,ScaleLongToQuantum(pixel));
2005 p+=quantum_info->pad;
2012 if (quantum_info->format == FloatingPointQuantumFormat)
2017 for (x=0; x < (long) number_pixels; x++)
2019 p=PushDoublePixel(&quantum_state,p,&pixel);
2020 q->red=ClampToQuantum(pixel);
2021 p=PushDoublePixel(&quantum_state,p,&pixel);
2022 q->green=ClampToQuantum(pixel);
2023 p=PushDoublePixel(&quantum_state,p,&pixel);
2024 q->blue=ClampToQuantum(pixel);
2025 p+=quantum_info->pad;
2033 range=GetQuantumRange(image->depth);
2034 for (x=0; x < (long) number_pixels; x++)
2036 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2037 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
2038 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2039 SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
2040 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2041 SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range));
2053 switch (quantum_info->depth)
2060 for (x=0; x < (long) number_pixels; x++)
2062 p=PushCharPixel(p,&pixel);
2063 SetRedPixelComponent(q,ScaleCharToQuantum(pixel));
2064 p=PushCharPixel(p,&pixel);
2065 SetGreenPixelComponent(q,ScaleCharToQuantum(pixel));
2066 p=PushCharPixel(p,&pixel);
2067 SetBluePixelComponent(q,ScaleCharToQuantum(pixel));
2068 p=PushCharPixel(p,&pixel);
2069 q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel));
2070 p+=quantum_info->pad;
2078 if (quantum_info->pack == MagickFalse)
2091 for (x=0; x < (long) number_pixels; x++)
2093 for (i=0; i < 4; i++)
2099 p=PushLongPixel(endian,p,&pixel);
2100 quantum=(unsigned long) (ScaleShortToQuantum(
2101 (unsigned short) (((pixel >> 22) & 0x3ff) << 6)));
2106 quantum=(unsigned long) (ScaleShortToQuantum(
2107 (unsigned short) (((pixel >> 12) & 0x3ff) << 6)));
2112 quantum=(unsigned long) (ScaleShortToQuantum(
2113 (unsigned short) (((pixel >> 2) & 0x3ff) << 6)));
2119 case 0: q->red=(Quantum) (quantum); break;
2120 case 1: q->green=(Quantum) (quantum); break;
2121 case 2: q->blue=(Quantum) (quantum); break;
2122 case 3: q->opacity=(Quantum) (QuantumRange-quantum); break;
2126 p+=quantum_info->pad;
2131 for (x=0; x < (long) number_pixels; x++)
2133 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2134 q->red=ScaleShortToQuantum((unsigned short) (pixel << 6));
2135 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2136 q->green=ScaleShortToQuantum((unsigned short) (pixel << 6));
2137 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2138 q->blue=ScaleShortToQuantum((unsigned short) (pixel << 6));
2139 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2140 q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(
2141 (unsigned short) (pixel << 6)));
2151 if (quantum_info->format == FloatingPointQuantumFormat)
2153 for (x=0; x < (long) number_pixels; x++)
2155 p=PushShortPixel(endian,p,&pixel);
2156 q->red=ClampToQuantum((MagickRealType) QuantumRange*
2157 Binary16ToSinglePrecision(pixel));
2158 p=PushShortPixel(endian,p,&pixel);
2159 q->green=ClampToQuantum((MagickRealType) QuantumRange*
2160 Binary16ToSinglePrecision(pixel));
2161 p=PushShortPixel(endian,p,&pixel);
2162 q->blue=ClampToQuantum((MagickRealType) QuantumRange*
2163 Binary16ToSinglePrecision(pixel));
2164 p=PushShortPixel(endian,p,&pixel);
2165 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(
2166 (MagickRealType) QuantumRange*
2167 Binary16ToSinglePrecision(pixel)));
2168 p+=quantum_info->pad;
2173 for (x=0; x < (long) number_pixels; x++)
2175 p=PushShortPixel(endian,p,&pixel);
2176 SetRedPixelComponent(q,ScaleShortToQuantum(pixel));
2177 p=PushShortPixel(endian,p,&pixel);
2178 SetGreenPixelComponent(q,ScaleShortToQuantum(pixel));
2179 p=PushShortPixel(endian,p,&pixel);
2180 SetBluePixelComponent(q,ScaleShortToQuantum(pixel));
2181 p=PushShortPixel(endian,p,&pixel);
2182 q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel));
2183 p+=quantum_info->pad;
2193 if (quantum_info->format == FloatingPointQuantumFormat)
2198 for (x=0; x < (long) number_pixels; x++)
2200 p=PushFloatPixel(&quantum_state,p,&pixel);
2201 q->red=ClampToQuantum(pixel);
2202 p=PushFloatPixel(&quantum_state,p,&pixel);
2203 q->green=ClampToQuantum(pixel);
2204 p=PushFloatPixel(&quantum_state,p,&pixel);
2205 q->blue=ClampToQuantum(pixel);
2206 p=PushFloatPixel(&quantum_state,p,&pixel);
2207 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel));
2208 p+=quantum_info->pad;
2213 for (x=0; x < (long) number_pixels; x++)
2215 p=PushLongPixel(endian,p,&pixel);
2216 SetRedPixelComponent(q,ScaleLongToQuantum(pixel));
2217 p=PushLongPixel(endian,p,&pixel);
2218 SetGreenPixelComponent(q,ScaleLongToQuantum(pixel));
2219 p=PushLongPixel(endian,p,&pixel);
2220 SetBluePixelComponent(q,ScaleLongToQuantum(pixel));
2221 p=PushLongPixel(endian,p,&pixel);
2222 q->opacity=(Quantum) (QuantumRange-ScaleLongToQuantum(pixel));
2223 p+=quantum_info->pad;
2230 if (quantum_info->format == FloatingPointQuantumFormat)
2235 for (x=0; x < (long) number_pixels; x++)
2237 p=PushDoublePixel(&quantum_state,p,&pixel);
2238 q->red=ClampToQuantum(pixel);
2239 p=PushDoublePixel(&quantum_state,p,&pixel);
2240 q->green=ClampToQuantum(pixel);
2241 p=PushDoublePixel(&quantum_state,p,&pixel);
2242 q->blue=ClampToQuantum(pixel);
2243 p=PushDoublePixel(&quantum_state,p,&pixel);
2244 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel));
2245 p+=quantum_info->pad;
2253 range=GetQuantumRange(image->depth);
2254 for (x=0; x < (long) number_pixels; x++)
2256 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2257 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
2258 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2259 SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
2260 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2261 SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range));
2262 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2263 q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range));
2273 if (image->colorspace != CMYKColorspace)
2275 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
2276 "ColorSeparatedImageRequired","`%s'",image->filename);
2279 switch (quantum_info->depth)
2286 for (x=0; x < (long) number_pixels; x++)
2288 p=PushCharPixel(p,&pixel);
2289 SetRedPixelComponent(q,ScaleCharToQuantum(pixel));
2290 p=PushCharPixel(p,&pixel);
2291 SetGreenPixelComponent(q,ScaleCharToQuantum(pixel));
2292 p=PushCharPixel(p,&pixel);
2293 SetBluePixelComponent(q,ScaleCharToQuantum(pixel));
2294 p=PushCharPixel(p,&pixel);
2295 indexes[x]=ScaleCharToQuantum(pixel);
2296 p+=quantum_info->pad;
2306 if (quantum_info->format == FloatingPointQuantumFormat)
2308 for (x=0; x < (long) number_pixels; x++)
2310 p=PushShortPixel(endian,p,&pixel);
2311 q->red=ClampToQuantum((MagickRealType) QuantumRange*
2312 Binary16ToSinglePrecision(pixel));
2313 p=PushShortPixel(endian,p,&pixel);
2314 q->green=ClampToQuantum((MagickRealType) QuantumRange*
2315 Binary16ToSinglePrecision(pixel));
2316 p=PushShortPixel(endian,p,&pixel);
2317 q->blue=ClampToQuantum((MagickRealType) QuantumRange*
2318 Binary16ToSinglePrecision(pixel));
2319 p=PushShortPixel(endian,p,&pixel);
2320 indexes[x]=ClampToQuantum((MagickRealType) QuantumRange*
2321 Binary16ToSinglePrecision(pixel));
2322 p+=quantum_info->pad;
2327 for (x=0; x < (long) number_pixels; x++)
2329 p=PushShortPixel(endian,p,&pixel);
2330 SetRedPixelComponent(q,ScaleShortToQuantum(pixel));
2331 p=PushShortPixel(endian,p,&pixel);
2332 SetGreenPixelComponent(q,ScaleShortToQuantum(pixel));
2333 p=PushShortPixel(endian,p,&pixel);
2334 SetBluePixelComponent(q,ScaleShortToQuantum(pixel));
2335 p=PushShortPixel(endian,p,&pixel);
2336 indexes[x]=ScaleShortToQuantum(pixel);
2337 p+=quantum_info->pad;
2347 if (quantum_info->format == FloatingPointQuantumFormat)
2352 for (x=0; x < (long) number_pixels; x++)
2354 p=PushFloatPixel(&quantum_state,p,&pixel);
2355 q->red=ClampToQuantum(pixel);
2356 p=PushFloatPixel(&quantum_state,p,&pixel);
2357 q->green=ClampToQuantum(pixel);
2358 p=PushFloatPixel(&quantum_state,p,&pixel);
2359 q->blue=ClampToQuantum(pixel);
2360 p=PushFloatPixel(&quantum_state,p,&pixel);
2361 indexes[x]=(IndexPacket) ClampToQuantum(pixel);
2362 p+=quantum_info->pad;
2367 for (x=0; x < (long) number_pixels; x++)
2369 p=PushLongPixel(endian,p,&pixel);
2370 SetRedPixelComponent(q,ScaleLongToQuantum(pixel));
2371 p=PushLongPixel(endian,p,&pixel);
2372 SetGreenPixelComponent(q,ScaleLongToQuantum(pixel));
2373 p=PushLongPixel(endian,p,&pixel);
2374 SetBluePixelComponent(q,ScaleLongToQuantum(pixel));
2375 p=PushLongPixel(endian,p,&pixel);
2376 indexes[x]=ScaleLongToQuantum(pixel);
2377 p+=quantum_info->pad;
2384 if (quantum_info->format == FloatingPointQuantumFormat)
2389 for (x=0; x < (long) number_pixels; x++)
2391 p=PushDoublePixel(&quantum_state,p,&pixel);
2392 q->red=ClampToQuantum(pixel);
2393 p=PushDoublePixel(&quantum_state,p,&pixel);
2394 q->green=ClampToQuantum(pixel);
2395 p=PushDoublePixel(&quantum_state,p,&pixel);
2396 q->blue=ClampToQuantum(pixel);
2397 p=PushDoublePixel(&quantum_state,p,&pixel);
2398 indexes[x]=(IndexPacket) ClampToQuantum(pixel);
2399 p+=quantum_info->pad;
2407 range=GetQuantumRange(image->depth);
2408 for (x=0; x < (long) number_pixels; x++)
2410 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2411 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
2412 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2413 SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
2414 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2415 SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range));
2416 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2417 indexes[x]=ScaleAnyToQuantum(pixel,range);
2428 if (image->colorspace != CMYKColorspace)
2430 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
2431 "ColorSeparatedImageRequired","`%s'",image->filename);
2434 switch (quantum_info->depth)
2441 for (x=0; x < (long) number_pixels; x++)
2443 p=PushCharPixel(p,&pixel);
2444 SetRedPixelComponent(q,ScaleCharToQuantum(pixel));
2445 p=PushCharPixel(p,&pixel);
2446 SetGreenPixelComponent(q,ScaleCharToQuantum(pixel));
2447 p=PushCharPixel(p,&pixel);
2448 SetBluePixelComponent(q,ScaleCharToQuantum(pixel));
2449 p=PushCharPixel(p,&pixel);
2450 indexes[x]=ScaleCharToQuantum(pixel);
2451 p=PushCharPixel(p,&pixel);
2452 q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel));
2453 p+=quantum_info->pad;
2463 if (quantum_info->format == FloatingPointQuantumFormat)
2465 for (x=0; x < (long) number_pixels; x++)
2467 p=PushShortPixel(endian,p,&pixel);
2468 q->red=ClampToQuantum((MagickRealType) QuantumRange*
2469 Binary16ToSinglePrecision(pixel));
2470 p=PushShortPixel(endian,p,&pixel);
2471 q->green=ClampToQuantum((MagickRealType) QuantumRange*
2472 Binary16ToSinglePrecision(pixel));
2473 p=PushShortPixel(endian,p,&pixel);
2474 q->blue=ClampToQuantum((MagickRealType) QuantumRange*
2475 Binary16ToSinglePrecision(pixel));
2476 p=PushShortPixel(endian,p,&pixel);
2477 indexes[x]=ClampToQuantum((MagickRealType) QuantumRange*
2478 Binary16ToSinglePrecision(pixel));
2479 p=PushShortPixel(endian,p,&pixel);
2480 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(
2481 (MagickRealType) QuantumRange*Binary16ToSinglePrecision(pixel)));
2482 p+=quantum_info->pad;
2487 for (x=0; x < (long) number_pixels; x++)
2489 p=PushShortPixel(endian,p,&pixel);
2490 SetRedPixelComponent(q,ScaleShortToQuantum(pixel));
2491 p=PushShortPixel(endian,p,&pixel);
2492 SetGreenPixelComponent(q,ScaleShortToQuantum(pixel));
2493 p=PushShortPixel(endian,p,&pixel);
2494 SetBluePixelComponent(q,ScaleShortToQuantum(pixel));
2495 p=PushShortPixel(endian,p,&pixel);
2496 indexes[x]=ScaleShortToQuantum(pixel);
2497 p=PushShortPixel(endian,p,&pixel);
2498 q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel));
2499 p+=quantum_info->pad;
2509 if (quantum_info->format == FloatingPointQuantumFormat)
2514 for (x=0; x < (long) number_pixels; x++)
2516 p=PushFloatPixel(&quantum_state,p,&pixel);
2517 q->red=ClampToQuantum(pixel);
2518 p=PushFloatPixel(&quantum_state,p,&pixel);
2519 q->green=ClampToQuantum(pixel);
2520 p=PushFloatPixel(&quantum_state,p,&pixel);
2521 q->blue=ClampToQuantum(pixel);
2522 p=PushFloatPixel(&quantum_state,p,&pixel);
2523 indexes[x]=(IndexPacket) ClampToQuantum(pixel);
2524 p=PushFloatPixel(&quantum_state,p,&pixel);
2525 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel));
2526 p+=quantum_info->pad;
2531 for (x=0; x < (long) number_pixels; x++)
2533 p=PushLongPixel(endian,p,&pixel);
2534 SetRedPixelComponent(q,ScaleLongToQuantum(pixel));
2535 p=PushLongPixel(endian,p,&pixel);
2536 SetGreenPixelComponent(q,ScaleLongToQuantum(pixel));
2537 p=PushLongPixel(endian,p,&pixel);
2538 SetBluePixelComponent(q,ScaleLongToQuantum(pixel));
2539 p=PushLongPixel(endian,p,&pixel);
2540 indexes[x]=ScaleLongToQuantum(pixel);
2541 p=PushLongPixel(endian,p,&pixel);
2542 q->opacity=(Quantum) (QuantumRange-ScaleLongToQuantum(pixel));
2543 p+=quantum_info->pad;
2550 if (quantum_info->format == FloatingPointQuantumFormat)
2555 for (x=0; x < (long) number_pixels; x++)
2557 p=PushDoublePixel(&quantum_state,p,&pixel);
2558 q->red=ClampToQuantum(pixel);
2559 p=PushDoublePixel(&quantum_state,p,&pixel);
2560 q->green=ClampToQuantum(pixel);
2561 p=PushDoublePixel(&quantum_state,p,&pixel);
2562 q->blue=ClampToQuantum(pixel);
2563 p=PushDoublePixel(&quantum_state,p,&pixel);
2564 indexes[x]=(IndexPacket) ClampToQuantum(pixel);
2565 p=PushDoublePixel(&quantum_state,p,&pixel);
2566 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel));
2567 p=PushDoublePixel(&quantum_state,p,&pixel);
2568 p+=quantum_info->pad;
2576 range=GetQuantumRange(image->depth);
2577 for (x=0; x < (long) number_pixels; x++)
2579 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2580 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
2581 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2582 SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
2583 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2584 SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range));
2585 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2586 indexes[x]=ScaleAnyToQuantum(pixel,range);
2587 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2588 q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range));
2598 switch (quantum_info->depth)
2606 if (quantum_info->pack == MagickFalse)
2619 for (x=0; x < (long) number_pixels; x+=2)
2621 for (i=0; i < 4; i++)
2627 p=PushLongPixel(endian,p,&pixel);
2628 quantum=(unsigned long) (ScaleShortToQuantum(
2629 (unsigned short) (((pixel >> 22) & 0x3ff) << 6)));
2634 quantum=(unsigned long) (ScaleShortToQuantum(
2635 (unsigned short) (((pixel >> 12) & 0x3ff) << 6)));
2640 quantum=(unsigned long) (ScaleShortToQuantum(
2641 (unsigned short) (((pixel >> 2) & 0x3ff) << 6)));
2645 cbcr[i]=(Quantum) (quantum);
2648 p+=quantum_info->pad;
2663 range=GetQuantumRange(image->depth);
2664 for (x=0; x < (long) number_pixels; x++)
2666 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2667 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
2668 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
2669 SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
2680 if ((quantum_type == CbYCrQuantum) || (quantum_type == CbYCrAQuantum))
2685 register PixelPacket
2688 q=GetAuthenticPixelQueue(image);
2689 if (image_view != (CacheView *) NULL)
2690 q=GetCacheViewAuthenticPixelQueue(image_view);
2691 for (x=0; x < (long) number_pixels; x++)
2699 if ((quantum_type == RGBOQuantum) || (quantum_type == CMYKOQuantum))
2701 register PixelPacket
2704 q=GetAuthenticPixelQueue(image);
2705 if (image_view != (CacheView *) NULL)
2706 q=GetCacheViewAuthenticPixelQueue(image_view);
2707 for (x=0; x < (long) number_pixels; x++)
2709 q->opacity=(Quantum) GetAlphaPixelComponent(q);
2713 if (quantum_info->alpha_type == DisassociatedQuantumAlpha)
2718 register PixelPacket
2724 q=GetAuthenticPixelQueue(image);
2725 if (image_view != (CacheView *) NULL)
2726 q=GetCacheViewAuthenticPixelQueue(image_view);
2727 for (x=0; x < (long) number_pixels; x++)
2729 alpha=QuantumScale*((MagickRealType) QuantumRange-q->opacity);
2730 alpha=1.0/(fabs(alpha) <= MagickEpsilon ? 1.0 : alpha);
2731 q->red=ClampToQuantum(alpha*q->red);
2732 q->green=ClampToQuantum(alpha*q->green);
2733 q->blue=ClampToQuantum(alpha*q->blue);