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 "MagickCore/studio.h"
48 #include "MagickCore/property.h"
49 #include "MagickCore/blob.h"
50 #include "MagickCore/blob-private.h"
51 #include "MagickCore/color-private.h"
52 #include "MagickCore/exception.h"
53 #include "MagickCore/exception-private.h"
54 #include "MagickCore/cache.h"
55 #include "MagickCore/constitute.h"
56 #include "MagickCore/delegate.h"
57 #include "MagickCore/geometry.h"
58 #include "MagickCore/list.h"
59 #include "MagickCore/magick.h"
60 #include "MagickCore/memory_.h"
61 #include "MagickCore/monitor.h"
62 #include "MagickCore/option.h"
63 #include "MagickCore/pixel.h"
64 #include "MagickCore/pixel-accessor.h"
65 #include "MagickCore/quantum.h"
66 #include "MagickCore/quantum-private.h"
67 #include "MagickCore/resource_.h"
68 #include "MagickCore/semaphore.h"
69 #include "MagickCore/statistic.h"
70 #include "MagickCore/stream.h"
71 #include "MagickCore/string_.h"
72 #include "MagickCore/utility.h"
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,
93 % const CacheView *image_view,const QuantumInfo *quantum_info,
94 % const QuantumType quantum_type,unsigned char *pixels,
95 % ExceptionInfo *exception)
97 % A description of each parameter follows:
101 % o image_view: the image cache view.
103 % o quantum_info: the quantum info.
105 % o quantum_type: Declare which pixel components to transfer (RGB, RGBA,
108 % o pixels: The components are transferred to this buffer.
110 % o exception: return any errors or warnings in this structure.
114 static inline unsigned char *PopDoublePixel(const QuantumState *quantum_state,
115 const double pixel,unsigned char *pixels)
123 p=(double *) quantum;
124 *p=(double) (pixel*quantum_state->inverse_scale+quantum_state->minimum);
125 if (quantum_state->endian != LSBEndian)
127 *pixels++=quantum[7];
128 *pixels++=quantum[6];
129 *pixels++=quantum[5];
130 *pixels++=quantum[4];
131 *pixels++=quantum[3];
132 *pixels++=quantum[2];
133 *pixels++=quantum[1];
134 *pixels++=quantum[0];
137 *pixels++=quantum[0];
138 *pixels++=quantum[1];
139 *pixels++=quantum[2];
140 *pixels++=quantum[3];
141 *pixels++=quantum[4];
142 *pixels++=quantum[5];
143 *pixels++=quantum[6];
144 *pixels++=quantum[7];
148 static inline unsigned char *PopFloatPixel(const QuantumState *quantum_state,
149 const float pixel,unsigned char *pixels)
158 *p=(float) ((double) pixel*quantum_state->inverse_scale+
159 quantum_state->minimum);
160 if (quantum_state->endian != LSBEndian)
162 *pixels++=quantum[3];
163 *pixels++=quantum[2];
164 *pixels++=quantum[1];
165 *pixels++=quantum[0];
168 *pixels++=quantum[0];
169 *pixels++=quantum[1];
170 *pixels++=quantum[2];
171 *pixels++=quantum[3];
175 static inline unsigned char *PopQuantumPixel(QuantumState *quantum_state,
176 const size_t depth,const QuantumAny pixel,unsigned char *pixels)
184 if (quantum_state->bits == 0UL)
185 quantum_state->bits=8U;
186 for (i=(ssize_t) depth; i > 0L; )
188 quantum_bits=(size_t) i;
189 if (quantum_bits > quantum_state->bits)
190 quantum_bits=quantum_state->bits;
191 i-=(ssize_t) quantum_bits;
192 if (quantum_state->bits == 8UL)
194 quantum_state->bits-=quantum_bits;
195 *pixels|=(((pixel >> i) &~ ((~0UL) << quantum_bits)) <<
196 quantum_state->bits);
197 if (quantum_state->bits == 0UL)
200 quantum_state->bits=8UL;
206 static inline unsigned char *PopQuantumLongPixel(QuantumState *quantum_state,
207 const size_t depth,const size_t pixel,unsigned char *pixels)
215 if (quantum_state->bits == 0U)
216 quantum_state->bits=32UL;
217 for (i=(ssize_t) depth; i > 0; )
219 quantum_bits=(size_t) i;
220 if (quantum_bits > quantum_state->bits)
221 quantum_bits=quantum_state->bits;
222 quantum_state->pixel|=(((pixel >> (depth-i)) &
223 quantum_state->mask[quantum_bits]) << (32U-quantum_state->bits));
224 i-=(ssize_t) quantum_bits;
225 quantum_state->bits-=quantum_bits;
226 if (quantum_state->bits == 0U)
228 pixels=PopLongPixel(quantum_state->endian,quantum_state->pixel,pixels);
229 quantum_state->pixel=0U;
230 quantum_state->bits=32U;
236 MagickExport size_t ExportQuantumPixels(Image *image,CacheView *image_view,
237 const QuantumInfo *quantum_info,const QuantumType quantum_type,
238 unsigned char *pixels,ExceptionInfo *exception)
255 register const Quantum
261 register unsigned char
271 assert(image != (Image *) NULL);
272 assert(image->signature == MagickSignature);
273 if (image->debug != MagickFalse)
274 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
275 assert(quantum_info != (QuantumInfo *) NULL);
276 assert(quantum_info->signature == MagickSignature);
277 if (pixels == (unsigned char *) NULL)
278 pixels=GetQuantumPixels(quantum_info);
279 if (image_view == (CacheView *) NULL)
281 number_pixels=GetImageExtent(image);
282 p=GetVirtualPixelQueue(image);
283 channels=GetPixelChannels(image);
287 number_pixels=GetCacheViewExtent(image_view);
288 p=GetCacheViewVirtualPixelQueue(image_view);
289 channels=GetPixelChannels(image);
291 if (quantum_info->alpha_type == AssociatedQuantumAlpha)
299 q=GetAuthenticPixelQueue(image);
300 if (image_view != (CacheView *) NULL)
301 q=GetCacheViewAuthenticPixelQueue(image_view);
302 for (x=0; x < (ssize_t) image->columns; x++)
304 alpha=QuantumScale*GetPixelAlpha(image,q);
305 SetPixelRed(image,ClampToQuantum(alpha*GetPixelRed(image,q)),q);
306 SetPixelGreen(image,ClampToQuantum(alpha*GetPixelGreen(image,q)),q);
307 SetPixelBlue(image,ClampToQuantum(alpha*GetPixelBlue(image,q)),q);
311 if ((quantum_type == RGBOQuantum) || (quantum_type == CMYKOQuantum) ||
312 (quantum_type == BGROQuantum))
317 q=GetAuthenticPixelQueue(image);
318 if (image_view != (CacheView *) NULL)
319 q=GetCacheViewAuthenticPixelQueue(image_view);
320 for (x=0; x < (ssize_t) number_pixels; x++)
322 SetPixelAlpha(image,GetPixelAlpha(image,q),q);
326 if ((quantum_type == CbYCrQuantum) || (quantum_type == CbYCrAQuantum))
334 q=GetAuthenticPixelQueue(image);
335 if (image_view != (CacheView *) NULL)
336 q=GetAuthenticPixelQueue(image);
337 for (x=0; x < (ssize_t) number_pixels; x++)
339 quantum=GetPixelRed(image,q);
340 SetPixelRed(image,GetPixelGreen(image,q),q);
341 SetPixelGreen(image,quantum,q);
347 InitializeQuantumState(quantum_info,image->endian,&quantum_state);
348 extent=GetQuantumExtent(image,quantum_info,quantum_type);
349 endian=quantum_state.endian;
350 switch (quantum_type)
354 if (image->storage_class != PseudoClass)
356 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
357 "ColormappedImageRequired","`%s'",image->filename);
360 switch (quantum_info->depth)
364 register unsigned char
367 for (x=((ssize_t) number_pixels-7); x > 0; x-=8)
369 pixel=(unsigned char) GetPixelIndex(image,p);
370 *q=((pixel & 0x01) << 7);
372 pixel=(unsigned char) GetPixelIndex(image,p);
373 *q|=((pixel & 0x01) << 6);
375 pixel=(unsigned char) GetPixelIndex(image,p);
376 *q|=((pixel & 0x01) << 5);
378 pixel=(unsigned char) GetPixelIndex(image,p);
379 *q|=((pixel & 0x01) << 4);
381 pixel=(unsigned char) GetPixelIndex(image,p);
382 *q|=((pixel & 0x01) << 3);
384 pixel=(unsigned char) GetPixelIndex(image,p);
385 *q|=((pixel & 0x01) << 2);
387 pixel=(unsigned char) GetPixelIndex(image,p);
388 *q|=((pixel & 0x01) << 1);
390 pixel=(unsigned char) GetPixelIndex(image,p);
391 *q|=((pixel & 0x01) << 0);
395 if ((number_pixels % 8) != 0)
398 for (bit=7; bit >= (ssize_t) (8-(number_pixels % 8)); bit--)
400 pixel=(unsigned char) GetPixelIndex(image,p);
401 *q|=((pixel & 0x01) << (unsigned char) bit);
410 register unsigned char
413 for (x=0; x < (ssize_t) (number_pixels-1) ; x+=2)
415 pixel=(unsigned char) GetPixelIndex(image,p);
416 *q=((pixel & 0xf) << 4);
418 pixel=(unsigned char) GetPixelIndex(image,p);
419 *q|=((pixel & 0xf) << 0);
423 if ((number_pixels % 2) != 0)
425 pixel=(unsigned char) GetPixelIndex(image,p);
426 *q=((pixel & 0xf) << 4);
434 for (x=0; x < (ssize_t) number_pixels; x++)
436 q=PopCharPixel((unsigned char) GetPixelIndex(image,p),q);
438 q+=quantum_info->pad;
444 if (quantum_info->format == FloatingPointQuantumFormat)
446 for (x=0; x < (ssize_t) number_pixels; x++)
448 q=PopShortPixel(endian,SinglePrecisionToHalf(QuantumScale*
449 GetPixelIndex(image,p)),q);
451 q+=quantum_info->pad;
455 for (x=0; x < (ssize_t) number_pixels; x++)
457 q=PopShortPixel(endian,(unsigned short) GetPixelIndex(image,p),q);
459 q+=quantum_info->pad;
465 if (quantum_info->format == FloatingPointQuantumFormat)
467 for (x=0; x < (ssize_t) number_pixels; x++)
469 q=PopFloatPixel(&quantum_state,(float)
470 GetPixelIndex(image,p),q);
472 q+=quantum_info->pad;
476 for (x=0; x < (ssize_t) number_pixels; x++)
478 q=PopLongPixel(endian,(unsigned int) GetPixelIndex(image,p),q);
480 q+=quantum_info->pad;
486 if (quantum_info->format == FloatingPointQuantumFormat)
488 for (x=0; x < (ssize_t) number_pixels; x++)
490 q=PopDoublePixel(&quantum_state,(double)
491 GetPixelIndex(image,p),q);
493 q+=quantum_info->pad;
500 for (x=0; x < (ssize_t) number_pixels; x++)
502 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
503 GetPixelIndex(image,p),q);
505 q+=quantum_info->pad;
512 case IndexAlphaQuantum:
514 if (image->storage_class != PseudoClass)
516 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
517 "ColormappedImageRequired","`%s'",image->filename);
520 switch (quantum_info->depth)
524 register unsigned char
527 for (x=((ssize_t) number_pixels-3); x > 0; x-=4)
529 pixel=(unsigned char) GetPixelIndex(image,p);
530 *q=((pixel & 0x01) << 7);
531 pixel=(unsigned char) (GetPixelAlpha(image,p) == (Quantum)
532 TransparentAlpha ? 1 : 0);
533 *q|=((pixel & 0x01) << 6);
535 pixel=(unsigned char) GetPixelIndex(image,p);
536 *q|=((pixel & 0x01) << 5);
537 pixel=(unsigned char) (GetPixelAlpha(image,p) == (Quantum)
538 TransparentAlpha ? 1 : 0);
539 *q|=((pixel & 0x01) << 4);
541 pixel=(unsigned char) GetPixelIndex(image,p);
542 *q|=((pixel & 0x01) << 3);
543 pixel=(unsigned char) (GetPixelAlpha(image,p) == (Quantum)
544 TransparentAlpha ? 1 : 0);
545 *q|=((pixel & 0x01) << 2);
547 pixel=(unsigned char) GetPixelIndex(image,p);
548 *q|=((pixel & 0x01) << 1);
549 pixel=(unsigned char) (GetPixelAlpha(image,p) == (Quantum)
550 TransparentAlpha ? 1 : 0);
551 *q|=((pixel & 0x01) << 0);
555 if ((number_pixels % 4) != 0)
558 for (bit=3; bit >= (ssize_t) (4-(number_pixels % 4)); bit-=2)
560 pixel=(unsigned char) GetPixelIndex(image,p);
561 *q|=((pixel & 0x01) << (unsigned char) (bit+4));
562 pixel=(unsigned char) (GetPixelAlpha(image,p) == (Quantum)
563 TransparentAlpha ? 1 : 0);
564 *q|=((pixel & 0x01) << (unsigned char) (bit+4-1));
573 register unsigned char
576 for (x=0; x < (ssize_t) number_pixels ; x++)
578 pixel=(unsigned char) GetPixelIndex(image,p);
579 *q=((pixel & 0xf) << 4);
580 pixel=(unsigned char) (16*QuantumScale*GetPixelAlpha(image,p)+0.5);
581 *q|=((pixel & 0xf) << 0);
589 register unsigned char
592 for (x=0; x < (ssize_t) number_pixels; x++)
594 q=PopCharPixel((unsigned char) GetPixelIndex(image,p),q);
595 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p));
596 q=PopCharPixel(pixel,q);
598 q+=quantum_info->pad;
604 register unsigned short
607 if (quantum_info->format == FloatingPointQuantumFormat)
609 for (x=0; x < (ssize_t) number_pixels; x++)
611 q=PopShortPixel(endian,(unsigned short)
612 GetPixelIndex(image,p),q);
613 pixel=SinglePrecisionToHalf(QuantumScale*
614 GetPixelAlpha(image,p));
615 q=PopShortPixel(endian,pixel,q);
617 q+=quantum_info->pad;
621 for (x=0; x < (ssize_t) number_pixels; x++)
623 q=PopShortPixel(endian,(unsigned short) GetPixelIndex(image,p),q);
624 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p));
625 q=PopShortPixel(endian,pixel,q);
627 q+=quantum_info->pad;
633 register unsigned int
636 if (quantum_info->format == FloatingPointQuantumFormat)
638 for (x=0; x < (ssize_t) number_pixels; x++)
643 q=PopFloatPixel(&quantum_state,(float)
644 GetPixelIndex(image,p),q);
645 pixel=(float) GetPixelAlpha(image,p);
646 q=PopFloatPixel(&quantum_state,pixel,q);
648 q+=quantum_info->pad;
652 for (x=0; x < (ssize_t) number_pixels; x++)
654 q=PopLongPixel(endian,(unsigned int) GetPixelIndex(image,p),q);
655 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p));
656 q=PopLongPixel(endian,pixel,q);
658 q+=quantum_info->pad;
664 if (quantum_info->format == FloatingPointQuantumFormat)
666 for (x=0; x < (ssize_t) number_pixels; x++)
671 q=PopDoublePixel(&quantum_state,(double)
672 GetPixelIndex(image,p),q);
673 pixel=(double) GetPixelAlpha(image,p);
674 q=PopDoublePixel(&quantum_state,pixel,q);
676 q+=quantum_info->pad;
683 range=GetQuantumRange(quantum_info->depth);
684 for (x=0; x < (ssize_t) number_pixels; x++)
686 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
687 GetPixelIndex(image,p),q);
688 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
689 ScaleQuantumToAny(GetPixelAlpha(image,p),range),q);
691 q+=quantum_info->pad;
700 switch (quantum_info->depth)
704 for (x=0; x < (ssize_t) number_pixels; x++)
706 q=PopCharPixel(ScaleQuantumToChar(GetPixelBlue(image,p)),q);
707 q=PopCharPixel(ScaleQuantumToChar(GetPixelGreen(image,p)),q);
708 q=PopCharPixel(ScaleQuantumToChar(GetPixelRed(image,p)),q);
710 q+=quantum_info->pad;
716 register unsigned int
719 range=GetQuantumRange(quantum_info->depth);
720 if (quantum_info->pack == MagickFalse)
722 for (x=0; x < (ssize_t) number_pixels; x++)
724 pixel=(unsigned int) (
725 ScaleQuantumToAny(GetPixelRed(image,p),range) << 22 |
726 ScaleQuantumToAny(GetPixelGreen(image,p),range) << 12 |
727 ScaleQuantumToAny(GetPixelBlue(image,p),range) << 2);
728 q=PopLongPixel(endian,pixel,q);
730 q+=quantum_info->pad;
734 if (quantum_info->quantum == 32UL)
736 for (x=0; x < (ssize_t) number_pixels; x++)
738 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),
740 q=PopQuantumLongPixel(&quantum_state,quantum_info->depth,pixel,
742 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
744 q=PopQuantumLongPixel(&quantum_state,quantum_info->depth,pixel,
746 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),
748 q=PopQuantumLongPixel(&quantum_state,quantum_info->depth,pixel,
751 q+=quantum_info->pad;
755 for (x=0; x < (ssize_t) number_pixels; x++)
757 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),
759 q=PopQuantumPixel(&quantum_state,quantum_info->depth,pixel,q);
760 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
762 q=PopQuantumPixel(&quantum_state,quantum_info->depth,pixel,q);
763 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),
765 q=PopQuantumPixel(&quantum_state,quantum_info->depth,pixel,q);
767 q+=quantum_info->pad;
773 register unsigned int
776 range=GetQuantumRange(quantum_info->depth);
777 if (quantum_info->pack == MagickFalse)
779 for (x=0; x < (ssize_t) (3*number_pixels-1); x+=2)
786 pixel=(unsigned int) ScaleQuantumToAny(
787 GetPixelRed(image,p),range);
792 pixel=(unsigned int) ScaleQuantumToAny(
793 GetPixelGreen(image,p),range);
798 pixel=(unsigned int) ScaleQuantumToAny(
799 GetPixelBlue(image,p),range);
804 q=PopShortPixel(endian,(unsigned short) (pixel << 4),q);
810 pixel=(unsigned int) ScaleQuantumToAny(
811 GetPixelRed(image,p),range);
816 pixel=(unsigned int) ScaleQuantumToAny(
817 GetPixelGreen(image,p),range);
822 pixel=(unsigned int) ScaleQuantumToAny(
823 GetPixelBlue(image,p),range);
828 q=PopShortPixel(endian,(unsigned short) (pixel << 4),q);
829 q+=quantum_info->pad;
831 for (bit=0; bit < (ssize_t) (3*number_pixels % 2); bit++)
838 pixel=(unsigned int) ScaleQuantumToAny(
839 GetPixelRed(image,p),range);
844 pixel=(unsigned int) ScaleQuantumToAny(
845 GetPixelGreen(image,p),range);
850 pixel=(unsigned int) ScaleQuantumToAny(
851 GetPixelBlue(image,p),range);
856 q=PopShortPixel(endian,(unsigned short) (pixel << 4),q);
857 q+=quantum_info->pad;
863 if (quantum_info->quantum == 32UL)
865 for (x=0; x < (ssize_t) number_pixels; x++)
867 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),
869 q=PopQuantumLongPixel(&quantum_state,quantum_info->depth,pixel,
871 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
873 q=PopQuantumLongPixel(&quantum_state,quantum_info->depth,pixel,
875 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),
877 q=PopQuantumLongPixel(&quantum_state,quantum_info->depth,pixel,
880 q+=quantum_info->pad;
884 for (x=0; x < (ssize_t) number_pixels; x++)
886 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),
888 q=PopQuantumPixel(&quantum_state,quantum_info->depth,pixel,q);
889 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
891 q=PopQuantumPixel(&quantum_state,quantum_info->depth,pixel,q);
892 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),
894 q=PopQuantumPixel(&quantum_state,quantum_info->depth,pixel,q);
896 q+=quantum_info->pad;
902 register unsigned short
905 if (quantum_info->format == FloatingPointQuantumFormat)
907 for (x=0; x < (ssize_t) number_pixels; x++)
909 pixel=SinglePrecisionToHalf(QuantumScale*
910 GetPixelBlue(image,p));
911 q=PopShortPixel(endian,pixel,q);
912 pixel=SinglePrecisionToHalf(QuantumScale*
913 GetPixelGreen(image,p));
914 q=PopShortPixel(endian,pixel,q);
915 pixel=SinglePrecisionToHalf(QuantumScale*
916 GetPixelRed(image,p));
917 q=PopShortPixel(endian,pixel,q);
919 q+=quantum_info->pad;
923 for (x=0; x < (ssize_t) number_pixels; x++)
925 pixel=ScaleQuantumToShort(GetPixelBlue(image,p));
926 q=PopShortPixel(endian,pixel,q);
927 pixel=ScaleQuantumToShort(GetPixelGreen(image,p));
928 q=PopShortPixel(endian,pixel,q);
929 pixel=ScaleQuantumToShort(GetPixelRed(image,p));
930 q=PopShortPixel(endian,pixel,q);
932 q+=quantum_info->pad;
938 register unsigned int
941 if (quantum_info->format == FloatingPointQuantumFormat)
943 for (x=0; x < (ssize_t) number_pixels; x++)
945 q=PopFloatPixel(&quantum_state,(float)
946 GetPixelRed(image,p),q);
947 q=PopFloatPixel(&quantum_state,(float)
948 GetPixelGreen(image,p),q);
949 q=PopFloatPixel(&quantum_state,(float)
950 GetPixelBlue(image,p),q);
952 q+=quantum_info->pad;
956 for (x=0; x < (ssize_t) number_pixels; x++)
958 pixel=ScaleQuantumToLong(GetPixelBlue(image,p));
959 q=PopLongPixel(endian,pixel,q);
960 pixel=ScaleQuantumToLong(GetPixelGreen(image,p));
961 q=PopLongPixel(endian,pixel,q);
962 pixel=ScaleQuantumToLong(GetPixelRed(image,p));
963 q=PopLongPixel(endian,pixel,q);
965 q+=quantum_info->pad;
971 if (quantum_info->format == FloatingPointQuantumFormat)
973 for (x=0; x < (ssize_t) number_pixels; x++)
975 q=PopDoublePixel(&quantum_state,(double)
976 GetPixelRed(image,p),q);
977 q=PopDoublePixel(&quantum_state,(double)
978 GetPixelGreen(image,p),q);
979 q=PopDoublePixel(&quantum_state,(double)
980 GetPixelBlue(image,p),q);
982 q+=quantum_info->pad;
989 range=GetQuantumRange(quantum_info->depth);
990 for (x=0; x < (ssize_t) number_pixels; x++)
992 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
993 ScaleQuantumToAny(GetPixelRed(image,p),range),q);
994 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
995 ScaleQuantumToAny(GetPixelGreen(image,p),range),q);
996 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
997 ScaleQuantumToAny(GetPixelBlue(image,p),range),q);
999 q+=quantum_info->pad;
1009 switch (quantum_info->depth)
1013 register unsigned char
1016 for (x=0; x < (ssize_t) number_pixels; x++)
1018 pixel=ScaleQuantumToChar(GetPixelBlue(image,p));
1019 q=PopCharPixel(pixel,q);
1020 pixel=ScaleQuantumToChar(GetPixelGreen(image,p));
1021 q=PopCharPixel(pixel,q);
1022 pixel=ScaleQuantumToChar(GetPixelRed(image,p));
1023 q=PopCharPixel(pixel,q);
1024 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p));
1025 q=PopCharPixel(pixel,q);
1027 q+=quantum_info->pad;
1033 register unsigned int
1036 range=GetQuantumRange(quantum_info->depth);
1037 if (quantum_info->pack == MagickFalse)
1051 for (x=0; x < (ssize_t) number_pixels; x++)
1053 for (i=0; i < 4; i++)
1057 case 0: quantum=GetPixelRed(image,p); break;
1058 case 1: quantum=GetPixelGreen(image,p); break;
1059 case 2: quantum=GetPixelBlue(image,p); break;
1060 case 3: quantum=GetPixelAlpha(image,p); break;
1066 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum,
1072 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum,
1078 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum,
1080 q=PopLongPixel(endian,pixel,q);
1088 q+=quantum_info->pad;
1092 if (quantum_info->quantum == 32UL)
1094 for (x=0; x < (ssize_t) number_pixels; x++)
1096 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),
1098 q=PopQuantumLongPixel(&quantum_state,quantum_info->depth,pixel,
1100 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
1102 q=PopQuantumLongPixel(&quantum_state,quantum_info->depth,pixel,
1104 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),
1106 q=PopQuantumLongPixel(&quantum_state,quantum_info->depth,pixel,
1108 pixel=(unsigned int) ScaleQuantumToAny(GetPixelAlpha(image,p),
1110 q=PopQuantumLongPixel(&quantum_state,quantum_info->depth,pixel,
1113 q+=quantum_info->pad;
1117 for (x=0; x < (ssize_t) number_pixels; x++)
1119 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),
1121 q=PopQuantumPixel(&quantum_state,quantum_info->depth,pixel,q);
1122 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
1124 q=PopQuantumPixel(&quantum_state,quantum_info->depth,pixel,q);
1125 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),
1127 q=PopQuantumPixel(&quantum_state,quantum_info->depth,pixel,q);
1128 pixel=(unsigned int) ScaleQuantumToAny(GetPixelAlpha(image,p),
1130 q=PopQuantumPixel(&quantum_state,quantum_info->depth,pixel,q);
1132 q+=quantum_info->pad;
1138 register unsigned short
1141 if (quantum_info->format == FloatingPointQuantumFormat)
1143 for (x=0; x < (ssize_t) number_pixels; x++)
1145 pixel=SinglePrecisionToHalf(QuantumScale*
1146 GetPixelBlue(image,p));
1147 q=PopShortPixel(endian,pixel,q);
1148 pixel=SinglePrecisionToHalf(QuantumScale*
1149 GetPixelGreen(image,p));
1150 q=PopShortPixel(endian,pixel,q);
1151 pixel=SinglePrecisionToHalf(QuantumScale*
1152 GetPixelRed(image,p));
1153 q=PopShortPixel(endian,pixel,q);
1154 pixel=SinglePrecisionToHalf(QuantumScale*
1155 GetPixelAlpha(image,p));
1156 q=PopShortPixel(endian,pixel,q);
1158 q+=quantum_info->pad;
1162 for (x=0; x < (ssize_t) number_pixels; x++)
1164 pixel=ScaleQuantumToShort(GetPixelBlue(image,p));
1165 q=PopShortPixel(endian,pixel,q);
1166 pixel=ScaleQuantumToShort(GetPixelGreen(image,p));
1167 q=PopShortPixel(endian,pixel,q);
1168 pixel=ScaleQuantumToShort(GetPixelRed(image,p));
1169 q=PopShortPixel(endian,pixel,q);
1170 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p));
1171 q=PopShortPixel(endian,pixel,q);
1173 q+=quantum_info->pad;
1179 register unsigned int
1182 if (quantum_info->format == FloatingPointQuantumFormat)
1184 for (x=0; x < (ssize_t) number_pixels; x++)
1189 q=PopFloatPixel(&quantum_state,(float)
1190 GetPixelRed(image,p),q);
1191 q=PopFloatPixel(&quantum_state,(float)
1192 GetPixelGreen(image,p),q);
1193 q=PopFloatPixel(&quantum_state,(float)
1194 GetPixelBlue(image,p),q);
1195 pixel=(float) GetPixelAlpha(image,p);
1196 q=PopFloatPixel(&quantum_state,pixel,q);
1198 q+=quantum_info->pad;
1202 for (x=0; x < (ssize_t) number_pixels; x++)
1204 pixel=ScaleQuantumToLong(GetPixelBlue(image,p));
1205 q=PopLongPixel(endian,pixel,q);
1206 pixel=ScaleQuantumToLong(GetPixelGreen(image,p));
1207 q=PopLongPixel(endian,pixel,q);
1208 pixel=ScaleQuantumToLong(GetPixelRed(image,p));
1209 q=PopLongPixel(endian,pixel,q);
1210 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p));
1211 q=PopLongPixel(endian,pixel,q);
1213 q+=quantum_info->pad;
1219 if (quantum_info->format == FloatingPointQuantumFormat)
1224 for (x=0; x < (ssize_t) number_pixels; x++)
1226 q=PopDoublePixel(&quantum_state,(double)
1227 GetPixelRed(image,p),q);
1228 q=PopDoublePixel(&quantum_state,(double)
1229 GetPixelGreen(image,p),q);
1230 q=PopDoublePixel(&quantum_state,(double)
1231 GetPixelBlue(image,p),q);
1232 pixel=(double) GetPixelAlpha(image,p);
1233 q=PopDoublePixel(&quantum_state,pixel,q);
1235 q+=quantum_info->pad;
1242 range=GetQuantumRange(quantum_info->depth);
1243 for (x=0; x < (ssize_t) number_pixels; x++)
1245 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
1246 ScaleQuantumToAny(GetPixelBlue(image,p),range),q);
1247 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
1248 ScaleQuantumToAny(GetPixelGreen(image,p),range),q);
1249 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
1250 ScaleQuantumToAny(GetPixelRed(image,p),range),q);
1251 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
1252 ScaleQuantumToAny(GetPixelAlpha(image,p),range),q);
1254 q+=quantum_info->pad;
1263 switch (quantum_info->depth)
1270 register unsigned char
1276 if (quantum_info->min_is_white != MagickFalse)
1281 threshold=(Quantum) (QuantumRange/2);
1282 for (x=((ssize_t) number_pixels-7); x > 0; x-=8)
1285 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) << 7;
1287 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) << 6;
1289 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) << 5;
1291 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) << 4;
1293 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) << 3;
1295 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) << 2;
1297 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) << 1;
1299 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) << 0;
1303 if ((number_pixels % 8) != 0)
1306 for (bit=7; bit >= (ssize_t) (8-(number_pixels % 8)); bit--)
1308 *q|=(GetPixelIntensity(image,p) < threshold ? black : white) <<
1318 register unsigned char
1321 for (x=0; x < (ssize_t) (number_pixels-1) ; x+=2)
1323 pixel=ScaleQuantumToChar(GetPixelIntensity(image,p));
1324 *q=(((pixel >> 4) & 0xf) << 4);
1326 pixel=ScaleQuantumToChar(GetPixelIntensity(image,p));
1331 if ((number_pixels % 2) != 0)
1333 pixel=ScaleQuantumToChar(GetPixelIntensity(image,p));
1334 *q=(((pixel >> 4) & 0xf) << 4);
1342 register unsigned char
1345 for (x=0; x < (ssize_t) number_pixels; x++)
1347 pixel=ScaleQuantumToChar(GetPixelIntensity(image,p));
1348 q=PopCharPixel(pixel,q);
1350 q+=quantum_info->pad;
1356 range=GetQuantumRange(quantum_info->depth);
1357 if (quantum_info->pack == MagickFalse)
1359 register unsigned int
1362 for (x=0; x < (ssize_t) (number_pixels-2); x+=3)
1364 pixel=(unsigned int) (
1365 ScaleQuantumToAny(GetPixelIntensity(image,p+2),range) << 22 |
1366 ScaleQuantumToAny(GetPixelIntensity(image,p+1),range) << 12 |
1367 ScaleQuantumToAny(GetPixelIntensity(image,p+0),range) << 2);
1368 q=PopLongPixel(endian,pixel,q);
1370 q+=quantum_info->pad;
1373 if (x++ < (ssize_t) (number_pixels-1))
1374 pixel|=ScaleQuantumToAny(GetPixelIntensity(image,p+1),
1376 if (x++ < (ssize_t) number_pixels)
1377 pixel|=ScaleQuantumToAny(GetPixelIntensity(image,p+0),
1379 q=PopLongPixel(endian,pixel,q);
1382 for (x=0; x < (ssize_t) number_pixels; x++)
1384 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
1385 ScaleQuantumToAny(GetPixelIntensity(image,p),range),q);
1387 q+=quantum_info->pad;
1393 register unsigned short
1396 range=GetQuantumRange(quantum_info->depth);
1397 if (quantum_info->pack == MagickFalse)
1399 for (x=0; x < (ssize_t) number_pixels; x++)
1401 pixel=ScaleQuantumToShort(GetPixelIntensity(image,p));
1402 q=PopShortPixel(endian,(unsigned short) (pixel >> 4),q);
1404 q+=quantum_info->pad;
1408 for (x=0; x < (ssize_t) number_pixels; x++)
1410 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
1411 ScaleQuantumToAny(GetPixelIntensity(image,p),range),q);
1413 q+=quantum_info->pad;
1419 register unsigned short
1422 if (quantum_info->format == FloatingPointQuantumFormat)
1424 for (x=0; x < (ssize_t) number_pixels; x++)
1426 pixel=SinglePrecisionToHalf(QuantumScale*
1427 GetPixelIntensity(image,p));
1428 q=PopShortPixel(endian,pixel,q);
1430 q+=quantum_info->pad;
1434 for (x=0; x < (ssize_t) number_pixels; x++)
1436 pixel=ScaleQuantumToShort(GetPixelIntensity(image,p));
1437 q=PopShortPixel(endian,pixel,q);
1439 q+=quantum_info->pad;
1445 register unsigned int
1448 if (quantum_info->format == FloatingPointQuantumFormat)
1450 for (x=0; x < (ssize_t) number_pixels; x++)
1455 pixel=(float) GetPixelIntensity(image,p);
1456 q=PopFloatPixel(&quantum_state,pixel,q);
1458 q+=quantum_info->pad;
1462 for (x=0; x < (ssize_t) number_pixels; x++)
1464 pixel=ScaleQuantumToLong(GetPixelIntensity(image,p));
1465 q=PopLongPixel(endian,pixel,q);
1467 q+=quantum_info->pad;
1473 if (quantum_info->format == FloatingPointQuantumFormat)
1475 for (x=0; x < (ssize_t) number_pixels; x++)
1480 pixel=(double) GetPixelIntensity(image,p);
1481 q=PopDoublePixel(&quantum_state,pixel,q);
1483 q+=quantum_info->pad;
1490 range=GetQuantumRange(quantum_info->depth);
1491 for (x=0; x < (ssize_t) number_pixels; x++)
1493 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
1494 ScaleQuantumToAny(GetPixelIntensity(image,p),range),q);
1496 q+=quantum_info->pad;
1503 case GrayAlphaQuantum:
1505 switch (quantum_info->depth)
1512 register unsigned char
1519 if (quantum_info->min_is_white == MagickFalse)
1524 threshold=(Quantum) (QuantumRange/2);
1525 for (x=((ssize_t) number_pixels-3); x > 0; x-=4)
1528 *q|=(GetPixelIntensity(image,p) > threshold ? black : white) << 7;
1529 pixel=(unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ?
1531 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 6);
1533 *q|=(GetPixelIntensity(image,p) > threshold ? black : white) << 5;
1534 pixel=(unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ?
1536 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 4);
1538 *q|=(GetPixelIntensity(image,p) > threshold ? black : white) << 3;
1539 pixel=(unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ?
1541 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 2);
1543 *q|=(GetPixelIntensity(image,p) > threshold ? black : white) << 1;
1544 pixel=(unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ?
1546 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << 0);
1550 if ((number_pixels % 4) != 0)
1553 for (bit=0; bit <= (ssize_t) (number_pixels % 4); bit+=2)
1555 *q|=(GetPixelIntensity(image,p) > threshold ? black : white) <<
1557 pixel=(unsigned char) (GetPixelAlpha(image,p) == OpaqueAlpha ?
1559 *q|=(((int) pixel != 0 ? 0x00 : 0x01) << (unsigned char)
1569 register unsigned char
1572 for (x=0; x < (ssize_t) number_pixels ; x++)
1574 pixel=ScaleQuantumToChar(GetPixelIntensity(image,p));
1575 *q=(((pixel >> 4) & 0xf) << 4);
1576 pixel=(unsigned char) (16*QuantumScale*GetPixelAlpha(image,p)+0.5);
1585 register unsigned char
1588 for (x=0; x < (ssize_t) number_pixels; x++)
1590 pixel=ScaleQuantumToChar(GetPixelIntensity(image,p));
1591 q=PopCharPixel(pixel,q);
1592 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p));
1593 q=PopCharPixel(pixel,q);
1595 q+=quantum_info->pad;
1601 register unsigned short
1604 if (quantum_info->format == FloatingPointQuantumFormat)
1606 for (x=0; x < (ssize_t) number_pixels; x++)
1608 pixel=SinglePrecisionToHalf(QuantumScale*
1609 GetPixelIntensity(image,p));
1610 q=PopShortPixel(endian,pixel,q);
1611 pixel=SinglePrecisionToHalf(QuantumScale*
1612 GetPixelAlpha(image,p));
1613 q=PopShortPixel(endian,pixel,q);
1615 q+=quantum_info->pad;
1619 for (x=0; x < (ssize_t) number_pixels; x++)
1621 pixel=ScaleQuantumToShort(GetPixelIntensity(image,p));
1622 q=PopShortPixel(endian,pixel,q);
1623 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p));
1624 q=PopShortPixel(endian,pixel,q);
1626 q+=quantum_info->pad;
1632 register unsigned int
1635 if (quantum_info->format == FloatingPointQuantumFormat)
1637 for (x=0; x < (ssize_t) number_pixels; x++)
1642 pixel=(float) GetPixelIntensity(image,p);
1643 q=PopFloatPixel(&quantum_state,pixel,q);
1644 pixel=(float) (GetPixelAlpha(image,p));
1645 q=PopFloatPixel(&quantum_state,pixel,q);
1647 q+=quantum_info->pad;
1651 for (x=0; x < (ssize_t) number_pixels; x++)
1653 pixel=ScaleQuantumToLong(GetPixelIntensity(image,p));
1654 q=PopLongPixel(endian,pixel,q);
1655 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p));
1656 q=PopLongPixel(endian,pixel,q);
1658 q+=quantum_info->pad;
1664 if (quantum_info->format == FloatingPointQuantumFormat)
1666 for (x=0; x < (ssize_t) number_pixels; x++)
1671 pixel=(double) GetPixelIntensity(image,p);
1672 q=PopDoublePixel(&quantum_state,pixel,q);
1673 pixel=(double) (GetPixelAlpha(image,p));
1674 q=PopDoublePixel(&quantum_state,pixel,q);
1676 q+=quantum_info->pad;
1683 range=GetQuantumRange(quantum_info->depth);
1684 for (x=0; x < (ssize_t) number_pixels; x++)
1686 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
1687 ScaleQuantumToAny(GetPixelIntensity(image,p),range),q);
1688 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
1689 ScaleQuantumToAny(GetPixelAlpha(image,p),range),q);
1691 q+=quantum_info->pad;
1701 switch (quantum_info->depth)
1705 register unsigned char
1708 for (x=0; x < (ssize_t) number_pixels; x++)
1710 pixel=ScaleQuantumToChar(GetPixelRed(image,p));
1711 q=PopCharPixel(pixel,q);
1713 q+=quantum_info->pad;
1719 register unsigned short
1722 if (quantum_info->format == FloatingPointQuantumFormat)
1724 for (x=0; x < (ssize_t) number_pixels; x++)
1726 pixel=SinglePrecisionToHalf(QuantumScale*
1727 GetPixelRed(image,p));
1728 q=PopShortPixel(endian,pixel,q);
1730 q+=quantum_info->pad;
1734 for (x=0; x < (ssize_t) number_pixels; x++)
1736 pixel=ScaleQuantumToShort(GetPixelRed(image,p));
1737 q=PopShortPixel(endian,pixel,q);
1739 q+=quantum_info->pad;
1745 register unsigned int
1748 if (quantum_info->format == FloatingPointQuantumFormat)
1750 for (x=0; x < (ssize_t) number_pixels; x++)
1752 q=PopFloatPixel(&quantum_state,(float)
1753 GetPixelRed(image,p),q);
1755 q+=quantum_info->pad;
1759 for (x=0; x < (ssize_t) number_pixels; x++)
1761 pixel=ScaleQuantumToLong(GetPixelRed(image,p));
1762 q=PopLongPixel(endian,pixel,q);
1764 q+=quantum_info->pad;
1770 if (quantum_info->format == FloatingPointQuantumFormat)
1772 for (x=0; x < (ssize_t) number_pixels; x++)
1774 q=PopDoublePixel(&quantum_state,(double)
1775 GetPixelRed(image,p),q);
1777 q+=quantum_info->pad;
1784 range=GetQuantumRange(quantum_info->depth);
1785 for (x=0; x < (ssize_t) number_pixels; x++)
1787 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
1788 ScaleQuantumToAny(GetPixelRed(image,p),range),q);
1790 q+=quantum_info->pad;
1798 case MagentaQuantum:
1800 switch (quantum_info->depth)
1804 register unsigned char
1807 for (x=0; x < (ssize_t) number_pixels; x++)
1809 pixel=ScaleQuantumToChar(GetPixelGreen(image,p));
1810 q=PopCharPixel(pixel,q);
1812 q+=quantum_info->pad;
1818 register unsigned short
1821 if (quantum_info->format == FloatingPointQuantumFormat)
1823 for (x=0; x < (ssize_t) number_pixels; x++)
1825 pixel=SinglePrecisionToHalf(QuantumScale*
1826 GetPixelGreen(image,p));
1827 q=PopShortPixel(endian,pixel,q);
1829 q+=quantum_info->pad;
1833 for (x=0; x < (ssize_t) number_pixels; x++)
1835 pixel=ScaleQuantumToShort(GetPixelGreen(image,p));
1836 q=PopShortPixel(endian,pixel,q);
1838 q+=quantum_info->pad;
1844 register unsigned int
1847 if (quantum_info->format == FloatingPointQuantumFormat)
1849 for (x=0; x < (ssize_t) number_pixels; x++)
1851 q=PopFloatPixel(&quantum_state,(float)
1852 GetPixelGreen(image,p),q);
1854 q+=quantum_info->pad;
1858 for (x=0; x < (ssize_t) number_pixels; x++)
1860 pixel=ScaleQuantumToLong(GetPixelGreen(image,p));
1861 q=PopLongPixel(endian,pixel,q);
1863 q+=quantum_info->pad;
1869 if (quantum_info->format == FloatingPointQuantumFormat)
1871 for (x=0; x < (ssize_t) number_pixels; x++)
1873 q=PopDoublePixel(&quantum_state,(double)
1874 GetPixelGreen(image,p),q);
1876 q+=quantum_info->pad;
1883 range=GetQuantumRange(quantum_info->depth);
1884 for (x=0; x < (ssize_t) number_pixels; x++)
1886 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
1887 ScaleQuantumToAny(GetPixelGreen(image,p),range),q);
1889 q+=quantum_info->pad;
1899 switch (quantum_info->depth)
1903 register unsigned char
1906 for (x=0; x < (ssize_t) number_pixels; x++)
1908 pixel=ScaleQuantumToChar(GetPixelBlue(image,p));
1909 q=PopCharPixel(pixel,q);
1911 q+=quantum_info->pad;
1917 register unsigned short
1920 if (quantum_info->format == FloatingPointQuantumFormat)
1922 for (x=0; x < (ssize_t) number_pixels; x++)
1924 pixel=SinglePrecisionToHalf(QuantumScale*
1925 GetPixelBlue(image,p));
1926 q=PopShortPixel(endian,pixel,q);
1928 q+=quantum_info->pad;
1932 for (x=0; x < (ssize_t) number_pixels; x++)
1934 pixel=ScaleQuantumToShort(GetPixelBlue(image,p));
1935 q=PopShortPixel(endian,pixel,q);
1937 q+=quantum_info->pad;
1943 register unsigned int
1946 if (quantum_info->format == FloatingPointQuantumFormat)
1948 for (x=0; x < (ssize_t) number_pixels; x++)
1950 q=PopFloatPixel(&quantum_state,(float)
1951 GetPixelBlue(image,p),q);
1953 q+=quantum_info->pad;
1957 for (x=0; x < (ssize_t) number_pixels; x++)
1959 pixel=ScaleQuantumToLong(GetPixelBlue(image,p));
1960 q=PopLongPixel(endian,pixel,q);
1962 q+=quantum_info->pad;
1968 if (quantum_info->format == FloatingPointQuantumFormat)
1970 for (x=0; x < (ssize_t) number_pixels; x++)
1972 q=PopDoublePixel(&quantum_state,(double)
1973 GetPixelBlue(image,p),q);
1975 q+=quantum_info->pad;
1982 range=GetQuantumRange(quantum_info->depth);
1983 for (x=0; x < (ssize_t) number_pixels; x++)
1985 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
1986 ScaleQuantumToAny(GetPixelBlue(image,p),range),q);
1988 q+=quantum_info->pad;
1997 switch (quantum_info->depth)
2001 register unsigned char
2004 for (x=0; x < (ssize_t) number_pixels; x++)
2006 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p));
2007 q=PopCharPixel(pixel,q);
2009 q+=quantum_info->pad;
2015 register unsigned short
2018 if (quantum_info->format == FloatingPointQuantumFormat)
2020 for (x=0; x < (ssize_t) number_pixels; x++)
2022 pixel=SinglePrecisionToHalf(QuantumScale*
2023 GetPixelAlpha(image,p));
2024 q=PopShortPixel(endian,pixel,q);
2026 q+=quantum_info->pad;
2030 for (x=0; x < (ssize_t) number_pixels; x++)
2032 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p));
2033 q=PopShortPixel(endian,pixel,q);
2035 q+=quantum_info->pad;
2041 register unsigned int
2044 if (quantum_info->format == FloatingPointQuantumFormat)
2046 for (x=0; x < (ssize_t) number_pixels; x++)
2051 pixel=(float) GetPixelAlpha(image,p);
2052 q=PopFloatPixel(&quantum_state,pixel,q);
2054 q+=quantum_info->pad;
2058 for (x=0; x < (ssize_t) number_pixels; x++)
2060 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p));
2061 q=PopLongPixel(endian,pixel,q);
2063 q+=quantum_info->pad;
2069 if (quantum_info->format == FloatingPointQuantumFormat)
2071 for (x=0; x < (ssize_t) number_pixels; x++)
2076 pixel=(double) (GetPixelAlpha(image,p));
2077 q=PopDoublePixel(&quantum_state,pixel,q);
2079 q+=quantum_info->pad;
2086 range=GetQuantumRange(quantum_info->depth);
2087 for (x=0; x < (ssize_t) number_pixels; x++)
2089 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
2090 ScaleQuantumToAny(GetPixelAlpha(image,p),range),q);
2092 q+=quantum_info->pad;
2099 case OpacityQuantum:
2101 switch (quantum_info->depth)
2105 register unsigned char
2108 for (x=0; x < (ssize_t) number_pixels; x++)
2110 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p));
2111 q=PopCharPixel(pixel,q);
2113 q+=quantum_info->pad;
2119 register unsigned short
2122 if (quantum_info->format == FloatingPointQuantumFormat)
2124 for (x=0; x < (ssize_t) number_pixels; x++)
2126 pixel=SinglePrecisionToHalf(QuantumScale*
2127 GetPixelAlpha(image,p));
2128 q=PopShortPixel(endian,pixel,q);
2130 q+=quantum_info->pad;
2134 for (x=0; x < (ssize_t) number_pixels; x++)
2136 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p));
2137 q=PopShortPixel(endian,pixel,q);
2139 q+=quantum_info->pad;
2145 register unsigned int
2148 if (quantum_info->format == FloatingPointQuantumFormat)
2150 for (x=0; x < (ssize_t) number_pixels; x++)
2152 q=PopFloatPixel(&quantum_state,(float)
2153 GetPixelAlpha(image,p),q);
2155 q+=quantum_info->pad;
2159 for (x=0; x < (ssize_t) number_pixels; x++)
2161 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p));
2162 q=PopLongPixel(endian,pixel,q);
2164 q+=quantum_info->pad;
2170 if (quantum_info->format == FloatingPointQuantumFormat)
2172 for (x=0; x < (ssize_t) number_pixels; x++)
2174 q=PopDoublePixel(&quantum_state,(double)
2175 GetPixelAlpha(image,p),q);
2177 q+=quantum_info->pad;
2184 range=GetQuantumRange(quantum_info->depth);
2185 for (x=0; x < (ssize_t) number_pixels; x++)
2187 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
2188 ScaleQuantumToAny(GetPixelAlpha(image,p),range),q);
2190 q+=quantum_info->pad;
2199 if (image->colorspace != CMYKColorspace)
2201 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
2202 "ColorSeparatedImageRequired","`%s'",image->filename);
2205 switch (quantum_info->depth)
2209 register unsigned char
2212 for (x=0; x < (ssize_t) number_pixels; x++)
2214 pixel=ScaleQuantumToChar(GetPixelBlack(image,p));
2215 q=PopCharPixel(pixel,q);
2217 q+=quantum_info->pad;
2223 register unsigned short
2226 if (quantum_info->format == FloatingPointQuantumFormat)
2228 for (x=0; x < (ssize_t) number_pixels; x++)
2230 pixel=SinglePrecisionToHalf(QuantumScale*
2231 GetPixelBlack(image,p));
2232 q=PopShortPixel(endian,pixel,q);
2234 q+=quantum_info->pad;
2238 for (x=0; x < (ssize_t) number_pixels; x++)
2240 pixel=ScaleQuantumToShort(GetPixelBlack(image,p));
2241 q=PopShortPixel(endian,pixel,q);
2243 q+=quantum_info->pad;
2249 register unsigned int
2252 if (quantum_info->format == FloatingPointQuantumFormat)
2254 for (x=0; x < (ssize_t) number_pixels; x++)
2256 q=PopFloatPixel(&quantum_state,(float)
2257 GetPixelBlack(image,p),q);
2259 q+=quantum_info->pad;
2263 for (x=0; x < (ssize_t) number_pixels; x++)
2265 pixel=ScaleQuantumToLong(GetPixelBlack(image,p));
2266 q=PopLongPixel(endian,pixel,q);
2268 q+=quantum_info->pad;
2274 if (quantum_info->format == FloatingPointQuantumFormat)
2276 for (x=0; x < (ssize_t) number_pixels; x++)
2278 q=PopDoublePixel(&quantum_state,(double)
2279 GetPixelBlack(image,p),q);
2281 q+=quantum_info->pad;
2288 range=GetQuantumRange(quantum_info->depth);
2289 for (x=0; x < (ssize_t) number_pixels; x++)
2291 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
2292 ScaleQuantumToAny((Quantum) GetPixelBlack(image,p),range),q);
2294 q+=quantum_info->pad;
2304 switch (quantum_info->depth)
2308 for (x=0; x < (ssize_t) number_pixels; x++)
2310 q=PopCharPixel(ScaleQuantumToChar(GetPixelRed(image,p)),q);
2311 q=PopCharPixel(ScaleQuantumToChar(GetPixelGreen(image,p)),q);
2312 q=PopCharPixel(ScaleQuantumToChar(GetPixelBlue(image,p)),q);
2314 q+=quantum_info->pad;
2320 register unsigned int
2323 range=GetQuantumRange(quantum_info->depth);
2324 if (quantum_info->pack == MagickFalse)
2326 for (x=0; x < (ssize_t) number_pixels; x++)
2328 pixel=(unsigned int) (
2329 ScaleQuantumToAny(GetPixelRed(image,p),range) << 22 |
2330 ScaleQuantumToAny(GetPixelGreen(image,p),range) << 12 |
2331 ScaleQuantumToAny(GetPixelBlue(image,p),range) << 2);
2332 q=PopLongPixel(endian,pixel,q);
2334 q+=quantum_info->pad;
2338 if (quantum_info->quantum == 32UL)
2340 for (x=0; x < (ssize_t) number_pixels; x++)
2342 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),
2344 q=PopQuantumLongPixel(&quantum_state,quantum_info->depth,pixel,
2346 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
2348 q=PopQuantumLongPixel(&quantum_state,quantum_info->depth,pixel,
2350 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),
2352 q=PopQuantumLongPixel(&quantum_state,quantum_info->depth,pixel,
2355 q+=quantum_info->pad;
2359 for (x=0; x < (ssize_t) number_pixels; x++)
2361 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),
2363 q=PopQuantumPixel(&quantum_state,quantum_info->depth,pixel,q);
2364 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
2366 q=PopQuantumPixel(&quantum_state,quantum_info->depth,pixel,q);
2367 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),
2369 q=PopQuantumPixel(&quantum_state,quantum_info->depth,pixel,q);
2371 q+=quantum_info->pad;
2377 register unsigned int
2380 range=GetQuantumRange(quantum_info->depth);
2381 if (quantum_info->pack == MagickFalse)
2383 for (x=0; x < (ssize_t) (3*number_pixels-1); x+=2)
2390 pixel=(unsigned int) ScaleQuantumToAny(
2391 GetPixelRed(image,p),range);
2396 pixel=(unsigned int) ScaleQuantumToAny(
2397 GetPixelGreen(image,p),range);
2402 pixel=(unsigned int) ScaleQuantumToAny(
2403 GetPixelBlue(image,p),range);
2408 q=PopShortPixel(endian,(unsigned short) (pixel << 4),q);
2414 pixel=(unsigned int) ScaleQuantumToAny(
2415 GetPixelRed(image,p),range);
2420 pixel=(unsigned int) ScaleQuantumToAny(
2421 GetPixelGreen(image,p),range);
2426 pixel=(unsigned int) ScaleQuantumToAny(
2427 GetPixelBlue(image,p),range);
2432 q=PopShortPixel(endian,(unsigned short) (pixel << 4),q);
2433 q+=quantum_info->pad;
2435 for (bit=0; bit < (ssize_t) (3*number_pixels % 2); bit++)
2437 switch ((x+bit) % 3)
2442 pixel=(unsigned int) ScaleQuantumToAny(
2443 GetPixelRed(image,p),range);
2448 pixel=(unsigned int) ScaleQuantumToAny(
2449 GetPixelGreen(image,p),range);
2454 pixel=(unsigned int) ScaleQuantumToAny(
2455 GetPixelBlue(image,p),range);
2460 q=PopShortPixel(endian,(unsigned short) (pixel << 4),q);
2461 q+=quantum_info->pad;
2467 if (quantum_info->quantum == 32UL)
2469 for (x=0; x < (ssize_t) number_pixels; x++)
2471 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),
2473 q=PopQuantumLongPixel(&quantum_state,quantum_info->depth,pixel,
2475 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
2477 q=PopQuantumLongPixel(&quantum_state,quantum_info->depth,pixel,
2479 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),
2481 q=PopQuantumLongPixel(&quantum_state,quantum_info->depth,pixel,
2484 q+=quantum_info->pad;
2488 for (x=0; x < (ssize_t) number_pixels; x++)
2490 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),
2492 q=PopQuantumPixel(&quantum_state,quantum_info->depth,pixel,q);
2493 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
2495 q=PopQuantumPixel(&quantum_state,quantum_info->depth,pixel,q);
2496 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),
2498 q=PopQuantumPixel(&quantum_state,quantum_info->depth,pixel,q);
2500 q+=quantum_info->pad;
2506 register unsigned short
2509 if (quantum_info->format == FloatingPointQuantumFormat)
2511 for (x=0; x < (ssize_t) number_pixels; x++)
2513 pixel=SinglePrecisionToHalf(QuantumScale*
2514 GetPixelRed(image,p));
2515 q=PopShortPixel(endian,pixel,q);
2516 pixel=SinglePrecisionToHalf(QuantumScale*
2517 GetPixelGreen(image,p));
2518 q=PopShortPixel(endian,pixel,q);
2519 pixel=SinglePrecisionToHalf(QuantumScale*
2520 GetPixelBlue(image,p));
2521 q=PopShortPixel(endian,pixel,q);
2523 q+=quantum_info->pad;
2527 for (x=0; x < (ssize_t) number_pixels; x++)
2529 pixel=ScaleQuantumToShort(GetPixelRed(image,p));
2530 q=PopShortPixel(endian,pixel,q);
2531 pixel=ScaleQuantumToShort(GetPixelGreen(image,p));
2532 q=PopShortPixel(endian,pixel,q);
2533 pixel=ScaleQuantumToShort(GetPixelBlue(image,p));
2534 q=PopShortPixel(endian,pixel,q);
2536 q+=quantum_info->pad;
2542 register unsigned int
2545 if (quantum_info->format == FloatingPointQuantumFormat)
2547 for (x=0; x < (ssize_t) number_pixels; x++)
2549 q=PopFloatPixel(&quantum_state,(float)
2550 GetPixelRed(image,p),q);
2551 q=PopFloatPixel(&quantum_state,(float)
2552 GetPixelGreen(image,p),q);
2553 q=PopFloatPixel(&quantum_state,(float)
2554 GetPixelBlue(image,p),q);
2556 q+=quantum_info->pad;
2560 for (x=0; x < (ssize_t) number_pixels; x++)
2562 pixel=ScaleQuantumToLong(GetPixelRed(image,p));
2563 q=PopLongPixel(endian,pixel,q);
2564 pixel=ScaleQuantumToLong(GetPixelGreen(image,p));
2565 q=PopLongPixel(endian,pixel,q);
2566 pixel=ScaleQuantumToLong(GetPixelBlue(image,p));
2567 q=PopLongPixel(endian,pixel,q);
2569 q+=quantum_info->pad;
2575 if (quantum_info->format == FloatingPointQuantumFormat)
2577 for (x=0; x < (ssize_t) number_pixels; x++)
2579 q=PopDoublePixel(&quantum_state,(double)
2580 GetPixelRed(image,p),q);
2581 q=PopDoublePixel(&quantum_state,(double)
2582 GetPixelGreen(image,p),q);
2583 q=PopDoublePixel(&quantum_state,(double)
2584 GetPixelBlue(image,p),q);
2586 q+=quantum_info->pad;
2593 range=GetQuantumRange(quantum_info->depth);
2594 for (x=0; x < (ssize_t) number_pixels; x++)
2596 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
2597 ScaleQuantumToAny(GetPixelRed(image,p),range),q);
2598 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
2599 ScaleQuantumToAny(GetPixelGreen(image,p),range),q);
2600 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
2601 ScaleQuantumToAny(GetPixelBlue(image,p),range),q);
2603 q+=quantum_info->pad;
2614 switch (quantum_info->depth)
2618 register unsigned char
2621 for (x=0; x < (ssize_t) number_pixels; x++)
2623 pixel=ScaleQuantumToChar(GetPixelRed(image,p));
2624 q=PopCharPixel(pixel,q);
2625 pixel=ScaleQuantumToChar(GetPixelGreen(image,p));
2626 q=PopCharPixel(pixel,q);
2627 pixel=ScaleQuantumToChar(GetPixelBlue(image,p));
2628 q=PopCharPixel(pixel,q);
2629 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p));
2630 q=PopCharPixel(pixel,q);
2632 q+=quantum_info->pad;
2638 register unsigned int
2641 range=GetQuantumRange(quantum_info->depth);
2642 if (quantum_info->pack == MagickFalse)
2656 for (x=0; x < (ssize_t) number_pixels; x++)
2658 for (i=0; i < 4; i++)
2662 case 0: quantum=GetPixelRed(image,p); break;
2663 case 1: quantum=GetPixelGreen(image,p); break;
2664 case 2: quantum=GetPixelBlue(image,p); break;
2665 case 3: quantum=GetPixelAlpha(image,p); break;
2671 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum,
2677 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum,
2683 pixel|=(size_t) (ScaleQuantumToAny((Quantum) quantum,
2685 q=PopLongPixel(endian,pixel,q);
2693 q+=quantum_info->pad;
2697 if (quantum_info->quantum == 32UL)
2699 for (x=0; x < (ssize_t) number_pixels; x++)
2701 pixel=(unsigned int) ScaleQuantumToAny(GetPixelRed(image,p),
2703 q=PopQuantumLongPixel(&quantum_state,quantum_info->depth,pixel,
2705 pixel=(unsigned int) ScaleQuantumToAny(GetPixelGreen(image,p),
2707 q=PopQuantumLongPixel(&quantum_state,quantum_info->depth,pixel,
2709 pixel=(unsigned int) ScaleQuantumToAny(GetPixelBlue(image,p),
2711 q=PopQuantumLongPixel(&quantum_state,quantum_info->depth,pixel,
2713 pixel=(unsigned int) ScaleQuantumToAny(GetPixelAlpha(image,p),
2715 q=PopQuantumLongPixel(&quantum_state,quantum_info->depth,pixel,
2718 q+=quantum_info->pad;
2722 for (x=0; x < (ssize_t) number_pixels; x++)
2724 pixel=(unsigned int) ScaleQuantumToAny(
2725 GetPixelRed(image,p),range);
2726 q=PopQuantumPixel(&quantum_state,quantum_info->depth,pixel,q);
2727 pixel=(unsigned int) ScaleQuantumToAny(
2728 GetPixelGreen(image,p),range);
2729 q=PopQuantumPixel(&quantum_state,quantum_info->depth,pixel,q);
2730 pixel=(unsigned int) ScaleQuantumToAny(
2731 GetPixelBlue(image,p),range);
2732 q=PopQuantumPixel(&quantum_state,quantum_info->depth,pixel,q);
2733 pixel=(unsigned int) ScaleQuantumToAny(
2734 GetPixelAlpha(image,p),range);
2735 q=PopQuantumPixel(&quantum_state,quantum_info->depth,pixel,q);
2737 q+=quantum_info->pad;
2743 register unsigned short
2746 if (quantum_info->format == FloatingPointQuantumFormat)
2748 for (x=0; x < (ssize_t) number_pixels; x++)
2750 pixel=SinglePrecisionToHalf(QuantumScale*
2751 GetPixelRed(image,p));
2752 q=PopShortPixel(endian,pixel,q);
2753 pixel=SinglePrecisionToHalf(QuantumScale*
2754 GetPixelGreen(image,p));
2755 q=PopShortPixel(endian,pixel,q);
2756 pixel=SinglePrecisionToHalf(QuantumScale*
2757 GetPixelBlue(image,p));
2758 q=PopShortPixel(endian,pixel,q);
2759 pixel=SinglePrecisionToHalf(QuantumScale*
2760 GetPixelAlpha(image,p));
2761 q=PopShortPixel(endian,pixel,q);
2763 q+=quantum_info->pad;
2767 for (x=0; x < (ssize_t) number_pixels; x++)
2769 pixel=ScaleQuantumToShort(GetPixelRed(image,p));
2770 q=PopShortPixel(endian,pixel,q);
2771 pixel=ScaleQuantumToShort(GetPixelGreen(image,p));
2772 q=PopShortPixel(endian,pixel,q);
2773 pixel=ScaleQuantumToShort(GetPixelBlue(image,p));
2774 q=PopShortPixel(endian,pixel,q);
2775 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p));
2776 q=PopShortPixel(endian,pixel,q);
2778 q+=quantum_info->pad;
2784 register unsigned int
2787 if (quantum_info->format == FloatingPointQuantumFormat)
2789 for (x=0; x < (ssize_t) number_pixels; x++)
2794 q=PopFloatPixel(&quantum_state,(float)
2795 GetPixelRed(image,p),q);
2796 q=PopFloatPixel(&quantum_state,(float)
2797 GetPixelGreen(image,p),q);
2798 q=PopFloatPixel(&quantum_state,(float)
2799 GetPixelBlue(image,p),q);
2800 pixel=(float) GetPixelAlpha(image,p);
2801 q=PopFloatPixel(&quantum_state,pixel,q);
2803 q+=quantum_info->pad;
2807 for (x=0; x < (ssize_t) number_pixels; x++)
2809 pixel=ScaleQuantumToLong(GetPixelRed(image,p));
2810 q=PopLongPixel(endian,pixel,q);
2811 pixel=ScaleQuantumToLong(GetPixelGreen(image,p));
2812 q=PopLongPixel(endian,pixel,q);
2813 pixel=ScaleQuantumToLong(GetPixelBlue(image,p));
2814 q=PopLongPixel(endian,pixel,q);
2815 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p));
2816 q=PopLongPixel(endian,pixel,q);
2818 q+=quantum_info->pad;
2824 if (quantum_info->format == FloatingPointQuantumFormat)
2829 for (x=0; x < (ssize_t) number_pixels; x++)
2831 q=PopDoublePixel(&quantum_state,(double)
2832 GetPixelRed(image,p),q);
2833 q=PopDoublePixel(&quantum_state,(double)
2834 GetPixelGreen(image,p),q);
2835 q=PopDoublePixel(&quantum_state,(double)
2836 GetPixelBlue(image,p),q);
2837 pixel=(double) GetPixelAlpha(image,p);
2838 q=PopDoublePixel(&quantum_state,pixel,q);
2840 q+=quantum_info->pad;
2847 range=GetQuantumRange(quantum_info->depth);
2848 for (x=0; x < (ssize_t) number_pixels; x++)
2850 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
2851 ScaleQuantumToAny(GetPixelRed(image,p),range),q);
2852 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
2853 ScaleQuantumToAny(GetPixelGreen(image,p),range),q);
2854 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
2855 ScaleQuantumToAny(GetPixelBlue(image,p),range),q);
2856 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
2857 ScaleQuantumToAny(GetPixelAlpha(image,p),range),q);
2859 q+=quantum_info->pad;
2868 if (image->colorspace != CMYKColorspace)
2870 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
2871 "ColorSeparatedImageRequired","`%s'",image->filename);
2874 switch (quantum_info->depth)
2878 register unsigned char
2881 for (x=0; x < (ssize_t) number_pixels; x++)
2883 pixel=ScaleQuantumToChar(GetPixelRed(image,p));
2884 q=PopCharPixel(pixel,q);
2885 pixel=ScaleQuantumToChar(GetPixelGreen(image,p));
2886 q=PopCharPixel(pixel,q);
2887 pixel=ScaleQuantumToChar(GetPixelBlue(image,p));
2888 q=PopCharPixel(pixel,q);
2889 pixel=ScaleQuantumToChar(GetPixelBlack(image,p));
2890 q=PopCharPixel(pixel,q);
2892 q+=quantum_info->pad;
2898 register unsigned short
2901 if (quantum_info->format == FloatingPointQuantumFormat)
2903 for (x=0; x < (ssize_t) number_pixels; x++)
2905 pixel=SinglePrecisionToHalf(QuantumScale*
2906 GetPixelRed(image,p));
2907 q=PopShortPixel(endian,pixel,q);
2908 pixel=SinglePrecisionToHalf(QuantumScale*
2909 GetPixelGreen(image,p));
2910 q=PopShortPixel(endian,pixel,q);
2911 pixel=SinglePrecisionToHalf(QuantumScale*
2912 GetPixelBlue(image,p));
2913 q=PopShortPixel(endian,pixel,q);
2914 pixel=SinglePrecisionToHalf(QuantumScale*
2915 GetPixelBlack(image,p));
2916 q=PopShortPixel(endian,pixel,q);
2918 q+=quantum_info->pad;
2922 for (x=0; x < (ssize_t) number_pixels; x++)
2924 pixel=ScaleQuantumToShort(GetPixelRed(image,p));
2925 q=PopShortPixel(endian,pixel,q);
2926 pixel=ScaleQuantumToShort(GetPixelGreen(image,p));
2927 q=PopShortPixel(endian,pixel,q);
2928 pixel=ScaleQuantumToShort(GetPixelBlue(image,p));
2929 q=PopShortPixel(endian,pixel,q);
2930 pixel=ScaleQuantumToShort(GetPixelBlack(image,p));
2931 q=PopShortPixel(endian,pixel,q);
2933 q+=quantum_info->pad;
2939 register unsigned int
2942 if (quantum_info->format == FloatingPointQuantumFormat)
2944 for (x=0; x < (ssize_t) number_pixels; x++)
2946 q=PopFloatPixel(&quantum_state,(float)
2947 GetPixelRed(image,p),q);
2948 q=PopFloatPixel(&quantum_state,(float)
2949 GetPixelGreen(image,p),q);
2950 q=PopFloatPixel(&quantum_state,(float)
2951 GetPixelBlue(image,p),q);
2952 q=PopFloatPixel(&quantum_state,(float)
2953 GetPixelBlack(image,p),q);
2955 q+=quantum_info->pad;
2959 for (x=0; x < (ssize_t) number_pixels; x++)
2961 pixel=ScaleQuantumToLong(GetPixelRed(image,p));
2962 q=PopLongPixel(endian,pixel,q);
2963 pixel=ScaleQuantumToLong(GetPixelGreen(image,p));
2964 q=PopLongPixel(endian,pixel,q);
2965 pixel=ScaleQuantumToLong(GetPixelBlue(image,p));
2966 q=PopLongPixel(endian,pixel,q);
2967 pixel=ScaleQuantumToLong(GetPixelBlack(image,p));
2968 q=PopLongPixel(endian,pixel,q);
2970 q+=quantum_info->pad;
2976 if (quantum_info->format == FloatingPointQuantumFormat)
2978 for (x=0; x < (ssize_t) number_pixels; x++)
2980 q=PopDoublePixel(&quantum_state,(double)
2981 GetPixelRed(image,p),q);
2982 q=PopDoublePixel(&quantum_state,(double)
2983 GetPixelGreen(image,p),q);
2984 q=PopDoublePixel(&quantum_state,(double)
2985 GetPixelBlue(image,p),q);
2986 q=PopDoublePixel(&quantum_state,(double)
2987 GetPixelBlack(image,p),q);
2989 q+=quantum_info->pad;
2996 range=GetQuantumRange(quantum_info->depth);
2997 for (x=0; x < (ssize_t) number_pixels; x++)
2999 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
3000 ScaleQuantumToAny(GetPixelRed(image,p),range),q);
3001 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
3002 ScaleQuantumToAny(GetPixelGreen(image,p),range),q);
3003 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
3004 ScaleQuantumToAny(GetPixelBlue(image,p),range),q);
3005 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
3006 ScaleQuantumToAny(GetPixelBlack(image,p),range),q);
3008 q+=quantum_info->pad;
3018 if (image->colorspace != CMYKColorspace)
3020 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
3021 "ColorSeparatedImageRequired","`%s'",image->filename);
3024 switch (quantum_info->depth)
3028 register unsigned char
3031 for (x=0; x < (ssize_t) number_pixels; x++)
3033 pixel=ScaleQuantumToChar(GetPixelRed(image,p));
3034 q=PopCharPixel(pixel,q);
3035 pixel=ScaleQuantumToChar(GetPixelGreen(image,p));
3036 q=PopCharPixel(pixel,q);
3037 pixel=ScaleQuantumToChar(GetPixelBlue(image,p));
3038 q=PopCharPixel(pixel,q);
3039 pixel=ScaleQuantumToChar(GetPixelBlack(image,p));
3040 q=PopCharPixel(pixel,q);
3041 pixel=ScaleQuantumToChar(GetPixelAlpha(image,p));
3042 q=PopCharPixel(pixel,q);
3044 q+=quantum_info->pad;
3050 register unsigned short
3053 if (quantum_info->format == FloatingPointQuantumFormat)
3055 for (x=0; x < (ssize_t) number_pixels; x++)
3057 pixel=SinglePrecisionToHalf(QuantumScale*
3058 GetPixelRed(image,p));
3059 q=PopShortPixel(endian,pixel,q);
3060 pixel=SinglePrecisionToHalf(QuantumScale*
3061 GetPixelGreen(image,p));
3062 q=PopShortPixel(endian,pixel,q);
3063 pixel=SinglePrecisionToHalf(QuantumScale*
3064 GetPixelBlue(image,p));
3065 q=PopShortPixel(endian,pixel,q);
3066 pixel=SinglePrecisionToHalf(QuantumScale*
3067 GetPixelBlack(image,p));
3068 q=PopShortPixel(endian,pixel,q);
3069 pixel=SinglePrecisionToHalf(QuantumScale*
3070 GetPixelAlpha(image,p));
3071 q=PopShortPixel(endian,pixel,q);
3073 q+=quantum_info->pad;
3077 for (x=0; x < (ssize_t) number_pixels; x++)
3079 pixel=ScaleQuantumToShort(GetPixelRed(image,p));
3080 q=PopShortPixel(endian,pixel,q);
3081 pixel=ScaleQuantumToShort(GetPixelGreen(image,p));
3082 q=PopShortPixel(endian,pixel,q);
3083 pixel=ScaleQuantumToShort(GetPixelBlue(image,p));
3084 q=PopShortPixel(endian,pixel,q);
3085 pixel=ScaleQuantumToShort(GetPixelBlack(image,p));
3086 q=PopShortPixel(endian,pixel,q);
3087 pixel=ScaleQuantumToShort(GetPixelAlpha(image,p));
3088 q=PopShortPixel(endian,pixel,q);
3090 q+=quantum_info->pad;
3096 register unsigned int
3099 if (quantum_info->format == FloatingPointQuantumFormat)
3101 for (x=0; x < (ssize_t) number_pixels; x++)
3106 q=PopFloatPixel(&quantum_state,(float)
3107 GetPixelRed(image,p),q);
3108 q=PopFloatPixel(&quantum_state,(float)
3109 GetPixelGreen(image,p),q);
3110 q=PopFloatPixel(&quantum_state,(float)
3111 GetPixelBlue(image,p),q);
3112 q=PopFloatPixel(&quantum_state,(float)
3113 GetPixelBlack(image,p),q);
3114 pixel=(float) (GetPixelAlpha(image,p));
3115 q=PopFloatPixel(&quantum_state,pixel,q);
3117 q+=quantum_info->pad;
3121 for (x=0; x < (ssize_t) number_pixels; x++)
3123 pixel=ScaleQuantumToLong(GetPixelRed(image,p));
3124 q=PopLongPixel(endian,pixel,q);
3125 pixel=ScaleQuantumToLong(GetPixelGreen(image,p));
3126 q=PopLongPixel(endian,pixel,q);
3127 pixel=ScaleQuantumToLong(GetPixelBlue(image,p));
3128 q=PopLongPixel(endian,pixel,q);
3129 pixel=ScaleQuantumToLong(GetPixelBlack(image,p));
3130 q=PopLongPixel(endian,pixel,q);
3131 pixel=ScaleQuantumToLong(GetPixelAlpha(image,p));
3132 q=PopLongPixel(endian,pixel,q);
3134 q+=quantum_info->pad;
3140 if (quantum_info->format == FloatingPointQuantumFormat)
3145 for (x=0; x < (ssize_t) number_pixels; x++)
3147 q=PopDoublePixel(&quantum_state,(double)
3148 GetPixelRed(image,p),q);
3149 q=PopDoublePixel(&quantum_state,(double)
3150 GetPixelGreen(image,p),q);
3151 q=PopDoublePixel(&quantum_state,(double)
3152 GetPixelBlue(image,p),q);
3153 q=PopDoublePixel(&quantum_state,(double)
3154 GetPixelBlack(image,p),q);
3155 pixel=(double) (GetPixelAlpha(image,p));
3156 q=PopDoublePixel(&quantum_state,pixel,q);
3158 q+=quantum_info->pad;
3165 range=GetQuantumRange(quantum_info->depth);
3166 for (x=0; x < (ssize_t) number_pixels; x++)
3168 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
3169 ScaleQuantumToAny(GetPixelRed(image,p),range),q);
3170 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
3171 ScaleQuantumToAny(GetPixelGreen(image,p),range),q);
3172 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
3173 ScaleQuantumToAny(GetPixelBlue(image,p),range),q);
3174 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
3175 ScaleQuantumToAny(GetPixelBlack(image,p),range),q);
3176 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
3177 ScaleQuantumToAny(GetPixelAlpha(image,p),range),q);
3179 q+=quantum_info->pad;
3194 register unsigned int
3205 range=GetQuantumRange(quantum_info->depth);
3206 switch (quantum_info->depth)
3210 if (quantum_info->pack == MagickFalse)
3212 for (x=0; x < (ssize_t) number_pixels; x+=2)
3214 for (i=0; i < 4; i++)
3220 quantum=GetPixelRed(image,p);
3225 quantum=GetPixelGreen(image,p);
3230 quantum=GetPixelBlue(image,p);
3234 cbcr[i]=(Quantum) quantum;
3237 pixel=(unsigned int) ((size_t) (cbcr[1]) << 22 | (size_t)
3238 (cbcr[0]) << 12 | (size_t) (cbcr[2]) << 2);
3239 q=PopLongPixel(endian,pixel,q);
3241 pixel=(unsigned int) ((size_t) (cbcr[3]) << 22 | (size_t)
3242 (cbcr[0]) << 12 | (size_t) (cbcr[2]) << 2);
3243 q=PopLongPixel(endian,pixel,q);
3245 q+=quantum_info->pad;
3253 for (x=0; x < (ssize_t) number_pixels; x+=2)
3255 for (i=0; i < 4; i++)
3261 quantum=GetPixelRed(image,p);
3266 quantum=GetPixelGreen(image,p);
3271 quantum=GetPixelBlue(image,p);
3275 cbcr[i]=(Quantum) quantum;
3278 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
3279 ScaleQuantumToAny(cbcr[1],range),q);
3280 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
3281 ScaleQuantumToAny(cbcr[0],range),q);
3282 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
3283 ScaleQuantumToAny(cbcr[2],range),q);
3285 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
3286 ScaleQuantumToAny(cbcr[3],range),q);
3287 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
3288 ScaleQuantumToAny(cbcr[0],range),q);
3289 q=PopQuantumPixel(&quantum_state,quantum_info->depth,
3290 ScaleQuantumToAny(cbcr[2],range),q);
3292 q+=quantum_info->pad;
3302 if ((quantum_type == CbYCrQuantum) || (quantum_type == CbYCrAQuantum))
3310 q=GetAuthenticPixelQueue(image);
3311 if (image_view != (CacheView *) NULL)
3312 q=GetCacheViewAuthenticPixelQueue(image_view);
3313 for (x=0; x < (ssize_t) number_pixels; x++)
3315 quantum=GetPixelRed(image,q);
3316 SetPixelRed(image,GetPixelGreen(image,q),q);
3317 SetPixelGreen(image,quantum,q);
3321 if ((quantum_type == RGBOQuantum) || (quantum_type == CMYKOQuantum) ||
3322 (quantum_type == BGROQuantum))
3327 q=GetAuthenticPixelQueue(image);
3328 if (image_view != (CacheView *) NULL)
3329 q=GetCacheViewAuthenticPixelQueue(image_view);
3330 for (x=0; x < (ssize_t) number_pixels; x++)
3332 SetPixelAlpha(image,GetPixelAlpha(image,q),q);