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 % EEEEE X X PPPP OOO RRRR TTTTT %
13 % E X X P P O O R R T %
14 % EEE X PPPP O O RRRR T %
16 % EEEEE X X P OOO R R T %
18 % MagickCore Methods to Export 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 + E x p o r t Q u a n t u m P i x e l s %
83 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
85 % ExportQuantumPixels() transfers one or more pixel components from the image
86 % pixel cache to a user supplied buffer. The pixels are returned in network
87 % byte order. MagickTrue is returned if the pixels are successfully
88 % transferred, otherwise MagickFalse.
90 % The format of the ExportQuantumPixels method is:
92 % size_t ExportQuantumPixels(const Image *image,const CacheView *image_view,
93 % const QuantumInfo *quantum_info,const QuantumType quantum_type,
94 % 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 (RGB, RGBA,
107 % o pixels: The components are transferred to this buffer.
109 % o exception: return any errors or warnings in this structure.
113 static inline unsigned char *PopDoublePixel(const QuantumState *quantum_state,
114 const double pixel,unsigned char *pixels)
122 p=(double *) quantum;
123 *p=(double) (pixel*quantum_state->inverse_scale+quantum_state->minimum);
124 if (quantum_state->endian != LSBEndian)
126 *pixels++=quantum[7];
127 *pixels++=quantum[6];
128 *pixels++=quantum[5];
129 *pixels++=quantum[4];
130 *pixels++=quantum[3];
131 *pixels++=quantum[2];
132 *pixels++=quantum[1];
133 *pixels++=quantum[0];
136 *pixels++=quantum[0];
137 *pixels++=quantum[1];
138 *pixels++=quantum[2];
139 *pixels++=quantum[3];
140 *pixels++=quantum[4];
141 *pixels++=quantum[5];
142 *pixels++=quantum[6];
143 *pixels++=quantum[7];
147 static inline unsigned char *PopFloatPixel(const QuantumState *quantum_state,
148 const float pixel,unsigned char *pixels)
157 *p=(float) ((double) pixel*quantum_state->inverse_scale+
158 quantum_state->minimum);
159 if (quantum_state->endian != LSBEndian)
161 *pixels++=quantum[3];
162 *pixels++=quantum[2];
163 *pixels++=quantum[1];
164 *pixels++=quantum[0];
167 *pixels++=quantum[0];
168 *pixels++=quantum[1];
169 *pixels++=quantum[2];
170 *pixels++=quantum[3];
174 static inline unsigned char *PopQuantumPixel(QuantumState *quantum_state,
175 const unsigned long depth,const QuantumAny pixel,unsigned char *pixels)
180 register unsigned long
183 if (quantum_state->bits == 0UL)
184 quantum_state->bits=8UL;
185 for (i=(long) depth; i > 0L; )
187 quantum_bits=(unsigned long) i;
188 if (quantum_bits > quantum_state->bits)
189 quantum_bits=quantum_state->bits;
191 if (quantum_state->bits == 8)
193 quantum_state->bits-=quantum_bits;
194 *pixels|=(((pixel >> i) &~ ((~0UL) << quantum_bits)) <<
195 quantum_state->bits);
196 if (quantum_state->bits == 0UL)
199 quantum_state->bits=8UL;
205 static inline unsigned char *PopQuantumLongPixel(QuantumState *quantum_state,
206 const unsigned long depth,const unsigned long pixel,unsigned char *pixels)
214 if (quantum_state->bits == 0UL)
215 quantum_state->bits=32UL;
216 for (i=(long) depth; i > 0; )
218 quantum_bits=(unsigned long) i;
219 if (quantum_bits > quantum_state->bits)
220 quantum_bits=quantum_state->bits;
221 quantum_state->pixel|=(((pixel >> (depth-i)) &
222 quantum_state->mask[quantum_bits]) << (32UL-quantum_state->bits));
224 quantum_state->bits-=quantum_bits;
225 if (quantum_state->bits == 0U)
227 pixels=PopLongPixel(quantum_state->endian,quantum_state->pixel,pixels);
228 quantum_state->pixel=0U;
229 quantum_state->bits=32UL;
235 MagickExport size_t ExportQuantumPixels(const Image *image,
236 const CacheView *image_view,const QuantumInfo *quantum_info,
237 const QuantumType quantum_type,unsigned char *pixels,ExceptionInfo *exception)
257 register const IndexPacket
260 register const PixelPacket
266 register unsigned char
272 assert(image != (Image *) NULL);
273 assert(image->signature == MagickSignature);
274 if (image->debug != MagickFalse)
275 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
276 assert(quantum_info != (QuantumInfo *) NULL);
277 assert(quantum_info->signature == MagickSignature);
278 if (pixels == (unsigned char *) NULL)
279 pixels=GetQuantumPixels(quantum_info);
280 number_pixels=GetImageExtent(image);
281 p=GetVirtualPixelQueue(image);
282 indexes=GetVirtualIndexQueue(image);
283 if (image_view != (CacheView *) NULL)
285 number_pixels=GetCacheViewExtent(image_view);
286 p=GetCacheViewVirtualPixelQueue(image_view);
287 indexes=GetCacheViewVirtualIndexQueue(image_view);
289 if (quantum_info->alpha_type == AssociatedQuantumAlpha)
297 q=GetAuthenticPixelQueue(image);
298 if (image_view != (CacheView *) NULL)
299 q=(PixelPacket *) GetCacheViewVirtualPixelQueue(image_view);
300 for (x=0; x < (long) image->columns; x++)
302 alpha=QuantumScale*((double) QuantumRange-q->opacity);
303 q->red=ClampToQuantum(alpha*q->red);
304 q->green=ClampToQuantum(alpha*q->green);
305 q->blue=ClampToQuantum(alpha*q->blue);
309 if ((quantum_type == RGBOQuantum) || (quantum_type == CMYKOQuantum))
314 q=GetAuthenticPixelQueue(image);
315 if (image_view != (CacheView *) NULL)
316 q=(PixelPacket *) GetCacheViewVirtualPixelQueue(image_view);
317 for (x=0; x < (long) number_pixels; x++)
319 q->opacity=(Quantum) GetAlphaPixelComponent(q);
323 if ((quantum_type == CbYCrQuantum) || (quantum_type == CbYCrAQuantum))
331 q=GetAuthenticPixelQueue(image);
332 if (image_view != (CacheView *) NULL)
333 q=GetAuthenticPixelQueue(image);
334 for (x=0; x < (long) number_pixels; x++)
344 InitializeQuantumState(quantum_info,image->endian,&quantum_state);
345 extent=GetQuantumExtent(image,quantum_info,quantum_type);
346 endian=quantum_state.endian;
347 switch (quantum_type)
351 if (image->storage_class != PseudoClass)
353 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
354 "ColormappedImageRequired","`%s'",image->filename);
357 switch (quantum_info->depth)
361 register unsigned char
364 for (x=((long) number_pixels-7); x > 0; x-=8)
366 pixel=(unsigned char) *indexes++;
367 *q=((pixel & 0x01) << 7);
368 pixel=(unsigned char) *indexes++;
369 *q|=((pixel & 0x01) << 6);
370 pixel=(unsigned char) *indexes++;
371 *q|=((pixel & 0x01) << 5);
372 pixel=(unsigned char) *indexes++;
373 *q|=((pixel & 0x01) << 4);
374 pixel=(unsigned char) *indexes++;
375 *q|=((pixel & 0x01) << 3);
376 pixel=(unsigned char) *indexes++;
377 *q|=((pixel & 0x01) << 2);
378 pixel=(unsigned char) *indexes++;
379 *q|=((pixel & 0x01) << 1);
380 pixel=(unsigned char) *indexes++;
381 *q|=((pixel & 0x01) << 0);
384 if ((number_pixels % 8) != 0)
387 for (bit=7; bit >= (long) (8-(number_pixels % 8)); bit--)
389 pixel=(unsigned char) *indexes++;
390 *q|=((pixel & 0x01) << (unsigned char) bit);
398 register unsigned char
401 for (x=0; x < (long) (number_pixels-1) ; x+=2)
403 pixel=(unsigned char) *indexes++;
404 *q=((pixel & 0xf) << 4);
405 pixel=(unsigned char) *indexes++;
406 *q|=((pixel & 0xf) << 0);
409 if ((number_pixels % 2) != 0)
411 pixel=(unsigned char) *indexes++;
412 *q=((pixel & 0xf) << 4);
419 for (x=0; x < (long) number_pixels; x++)
421 q=PopCharPixel((unsigned char) indexes[x],q);
422 q+=quantum_info->pad;
428 if (quantum_info->format == FloatingPointQuantumFormat)
430 for (x=0; x < (long) number_pixels; x++)
432 q=PopShortPixel(endian,ScaleFloatToHalf(QuantumScale*
434 q+=quantum_info->pad;
438 for (x=0; x < (long) number_pixels; x++)
440 q=PopShortPixel(endian,(unsigned short) indexes[x],q);
441 q+=quantum_info->pad;
447 if (quantum_info->format == FloatingPointQuantumFormat)
449 for (x=0; x < (long) number_pixels; x++)
451 q=PopFloatPixel(&quantum_state,(float) indexes[x],q);
453 q+=quantum_info->pad;
457 for (x=0; x < (long) number_pixels; x++)
459 q=PopLongPixel(endian,(unsigned long) indexes[x],q);
460 q+=quantum_info->pad;
466 if (quantum_info->format == FloatingPointQuantumFormat)
468 for (x=0; x < (long) number_pixels; x++)
470 q=PopDoublePixel(&quantum_state,(double) indexes[x],q);
472 q+=quantum_info->pad;
479 for (x=0; x < (long) number_pixels; x++)
481 q=PopQuantumPixel(&quantum_state,image->depth,indexes[x],q);
483 q+=quantum_info->pad;
490 case IndexAlphaQuantum:
492 if (image->storage_class != PseudoClass)
494 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
495 "ColormappedImageRequired","`%s'",image->filename);
498 switch (quantum_info->depth)
502 register unsigned char
505 for (x=((long) number_pixels-3); x > 0; x-=4)
507 pixel=(unsigned char) *indexes++;
508 *q=((pixel & 0x01) << 7);
509 pixel=(unsigned char) (p->opacity == (Quantum) TransparentOpacity ?
511 *q|=((pixel & 0x01) << 6);
513 pixel=(unsigned char) *indexes++;
514 *q|=((pixel & 0x01) << 5);
515 pixel=(unsigned char) (p->opacity == (Quantum) TransparentOpacity ?
517 *q|=((pixel & 0x01) << 4);
519 pixel=(unsigned char) *indexes++;
520 *q|=((pixel & 0x01) << 3);
521 pixel=(unsigned char) (p->opacity == (Quantum) TransparentOpacity ?
523 *q|=((pixel & 0x01) << 2);
525 pixel=(unsigned char) *indexes++;
526 *q|=((pixel & 0x01) << 1);
527 pixel=(unsigned char) (p->opacity == (Quantum) TransparentOpacity ?
529 *q|=((pixel & 0x01) << 0);
533 if ((number_pixels % 4) != 0)
536 for (bit=3; bit >= (long) (4-(number_pixels % 4)); bit-=2)
538 pixel=(unsigned char) *indexes++;
539 *q|=((pixel & 0x01) << (unsigned char) (bit+4));
540 pixel=(unsigned char) (p->opacity == (Quantum)
541 TransparentOpacity ? 1 : 0);
542 *q|=((pixel & 0x01) << (unsigned char) (bit+4-1));
551 register unsigned char
554 for (x=0; x < (long) number_pixels ; x++)
556 pixel=(unsigned char) *indexes++;
557 *q=((pixel & 0xf) << 4);
558 pixel=(unsigned char) (16*QuantumScale*((Quantum) (QuantumRange-
559 GetOpacityPixelComponent(p)))+0.5);
560 *q|=((pixel & 0xf) << 0);
568 register unsigned char
571 for (x=0; x < (long) number_pixels; x++)
573 q=PopCharPixel((unsigned char) indexes[x],q);
574 pixel=ScaleQuantumToChar((Quantum) (QuantumRange-
575 GetOpacityPixelComponent(p)));
576 q=PopCharPixel(pixel,q);
578 q+=quantum_info->pad;
584 register unsigned short
587 if (quantum_info->format == FloatingPointQuantumFormat)
589 for (x=0; x < (long) number_pixels; x++)
591 q=PopShortPixel(endian,(unsigned short) indexes[x],q);
592 pixel=ScaleFloatToHalf(QuantumScale*(QuantumRange-
593 GetOpacityPixelComponent(p)));
594 q=PopShortPixel(endian,pixel,q);
596 q+=quantum_info->pad;
600 for (x=0; x < (long) number_pixels; x++)
602 q=PopShortPixel(endian,(unsigned short) indexes[x],q);
603 pixel=ScaleQuantumToShort((Quantum) (QuantumRange-
604 GetOpacityPixelComponent(p)));
605 q=PopShortPixel(endian,pixel,q);
607 q+=quantum_info->pad;
613 register unsigned long
616 if (quantum_info->format == FloatingPointQuantumFormat)
618 for (x=0; x < (long) number_pixels; x++)
623 q=PopFloatPixel(&quantum_state,(float) indexes[x],q);
624 pixel=(float) (GetAlphaPixelComponent(p));
625 q=PopFloatPixel(&quantum_state,pixel,q);
627 q+=quantum_info->pad;
631 for (x=0; x < (long) number_pixels; x++)
633 q=PopLongPixel(endian,(unsigned long) indexes[x],q);
634 pixel=ScaleQuantumToLong((Quantum) (QuantumRange-
635 GetOpacityPixelComponent(p)));
636 q=PopLongPixel(endian,pixel,q);
638 q+=quantum_info->pad;
644 if (quantum_info->format == FloatingPointQuantumFormat)
646 for (x=0; x < (long) number_pixels; x++)
651 q=PopDoublePixel(&quantum_state,(double) indexes[x],q);
652 pixel=(double) (GetAlphaPixelComponent(p));
653 q=PopDoublePixel(&quantum_state,pixel,q);
655 q+=quantum_info->pad;
662 range=GetQuantumRange(image->depth);
663 for (x=0; x < (long) number_pixels; x++)
665 q=PopQuantumPixel(&quantum_state,image->depth,indexes[x],q);
666 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
667 (Quantum) (GetAlphaPixelComponent(p)),range),q);
669 q+=quantum_info->pad;
678 switch (quantum_info->depth)
685 register unsigned char
691 if (quantum_info->min_is_white != MagickFalse)
696 threshold=(Quantum) (QuantumRange/2);
697 for (x=((long) number_pixels-7); x > 0; x-=8)
700 *q|=(PixelIntensityToQuantum(p) < threshold ? black : white) << 7;
702 *q|=(PixelIntensityToQuantum(p) < threshold ? black : white) << 6;
704 *q|=(PixelIntensityToQuantum(p) < threshold ? black : white) << 5;
706 *q|=(PixelIntensityToQuantum(p) < threshold ? black : white) << 4;
708 *q|=(PixelIntensityToQuantum(p) < threshold ? black : white) << 3;
710 *q|=(PixelIntensityToQuantum(p) < threshold ? black : white) << 2;
712 *q|=(PixelIntensityToQuantum(p) < threshold ? black : white) << 1;
714 *q|=(PixelIntensityToQuantum(p) < threshold ? black : white) << 0;
718 if ((number_pixels % 8) != 0)
721 for (bit=7; bit >= (long) (8-(number_pixels % 8)); bit--)
723 *q|=(PixelIntensityToQuantum(p) < threshold ? black : white) <<
733 register unsigned char
736 for (x=0; x < (long) (number_pixels-1) ; x+=2)
738 pixel=ScaleQuantumToChar(PixelIntensityToQuantum(p));
739 *q=(((pixel >> 4) & 0xf) << 4);
741 pixel=ScaleQuantumToChar(PixelIntensityToQuantum(p));
746 if ((number_pixels % 2) != 0)
748 pixel=ScaleQuantumToChar(PixelIntensityToQuantum(p));
749 *q=(((pixel >> 4) & 0xf) << 4);
757 register unsigned char
760 for (x=0; x < (long) number_pixels; x++)
762 pixel=ScaleQuantumToChar(PixelIntensityToQuantum(p));
763 q=PopCharPixel(pixel,q);
765 q+=quantum_info->pad;
771 register unsigned short
774 range=GetQuantumRange(image->depth);
775 if (quantum_info->pack == MagickFalse)
777 for (x=0; x < (long) number_pixels; x++)
779 pixel=ScaleQuantumToShort(PixelIntensityToQuantum(p));
780 q=PopShortPixel(endian,(unsigned short) ScaleQuantumToAny(
781 (Quantum) pixel,range),q);
783 q+=quantum_info->pad;
787 for (x=0; x < (long) number_pixels; x++)
789 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
790 PixelIntensityToQuantum(p),range),q);
792 q+=quantum_info->pad;
798 register unsigned short
801 range=GetQuantumRange(image->depth);
802 if (quantum_info->pack == MagickFalse)
804 for (x=0; x < (long) number_pixels; x++)
806 pixel=ScaleQuantumToShort(PixelIntensityToQuantum(p));
807 q=PopShortPixel(endian,(unsigned short) (pixel >> 4),q);
809 q+=quantum_info->pad;
813 for (x=0; x < (long) number_pixels; x++)
815 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
816 PixelIntensityToQuantum(p),range),q);
818 q+=quantum_info->pad;
824 register unsigned short
827 if (quantum_info->format == FloatingPointQuantumFormat)
829 for (x=0; x < (long) number_pixels; x++)
831 pixel=ScaleFloatToHalf(QuantumScale*PixelIntensityToQuantum(p));
832 q=PopShortPixel(endian,pixel,q);
834 q+=quantum_info->pad;
838 for (x=0; x < (long) number_pixels; x++)
840 pixel=ScaleQuantumToShort(PixelIntensityToQuantum(p));
841 q=PopShortPixel(endian,pixel,q);
843 q+=quantum_info->pad;
849 register unsigned long
852 if (quantum_info->format == FloatingPointQuantumFormat)
854 for (x=0; x < (long) number_pixels; x++)
859 pixel=(float) PixelIntensityToQuantum(p);
860 q=PopFloatPixel(&quantum_state,pixel,q);
862 q+=quantum_info->pad;
866 for (x=0; x < (long) number_pixels; x++)
868 pixel=ScaleQuantumToLong(PixelIntensityToQuantum(p));
869 q=PopLongPixel(endian,pixel,q);
871 q+=quantum_info->pad;
877 if (quantum_info->format == FloatingPointQuantumFormat)
879 for (x=0; x < (long) number_pixels; x++)
884 pixel=(double) PixelIntensityToQuantum(p);
885 q=PopDoublePixel(&quantum_state,pixel,q);
887 q+=quantum_info->pad;
894 range=GetQuantumRange(image->depth);
895 for (x=0; x < (long) number_pixels; x++)
897 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
898 PixelIntensityToQuantum(p),range),q);
900 q+=quantum_info->pad;
907 case GrayAlphaQuantum:
909 switch (quantum_info->depth)
916 register unsigned char
923 if (quantum_info->min_is_white == MagickFalse)
928 threshold=(Quantum) (QuantumRange/2);
929 for (x=((long) number_pixels-3); x > 0; x-=4)
932 *q|=(PixelIntensityToQuantum(p) < threshold ? black : white) << 7;
933 pixel=(unsigned char) (p->opacity == OpaqueOpacity ? 0x00 : 0x01);
934 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 6);
936 *q|=(PixelIntensityToQuantum(p) < threshold ? black : white) << 5;
937 pixel=(unsigned char) (p->opacity == OpaqueOpacity ? 0x00 : 0x01);
938 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 4);
940 *q|=(PixelIntensityToQuantum(p) < threshold ? black : white) << 3;
941 pixel=(unsigned char) (p->opacity == OpaqueOpacity ? 0x00 : 0x01);
942 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 2);
944 *q|=(PixelIntensityToQuantum(p) < threshold ? black : white) << 1;
945 pixel=(unsigned char) (p->opacity == OpaqueOpacity ? 0x00 : 0x01);
946 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 0);
950 if ((number_pixels % 4) != 0)
953 for (bit=3; bit >= (long) (4-(number_pixels % 4)); bit-=2)
955 *q|=(PixelIntensityToQuantum(p) < threshold ? black : white) <<
957 pixel=(unsigned char) (p->opacity == OpaqueOpacity ? 0x00 :
959 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << (unsigned char)
969 register unsigned char
972 for (x=0; x < (long) number_pixels ; x++)
974 pixel=ScaleQuantumToChar(PixelIntensityToQuantum(p));
975 *q=(((pixel >> 4) & 0xf) << 4);
976 pixel=(unsigned char) (16*QuantumScale*((Quantum) (QuantumRange-
977 GetOpacityPixelComponent(p)))+0.5);
986 register unsigned char
989 for (x=0; x < (long) number_pixels; x++)
991 pixel=ScaleQuantumToChar(PixelIntensityToQuantum(p));
992 q=PopCharPixel(pixel,q);
993 pixel=ScaleQuantumToChar((Quantum) (QuantumRange-
994 GetOpacityPixelComponent(p)));
995 q=PopCharPixel(pixel,q);
997 q+=quantum_info->pad;
1003 register unsigned short
1006 if (quantum_info->format == FloatingPointQuantumFormat)
1008 for (x=0; x < (long) number_pixels; x++)
1010 pixel=ScaleFloatToHalf(QuantumScale*PixelIntensityToQuantum(p));
1011 q=PopShortPixel(endian,pixel,q);
1012 pixel=ScaleFloatToHalf(QuantumScale*(QuantumRange-
1013 GetOpacityPixelComponent(p)));
1014 q=PopShortPixel(endian,pixel,q);
1016 q+=quantum_info->pad;
1020 for (x=0; x < (long) number_pixels; x++)
1022 pixel=ScaleQuantumToShort(PixelIntensityToQuantum(p));
1023 q=PopShortPixel(endian,pixel,q);
1024 pixel=ScaleQuantumToShort((Quantum) (QuantumRange-
1025 GetOpacityPixelComponent(p)));
1026 q=PopShortPixel(endian,pixel,q);
1028 q+=quantum_info->pad;
1034 register unsigned long
1037 if (quantum_info->format == FloatingPointQuantumFormat)
1039 for (x=0; x < (long) number_pixels; x++)
1044 pixel=(float) PixelIntensityToQuantum(p);
1045 q=PopFloatPixel(&quantum_state,pixel,q);
1046 pixel=(float) (GetAlphaPixelComponent(p));
1047 q=PopFloatPixel(&quantum_state,pixel,q);
1049 q+=quantum_info->pad;
1053 for (x=0; x < (long) number_pixels; x++)
1055 pixel=ScaleQuantumToLong(PixelIntensityToQuantum(p));
1056 q=PopLongPixel(endian,pixel,q);
1057 pixel=ScaleQuantumToLong((Quantum) (QuantumRange-
1058 GetOpacityPixelComponent(p)));
1059 q=PopLongPixel(endian,pixel,q);
1061 q+=quantum_info->pad;
1067 if (quantum_info->format == FloatingPointQuantumFormat)
1069 for (x=0; x < (long) number_pixels; x++)
1074 pixel=(double) PixelIntensityToQuantum(p);
1075 q=PopDoublePixel(&quantum_state,pixel,q);
1076 pixel=(double) (GetAlphaPixelComponent(p));
1077 q=PopDoublePixel(&quantum_state,pixel,q);
1079 q+=quantum_info->pad;
1086 range=GetQuantumRange(image->depth);
1087 for (x=0; x < (long) number_pixels; x++)
1089 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
1090 PixelIntensityToQuantum(p),range),q);
1091 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
1092 (Quantum) (GetAlphaPixelComponent(p)),range),q);
1094 q+=quantum_info->pad;
1104 switch (quantum_info->depth)
1108 register unsigned char
1111 for (x=0; x < (long) number_pixels; x++)
1113 pixel=ScaleQuantumToChar(GetRedPixelComponent(p));
1114 q=PopCharPixel(pixel,q);
1116 q+=quantum_info->pad;
1122 register unsigned short
1125 if (quantum_info->format == FloatingPointQuantumFormat)
1127 for (x=0; x < (long) number_pixels; x++)
1129 pixel=ScaleFloatToHalf(QuantumScale*GetRedPixelComponent(p));
1130 q=PopShortPixel(endian,pixel,q);
1132 q+=quantum_info->pad;
1136 for (x=0; x < (long) number_pixels; x++)
1138 pixel=ScaleQuantumToShort(GetRedPixelComponent(p));
1139 q=PopShortPixel(endian,pixel,q);
1141 q+=quantum_info->pad;
1147 register unsigned long
1150 if (quantum_info->format == FloatingPointQuantumFormat)
1152 for (x=0; x < (long) number_pixels; x++)
1154 q=PopFloatPixel(&quantum_state,(float) p->red,q);
1156 q+=quantum_info->pad;
1160 for (x=0; x < (long) number_pixels; x++)
1162 pixel=ScaleQuantumToLong(GetRedPixelComponent(p));
1163 q=PopLongPixel(endian,pixel,q);
1165 q+=quantum_info->pad;
1171 if (quantum_info->format == FloatingPointQuantumFormat)
1173 for (x=0; x < (long) number_pixels; x++)
1175 q=PopDoublePixel(&quantum_state,(double) p->red,q);
1177 q+=quantum_info->pad;
1184 range=GetQuantumRange(image->depth);
1185 for (x=0; x < (long) number_pixels; x++)
1187 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
1190 q+=quantum_info->pad;
1198 case MagentaQuantum:
1200 switch (quantum_info->depth)
1204 register unsigned char
1207 for (x=0; x < (long) number_pixels; x++)
1209 pixel=ScaleQuantumToChar(GetGreenPixelComponent(p));
1210 q=PopCharPixel(pixel,q);
1212 q+=quantum_info->pad;
1218 register unsigned short
1221 if (quantum_info->format == FloatingPointQuantumFormat)
1223 for (x=0; x < (long) number_pixels; x++)
1225 pixel=ScaleFloatToHalf(QuantumScale*GetGreenPixelComponent(p));
1226 q=PopShortPixel(endian,pixel,q);
1228 q+=quantum_info->pad;
1232 for (x=0; x < (long) number_pixels; x++)
1234 pixel=ScaleQuantumToShort(GetGreenPixelComponent(p));
1235 q=PopShortPixel(endian,pixel,q);
1237 q+=quantum_info->pad;
1243 register unsigned long
1246 if (quantum_info->format == FloatingPointQuantumFormat)
1248 for (x=0; x < (long) number_pixels; x++)
1250 q=PopFloatPixel(&quantum_state,(float) p->green,q);
1252 q+=quantum_info->pad;
1256 for (x=0; x < (long) number_pixels; x++)
1258 pixel=ScaleQuantumToLong(GetGreenPixelComponent(p));
1259 q=PopLongPixel(endian,pixel,q);
1261 q+=quantum_info->pad;
1267 if (quantum_info->format == FloatingPointQuantumFormat)
1269 for (x=0; x < (long) number_pixels; x++)
1271 q=PopDoublePixel(&quantum_state,(double) p->green,q);
1273 q+=quantum_info->pad;
1280 range=GetQuantumRange(image->depth);
1281 for (x=0; x < (long) number_pixels; x++)
1283 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
1286 q+=quantum_info->pad;
1296 switch (quantum_info->depth)
1300 register unsigned char
1303 for (x=0; x < (long) number_pixels; x++)
1305 pixel=ScaleQuantumToChar(GetBluePixelComponent(p));
1306 q=PopCharPixel(pixel,q);
1308 q+=quantum_info->pad;
1314 register unsigned short
1317 if (quantum_info->format == FloatingPointQuantumFormat)
1319 for (x=0; x < (long) number_pixels; x++)
1321 pixel=ScaleFloatToHalf(QuantumScale*GetBluePixelComponent(p));
1322 q=PopShortPixel(endian,pixel,q);
1324 q+=quantum_info->pad;
1328 for (x=0; x < (long) number_pixels; x++)
1330 pixel=ScaleQuantumToShort(GetBluePixelComponent(p));
1331 q=PopShortPixel(endian,pixel,q);
1333 q+=quantum_info->pad;
1339 register unsigned long
1342 if (quantum_info->format == FloatingPointQuantumFormat)
1344 for (x=0; x < (long) number_pixels; x++)
1346 q=PopFloatPixel(&quantum_state,(float) p->blue,q);
1348 q+=quantum_info->pad;
1352 for (x=0; x < (long) number_pixels; x++)
1354 pixel=ScaleQuantumToLong(GetBluePixelComponent(p));
1355 q=PopLongPixel(endian,pixel,q);
1357 q+=quantum_info->pad;
1363 if (quantum_info->format == FloatingPointQuantumFormat)
1365 for (x=0; x < (long) number_pixels; x++)
1367 q=PopDoublePixel(&quantum_state,(double) p->blue,q);
1369 q+=quantum_info->pad;
1376 range=GetQuantumRange(image->depth);
1377 for (x=0; x < (long) number_pixels; x++)
1379 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
1382 q+=quantum_info->pad;
1391 switch (quantum_info->depth)
1395 register unsigned char
1398 for (x=0; x < (long) number_pixels; x++)
1400 pixel=ScaleQuantumToChar((Quantum) (QuantumRange-
1401 GetOpacityPixelComponent(p)));
1402 q=PopCharPixel(pixel,q);
1404 q+=quantum_info->pad;
1410 register unsigned short
1413 if (quantum_info->format == FloatingPointQuantumFormat)
1415 for (x=0; x < (long) number_pixels; x++)
1417 pixel=ScaleFloatToHalf(QuantumScale*(QuantumRange-
1418 GetOpacityPixelComponent(p)));
1419 q=PopShortPixel(endian,pixel,q);
1421 q+=quantum_info->pad;
1425 for (x=0; x < (long) number_pixels; x++)
1427 pixel=ScaleQuantumToShort((Quantum) (QuantumRange-
1428 GetOpacityPixelComponent(p)));
1429 q=PopShortPixel(endian,pixel,q);
1431 q+=quantum_info->pad;
1437 register unsigned long
1440 if (quantum_info->format == FloatingPointQuantumFormat)
1442 for (x=0; x < (long) number_pixels; x++)
1447 pixel=(float) (GetAlphaPixelComponent(p));
1448 q=PopFloatPixel(&quantum_state,pixel,q);
1450 q+=quantum_info->pad;
1454 for (x=0; x < (long) number_pixels; x++)
1456 pixel=ScaleQuantumToLong((Quantum) (QuantumRange-
1457 GetOpacityPixelComponent(p)));
1458 q=PopLongPixel(endian,pixel,q);
1460 q+=quantum_info->pad;
1466 if (quantum_info->format == FloatingPointQuantumFormat)
1468 for (x=0; x < (long) number_pixels; x++)
1473 pixel=(double) (GetAlphaPixelComponent(p));
1474 q=PopDoublePixel(&quantum_state,pixel,q);
1476 q+=quantum_info->pad;
1483 range=GetQuantumRange(image->depth);
1484 for (x=0; x < (long) number_pixels; x++)
1486 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
1487 (Quantum) (GetAlphaPixelComponent(p)),range),q);
1489 q+=quantum_info->pad;
1496 case OpacityQuantum:
1498 switch (quantum_info->depth)
1502 register unsigned char
1505 for (x=0; x < (long) number_pixels; x++)
1507 pixel=ScaleQuantumToChar(GetOpacityPixelComponent(p));
1508 q=PopCharPixel(pixel,q);
1510 q+=quantum_info->pad;
1516 register unsigned short
1519 if (quantum_info->format == FloatingPointQuantumFormat)
1521 for (x=0; x < (long) number_pixels; x++)
1523 pixel=ScaleFloatToHalf(QuantumScale*GetOpacityPixelComponent(p));
1524 q=PopShortPixel(endian,pixel,q);
1526 q+=quantum_info->pad;
1530 for (x=0; x < (long) number_pixels; x++)
1532 pixel=ScaleQuantumToShort(GetOpacityPixelComponent(p));
1533 q=PopShortPixel(endian,pixel,q);
1535 q+=quantum_info->pad;
1541 register unsigned long
1544 if (quantum_info->format == FloatingPointQuantumFormat)
1546 for (x=0; x < (long) number_pixels; x++)
1548 q=PopFloatPixel(&quantum_state,(float) p->opacity,q);
1550 q+=quantum_info->pad;
1554 for (x=0; x < (long) number_pixels; x++)
1556 pixel=ScaleQuantumToLong(GetOpacityPixelComponent(p));
1557 q=PopLongPixel(endian,pixel,q);
1559 q+=quantum_info->pad;
1565 if (quantum_info->format == FloatingPointQuantumFormat)
1567 for (x=0; x < (long) number_pixels; x++)
1569 q=PopDoublePixel(&quantum_state,(double) p->opacity,q);
1571 q+=quantum_info->pad;
1578 range=GetQuantumRange(image->depth);
1579 for (x=0; x < (long) number_pixels; x++)
1581 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
1582 p->opacity,range),q);
1584 q+=quantum_info->pad;
1593 if (image->colorspace != CMYKColorspace)
1595 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1596 "ColorSeparatedImageRequired","`%s'",image->filename);
1599 switch (quantum_info->depth)
1603 register unsigned char
1606 for (x=0; x < (long) number_pixels; x++)
1608 pixel=ScaleQuantumToChar(indexes[x]);
1609 q=PopCharPixel(pixel,q);
1611 q+=quantum_info->pad;
1617 register unsigned short
1620 if (quantum_info->format == FloatingPointQuantumFormat)
1622 for (x=0; x < (long) number_pixels; x++)
1624 pixel=ScaleFloatToHalf(QuantumScale*indexes[x]);
1625 q=PopShortPixel(endian,pixel,q);
1627 q+=quantum_info->pad;
1631 for (x=0; x < (long) number_pixels; x++)
1633 pixel=ScaleQuantumToShort(indexes[x]);
1634 q=PopShortPixel(endian,pixel,q);
1636 q+=quantum_info->pad;
1642 register unsigned long
1645 if (quantum_info->format == FloatingPointQuantumFormat)
1647 for (x=0; x < (long) number_pixels; x++)
1649 q=PopFloatPixel(&quantum_state,(float) indexes[x],q);
1651 q+=quantum_info->pad;
1655 for (x=0; x < (long) number_pixels; x++)
1657 pixel=ScaleQuantumToLong(indexes[x]);
1658 q=PopLongPixel(endian,pixel,q);
1660 q+=quantum_info->pad;
1666 if (quantum_info->format == FloatingPointQuantumFormat)
1668 for (x=0; x < (long) number_pixels; x++)
1670 q=PopDoublePixel(&quantum_state,(double) indexes[x],q);
1672 q+=quantum_info->pad;
1679 range=GetQuantumRange(image->depth);
1680 for (x=0; x < (long) number_pixels; x++)
1682 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
1683 (Quantum) indexes[x],range),q);
1685 q+=quantum_info->pad;
1695 switch (quantum_info->depth)
1699 for (x=0; x < (long) number_pixels; x++)
1701 q=PopCharPixel(ScaleQuantumToChar(GetRedPixelComponent(p)),q);
1702 q=PopCharPixel(ScaleQuantumToChar(GetGreenPixelComponent(p)),q);
1703 q=PopCharPixel(ScaleQuantumToChar(GetBluePixelComponent(p)),q);
1705 q+=quantum_info->pad;
1711 register unsigned long
1714 range=GetQuantumRange(image->depth);
1715 if (quantum_info->pack == MagickFalse)
1717 for (x=0; x < (long) number_pixels; x++)
1719 pixel=(unsigned long) (ScaleQuantumToAny(p->red,range) << 22 |
1720 ScaleQuantumToAny(p->green,range) << 12 |
1721 ScaleQuantumToAny(p->blue,range) << 2);
1722 q=PopLongPixel(endian,pixel,q);
1724 q+=quantum_info->pad;
1728 if (quantum_info->quantum == 32UL)
1730 for (x=0; x < (long) number_pixels; x++)
1732 pixel=(unsigned long) ScaleQuantumToAny(p->red,range);
1733 q=PopQuantumLongPixel(&quantum_state,image->depth,pixel,q);
1734 pixel=(unsigned long) ScaleQuantumToAny(p->green,range);
1735 q=PopQuantumLongPixel(&quantum_state,image->depth,pixel,q);
1736 pixel=(unsigned long) ScaleQuantumToAny(p->blue,range);
1737 q=PopQuantumLongPixel(&quantum_state,image->depth,pixel,q);
1739 q+=quantum_info->pad;
1743 for (x=0; x < (long) number_pixels; x++)
1745 pixel=(unsigned long) ScaleQuantumToAny(p->red,range);
1746 q=PopQuantumPixel(&quantum_state,image->depth,pixel,q);
1747 pixel=(unsigned long) ScaleQuantumToAny(p->green,range);
1748 q=PopQuantumPixel(&quantum_state,image->depth,pixel,q);
1749 pixel=(unsigned long) ScaleQuantumToAny(p->blue,range);
1750 q=PopQuantumPixel(&quantum_state,image->depth,pixel,q);
1752 q+=quantum_info->pad;
1758 register unsigned long
1761 range=GetQuantumRange(image->depth);
1762 if (quantum_info->pack == MagickFalse)
1764 for (x=0; x < (long) (3*number_pixels-1); x+=2)
1771 pixel=(unsigned long) ScaleQuantumToAny(p->red,range);
1776 pixel=(unsigned long) ScaleQuantumToAny(p->green,range);
1781 pixel=(unsigned long) ScaleQuantumToAny(p->blue,range);
1786 q=PopShortPixel(endian,(unsigned short) (pixel << 4),q);
1792 pixel=(unsigned long) ScaleQuantumToAny(p->red,range);
1797 pixel=(unsigned long) ScaleQuantumToAny(p->green,range);
1802 pixel=(unsigned long) ScaleQuantumToAny(p->blue,range);
1807 q=PopShortPixel(endian,(unsigned short) (pixel << 4),q);
1808 q+=quantum_info->pad;
1810 for (bit=0; bit < (long) (3*number_pixels % 2); bit++)
1812 switch ((x+bit) % 3)
1817 pixel=(unsigned long) ScaleQuantumToAny(p->red,range);
1822 pixel=(unsigned long) ScaleQuantumToAny(p->green,range);
1827 pixel=(unsigned long) ScaleQuantumToAny(p->blue,range);
1832 q=PopShortPixel(endian,(unsigned short) (pixel << 4),q);
1833 q+=quantum_info->pad;
1839 if (quantum_info->quantum == 32UL)
1841 for (x=0; x < (long) number_pixels; x++)
1843 pixel=(unsigned long) ScaleQuantumToAny(p->red,range);
1844 q=PopQuantumLongPixel(&quantum_state,image->depth,pixel,q);
1845 pixel=(unsigned long) ScaleQuantumToAny(p->green,range);
1846 q=PopQuantumLongPixel(&quantum_state,image->depth,pixel,q);
1847 pixel=(unsigned long) ScaleQuantumToAny(p->blue,range);
1848 q=PopQuantumLongPixel(&quantum_state,image->depth,pixel,q);
1850 q+=quantum_info->pad;
1854 for (x=0; x < (long) number_pixels; x++)
1856 pixel=(unsigned long) ScaleQuantumToAny(p->red,range);
1857 q=PopQuantumPixel(&quantum_state,image->depth,pixel,q);
1858 pixel=(unsigned long) ScaleQuantumToAny(p->green,range);
1859 q=PopQuantumPixel(&quantum_state,image->depth,pixel,q);
1860 pixel=(unsigned long) ScaleQuantumToAny(p->blue,range);
1861 q=PopQuantumPixel(&quantum_state,image->depth,pixel,q);
1863 q+=quantum_info->pad;
1869 register unsigned short
1872 if (quantum_info->format == FloatingPointQuantumFormat)
1874 for (x=0; x < (long) number_pixels; x++)
1876 pixel=ScaleFloatToHalf(QuantumScale*GetRedPixelComponent(p));
1877 q=PopShortPixel(endian,pixel,q);
1878 pixel=ScaleFloatToHalf(QuantumScale*GetGreenPixelComponent(p));
1879 q=PopShortPixel(endian,pixel,q);
1880 pixel=ScaleFloatToHalf(QuantumScale*GetBluePixelComponent(p));
1881 q=PopShortPixel(endian,pixel,q);
1883 q+=quantum_info->pad;
1887 for (x=0; x < (long) number_pixels; x++)
1889 pixel=ScaleQuantumToShort(GetRedPixelComponent(p));
1890 q=PopShortPixel(endian,pixel,q);
1891 pixel=ScaleQuantumToShort(GetGreenPixelComponent(p));
1892 q=PopShortPixel(endian,pixel,q);
1893 pixel=ScaleQuantumToShort(GetBluePixelComponent(p));
1894 q=PopShortPixel(endian,pixel,q);
1896 q+=quantum_info->pad;
1902 register unsigned long
1905 if (quantum_info->format == FloatingPointQuantumFormat)
1907 for (x=0; x < (long) number_pixels; x++)
1909 q=PopFloatPixel(&quantum_state,(float) p->red,q);
1910 q=PopFloatPixel(&quantum_state,(float) p->green,q);
1911 q=PopFloatPixel(&quantum_state,(float) p->blue,q);
1913 q+=quantum_info->pad;
1917 for (x=0; x < (long) number_pixels; x++)
1919 pixel=ScaleQuantumToLong(GetRedPixelComponent(p));
1920 q=PopLongPixel(endian,pixel,q);
1921 pixel=ScaleQuantumToLong(GetGreenPixelComponent(p));
1922 q=PopLongPixel(endian,pixel,q);
1923 pixel=ScaleQuantumToLong(GetBluePixelComponent(p));
1924 q=PopLongPixel(endian,pixel,q);
1926 q+=quantum_info->pad;
1932 if (quantum_info->format == FloatingPointQuantumFormat)
1934 for (x=0; x < (long) number_pixels; x++)
1936 q=PopDoublePixel(&quantum_state,(double) p->red,q);
1937 q=PopDoublePixel(&quantum_state,(double) p->green,q);
1938 q=PopDoublePixel(&quantum_state,(double) p->blue,q);
1940 q+=quantum_info->pad;
1947 range=GetQuantumRange(image->depth);
1948 for (x=0; x < (long) number_pixels; x++)
1950 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
1952 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
1954 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
1957 q+=quantum_info->pad;
1968 switch (quantum_info->depth)
1972 register unsigned char
1975 for (x=0; x < (long) number_pixels; x++)
1977 pixel=ScaleQuantumToChar(GetRedPixelComponent(p));
1978 q=PopCharPixel(pixel,q);
1979 pixel=ScaleQuantumToChar(GetGreenPixelComponent(p));
1980 q=PopCharPixel(pixel,q);
1981 pixel=ScaleQuantumToChar(GetBluePixelComponent(p));
1982 q=PopCharPixel(pixel,q);
1983 pixel=ScaleQuantumToChar((Quantum) (QuantumRange-
1984 GetOpacityPixelComponent(p)));
1985 q=PopCharPixel(pixel,q);
1987 q+=quantum_info->pad;
1993 register unsigned short
1996 if (quantum_info->format == FloatingPointQuantumFormat)
1998 for (x=0; x < (long) number_pixels; x++)
2000 pixel=ScaleFloatToHalf(QuantumScale*GetRedPixelComponent(p));
2001 q=PopShortPixel(endian,pixel,q);
2002 pixel=ScaleFloatToHalf(QuantumScale*GetGreenPixelComponent(p));
2003 q=PopShortPixel(endian,pixel,q);
2004 pixel=ScaleFloatToHalf(QuantumScale*GetBluePixelComponent(p));
2005 q=PopShortPixel(endian,pixel,q);
2006 pixel=ScaleFloatToHalf(QuantumScale*(QuantumRange-
2007 GetOpacityPixelComponent(p)));
2008 q=PopShortPixel(endian,pixel,q);
2010 q+=quantum_info->pad;
2014 for (x=0; x < (long) number_pixels; x++)
2016 pixel=ScaleQuantumToShort(GetRedPixelComponent(p));
2017 q=PopShortPixel(endian,pixel,q);
2018 pixel=ScaleQuantumToShort(GetGreenPixelComponent(p));
2019 q=PopShortPixel(endian,pixel,q);
2020 pixel=ScaleQuantumToShort(GetBluePixelComponent(p));
2021 q=PopShortPixel(endian,pixel,q);
2022 pixel=ScaleQuantumToShort((Quantum) (QuantumRange-
2023 GetOpacityPixelComponent(p)));
2024 q=PopShortPixel(endian,pixel,q);
2026 q+=quantum_info->pad;
2032 register unsigned long
2035 if (quantum_info->format == FloatingPointQuantumFormat)
2037 for (x=0; x < (long) number_pixels; x++)
2042 q=PopFloatPixel(&quantum_state,(float) p->red,q);
2043 q=PopFloatPixel(&quantum_state,(float) p->green,q);
2044 q=PopFloatPixel(&quantum_state,(float) p->blue,q);
2045 pixel=(float) (GetAlphaPixelComponent(p));
2046 q=PopFloatPixel(&quantum_state,pixel,q);
2048 q+=quantum_info->pad;
2052 for (x=0; x < (long) number_pixels; x++)
2054 pixel=ScaleQuantumToLong(GetRedPixelComponent(p));
2055 q=PopLongPixel(endian,pixel,q);
2056 pixel=ScaleQuantumToLong(GetGreenPixelComponent(p));
2057 q=PopLongPixel(endian,pixel,q);
2058 pixel=ScaleQuantumToLong(GetBluePixelComponent(p));
2059 q=PopLongPixel(endian,pixel,q);
2060 pixel=ScaleQuantumToLong((Quantum) (QuantumRange-
2061 GetOpacityPixelComponent(p)));
2062 q=PopLongPixel(endian,pixel,q);
2064 q+=quantum_info->pad;
2070 if (quantum_info->format == FloatingPointQuantumFormat)
2075 for (x=0; x < (long) number_pixels; x++)
2077 q=PopDoublePixel(&quantum_state,(double) p->red,q);
2078 q=PopDoublePixel(&quantum_state,(double) p->green,q);
2079 q=PopDoublePixel(&quantum_state,(double) p->blue,q);
2080 pixel=(double) (GetAlphaPixelComponent(p));
2081 q=PopDoublePixel(&quantum_state,pixel,q);
2083 q+=quantum_info->pad;
2090 range=GetQuantumRange(image->depth);
2091 for (x=0; x < (long) number_pixels; x++)
2093 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
2095 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
2097 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
2099 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
2100 (Quantum) (GetAlphaPixelComponent(p)),range),q);
2102 q+=quantum_info->pad;
2111 if (image->colorspace != CMYKColorspace)
2113 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
2114 "ColorSeparatedImageRequired","`%s'",image->filename);
2117 switch (quantum_info->depth)
2121 register unsigned char
2124 for (x=0; x < (long) number_pixels; x++)
2126 pixel=ScaleQuantumToChar(GetRedPixelComponent(p));
2127 q=PopCharPixel(pixel,q);
2128 pixel=ScaleQuantumToChar(GetGreenPixelComponent(p));
2129 q=PopCharPixel(pixel,q);
2130 pixel=ScaleQuantumToChar(GetBluePixelComponent(p));
2131 q=PopCharPixel(pixel,q);
2132 pixel=ScaleQuantumToChar(indexes[x]);
2133 q=PopCharPixel(pixel,q);
2135 q+=quantum_info->pad;
2141 register unsigned short
2144 if (quantum_info->format == FloatingPointQuantumFormat)
2146 for (x=0; x < (long) number_pixels; x++)
2148 pixel=ScaleFloatToHalf(QuantumScale*GetRedPixelComponent(p));
2149 q=PopShortPixel(endian,pixel,q);
2150 pixel=ScaleFloatToHalf(QuantumScale*GetGreenPixelComponent(p));
2151 q=PopShortPixel(endian,pixel,q);
2152 pixel=ScaleFloatToHalf(QuantumScale*GetBluePixelComponent(p));
2153 q=PopShortPixel(endian,pixel,q);
2154 pixel=ScaleFloatToHalf(QuantumScale*indexes[x]);
2155 q=PopShortPixel(endian,pixel,q);
2157 q+=quantum_info->pad;
2161 for (x=0; x < (long) number_pixels; x++)
2163 pixel=ScaleQuantumToShort(GetRedPixelComponent(p));
2164 q=PopShortPixel(endian,pixel,q);
2165 pixel=ScaleQuantumToShort(GetGreenPixelComponent(p));
2166 q=PopShortPixel(endian,pixel,q);
2167 pixel=ScaleQuantumToShort(GetBluePixelComponent(p));
2168 q=PopShortPixel(endian,pixel,q);
2169 pixel=ScaleQuantumToShort(indexes[x]);
2170 q=PopShortPixel(endian,pixel,q);
2172 q+=quantum_info->pad;
2178 register unsigned long
2181 if (quantum_info->format == FloatingPointQuantumFormat)
2183 for (x=0; x < (long) number_pixels; x++)
2185 q=PopFloatPixel(&quantum_state,(float) p->red,q);
2186 q=PopFloatPixel(&quantum_state,(float) p->green,q);
2187 q=PopFloatPixel(&quantum_state,(float) p->blue,q);
2188 q=PopFloatPixel(&quantum_state,(float) indexes[x],q);
2190 q+=quantum_info->pad;
2194 for (x=0; x < (long) number_pixels; x++)
2196 pixel=ScaleQuantumToLong(GetRedPixelComponent(p));
2197 q=PopLongPixel(endian,pixel,q);
2198 pixel=ScaleQuantumToLong(GetGreenPixelComponent(p));
2199 q=PopLongPixel(endian,pixel,q);
2200 pixel=ScaleQuantumToLong(GetBluePixelComponent(p));
2201 q=PopLongPixel(endian,pixel,q);
2202 pixel=ScaleQuantumToLong(indexes[x]);
2203 q=PopLongPixel(endian,pixel,q);
2205 q+=quantum_info->pad;
2211 if (quantum_info->format == FloatingPointQuantumFormat)
2213 for (x=0; x < (long) number_pixels; x++)
2215 q=PopDoublePixel(&quantum_state,(double) p->red,q);
2216 q=PopDoublePixel(&quantum_state,(double) p->green,q);
2217 q=PopDoublePixel(&quantum_state,(double) p->blue,q);
2218 q=PopDoublePixel(&quantum_state,(double) indexes[x],q);
2220 q+=quantum_info->pad;
2227 range=GetQuantumRange(image->depth);
2228 for (x=0; x < (long) number_pixels; x++)
2230 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
2232 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
2234 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
2236 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
2237 indexes[x],range),q);
2239 q+=quantum_info->pad;
2249 if (image->colorspace != CMYKColorspace)
2251 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
2252 "ColorSeparatedImageRequired","`%s'",image->filename);
2255 switch (quantum_info->depth)
2259 register unsigned char
2262 for (x=0; x < (long) number_pixels; x++)
2264 pixel=ScaleQuantumToChar(GetRedPixelComponent(p));
2265 q=PopCharPixel(pixel,q);
2266 pixel=ScaleQuantumToChar(GetGreenPixelComponent(p));
2267 q=PopCharPixel(pixel,q);
2268 pixel=ScaleQuantumToChar(GetBluePixelComponent(p));
2269 q=PopCharPixel(pixel,q);
2270 pixel=ScaleQuantumToChar(indexes[x]);
2271 q=PopCharPixel(pixel,q);
2272 pixel=ScaleQuantumToChar((Quantum) (QuantumRange-
2273 GetOpacityPixelComponent(p)));
2274 q=PopCharPixel(pixel,q);
2276 q+=quantum_info->pad;
2282 register unsigned short
2285 if (quantum_info->format == FloatingPointQuantumFormat)
2287 for (x=0; x < (long) number_pixels; x++)
2289 pixel=ScaleFloatToHalf(QuantumScale*GetRedPixelComponent(p));
2290 q=PopShortPixel(endian,pixel,q);
2291 pixel=ScaleFloatToHalf(QuantumScale*GetGreenPixelComponent(p));
2292 q=PopShortPixel(endian,pixel,q);
2293 pixel=ScaleFloatToHalf(QuantumScale*GetBluePixelComponent(p));
2294 q=PopShortPixel(endian,pixel,q);
2295 pixel=ScaleFloatToHalf(QuantumScale*indexes[x]);
2296 q=PopShortPixel(endian,pixel,q);
2297 pixel=ScaleFloatToHalf(QuantumScale*(QuantumRange-
2298 GetOpacityPixelComponent(p)));
2299 q=PopShortPixel(endian,pixel,q);
2301 q+=quantum_info->pad;
2305 for (x=0; x < (long) number_pixels; x++)
2307 pixel=ScaleQuantumToShort(GetRedPixelComponent(p));
2308 q=PopShortPixel(endian,pixel,q);
2309 pixel=ScaleQuantumToShort(GetGreenPixelComponent(p));
2310 q=PopShortPixel(endian,pixel,q);
2311 pixel=ScaleQuantumToShort(GetBluePixelComponent(p));
2312 q=PopShortPixel(endian,pixel,q);
2313 pixel=ScaleQuantumToShort(indexes[x]);
2314 q=PopShortPixel(endian,pixel,q);
2315 pixel=ScaleQuantumToShort((Quantum) (QuantumRange-
2316 GetOpacityPixelComponent(p)));
2317 q=PopShortPixel(endian,pixel,q);
2319 q+=quantum_info->pad;
2325 register unsigned long
2328 if (quantum_info->format == FloatingPointQuantumFormat)
2330 for (x=0; x < (long) number_pixels; x++)
2335 q=PopFloatPixel(&quantum_state,(float) p->red,q);
2336 q=PopFloatPixel(&quantum_state,(float) p->green,q);
2337 q=PopFloatPixel(&quantum_state,(float) p->blue,q);
2338 q=PopFloatPixel(&quantum_state,(float) indexes[x],q);
2339 pixel=(float) (GetAlphaPixelComponent(p));
2340 q=PopFloatPixel(&quantum_state,pixel,q);
2342 q+=quantum_info->pad;
2346 for (x=0; x < (long) number_pixels; x++)
2348 pixel=ScaleQuantumToLong(GetRedPixelComponent(p));
2349 q=PopLongPixel(endian,pixel,q);
2350 pixel=ScaleQuantumToLong(GetGreenPixelComponent(p));
2351 q=PopLongPixel(endian,pixel,q);
2352 pixel=ScaleQuantumToLong(GetBluePixelComponent(p));
2353 q=PopLongPixel(endian,pixel,q);
2354 pixel=ScaleQuantumToLong(indexes[x]);
2355 q=PopLongPixel(endian,pixel,q);
2356 pixel=ScaleQuantumToLong((Quantum) (QuantumRange-
2357 GetOpacityPixelComponent(p)));
2358 q=PopLongPixel(endian,pixel,q);
2360 q+=quantum_info->pad;
2366 if (quantum_info->format == FloatingPointQuantumFormat)
2371 for (x=0; x < (long) number_pixels; x++)
2373 q=PopDoublePixel(&quantum_state,(double) p->red,q);
2374 q=PopDoublePixel(&quantum_state,(double) p->green,q);
2375 q=PopDoublePixel(&quantum_state,(double) p->blue,q);
2376 q=PopDoublePixel(&quantum_state,(double) indexes[x],q);
2377 pixel=(double) (GetAlphaPixelComponent(p));
2378 q=PopDoublePixel(&quantum_state,pixel,q);
2380 q+=quantum_info->pad;
2387 range=GetQuantumRange(image->depth);
2388 for (x=0; x < (long) number_pixels; x++)
2390 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
2392 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
2394 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
2396 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
2397 indexes[x],range),q);
2398 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
2399 p->opacity,range),q);
2401 q+=quantum_info->pad;
2419 register unsigned long
2427 range=GetQuantumRange(image->depth);
2428 switch (quantum_info->depth)
2432 if (quantum_info->pack == MagickFalse)
2434 for (x=0; x < (long) number_pixels; x+=2)
2436 for (i=0; i < 4; i++)
2442 quantum=GetRedPixelComponent(p);
2447 quantum=GetGreenPixelComponent(p);
2452 quantum=GetBluePixelComponent(p);
2456 cbcr[i]=(Quantum) quantum;
2459 pixel=(unsigned long) ((unsigned long) (cbcr[1]) << 22 |
2460 (unsigned long) (cbcr[0]) << 12 |
2461 (unsigned long) (cbcr[2]) << 2);
2462 q=PopLongPixel(endian,pixel,q);
2464 pixel=(unsigned long) ((unsigned long) (cbcr[3]) << 22 |
2465 (unsigned long) (cbcr[0]) << 12 |
2466 (unsigned long) (cbcr[2]) << 2);
2467 q=PopLongPixel(endian,pixel,q);
2469 q+=quantum_info->pad;
2477 for (x=0; x < (long) number_pixels; x+=2)
2479 for (i=0; i < 4; i++)
2485 quantum=GetRedPixelComponent(p);
2490 quantum=GetGreenPixelComponent(p);
2495 quantum=GetBluePixelComponent(p);
2499 cbcr[i]=(Quantum) quantum;
2502 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
2504 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
2506 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
2509 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
2511 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
2513 q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
2516 q+=quantum_info->pad;
2526 if ((quantum_type == CbYCrQuantum) || (quantum_type == CbYCrAQuantum))
2531 register PixelPacket
2534 q=GetAuthenticPixelQueue(image);
2535 if (image_view != (CacheView *) NULL)
2536 q=(PixelPacket *) GetCacheViewVirtualPixelQueue(image_view);
2537 for (x=0; x < (long) number_pixels; x++)
2545 if ((quantum_type == RGBOQuantum) || (quantum_type == CMYKOQuantum))
2547 register PixelPacket
2550 q=GetAuthenticPixelQueue(image);
2551 if (image_view != (CacheView *) NULL)
2552 q=(PixelPacket *) GetCacheViewVirtualPixelQueue(image_view);
2553 for (x=0; x < (long) number_pixels; x++)
2555 q->opacity=(Quantum) GetAlphaPixelComponent(q);