00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #include "magick/studio.h"
00048 #include "magick/property.h"
00049 #include "magick/blob.h"
00050 #include "magick/blob-private.h"
00051 #include "magick/color-private.h"
00052 #include "magick/exception.h"
00053 #include "magick/exception-private.h"
00054 #include "magick/cache.h"
00055 #include "magick/constitute.h"
00056 #include "magick/delegate.h"
00057 #include "magick/geometry.h"
00058 #include "magick/list.h"
00059 #include "magick/magick.h"
00060 #include "magick/memory_.h"
00061 #include "magick/monitor.h"
00062 #include "magick/option.h"
00063 #include "magick/pixel.h"
00064 #include "magick/pixel-private.h"
00065 #include "magick/quantum.h"
00066 #include "magick/quantum-private.h"
00067 #include "magick/resource_.h"
00068 #include "magick/semaphore.h"
00069 #include "magick/statistic.h"
00070 #include "magick/stream.h"
00071 #include "magick/string_.h"
00072 #include "magick/utility.h"
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 static inline IndexPacket PushColormapIndex(Image *image,
00114 const unsigned long index,MagickBooleanType *range_exception)
00115 {
00116 if (index < image->colors)
00117 return((IndexPacket) index);
00118 *range_exception=MagickTrue;
00119 return((IndexPacket) 0);
00120 }
00121
00122 static inline const unsigned char *PushDoublePixel(
00123 const QuantumState *quantum_state,const unsigned char *pixels,double *pixel)
00124 {
00125 double
00126 *p;
00127
00128 unsigned char
00129 quantum[8];
00130
00131 if (quantum_state->endian != LSBEndian)
00132 {
00133 quantum[7]=(*pixels++);
00134 quantum[6]=(*pixels++);
00135 quantum[5]=(*pixels++);
00136 quantum[5]=(*pixels++);
00137 quantum[3]=(*pixels++);
00138 quantum[2]=(*pixels++);
00139 quantum[1]=(*pixels++);
00140 quantum[0]=(*pixels++);
00141 p=(double *) quantum;
00142 *pixel=(*p);
00143 *pixel-=quantum_state->minimum;
00144 *pixel*=quantum_state->scale;
00145 return(pixels);
00146 }
00147 quantum[0]=(*pixels++);
00148 quantum[1]=(*pixels++);
00149 quantum[2]=(*pixels++);
00150 quantum[3]=(*pixels++);
00151 quantum[4]=(*pixels++);
00152 quantum[5]=(*pixels++);
00153 quantum[6]=(*pixels++);
00154 quantum[7]=(*pixels++);
00155 p=(double *) quantum;
00156 *pixel=(*p);
00157 *pixel-=quantum_state->minimum;
00158 *pixel*=quantum_state->scale;
00159 return(pixels);
00160 }
00161
00162 static inline const unsigned char *PushFloatPixel(
00163 const QuantumState *quantum_state,const unsigned char *pixels,float *pixel)
00164 {
00165 float
00166 *p;
00167
00168 unsigned char
00169 quantum[4];
00170
00171 if (quantum_state->endian != LSBEndian)
00172 {
00173 quantum[3]=(*pixels++);
00174 quantum[2]=(*pixels++);
00175 quantum[1]=(*pixels++);
00176 quantum[0]=(*pixels++);
00177 p=(float *) quantum;
00178 *pixel=(*p);
00179 *pixel-=quantum_state->minimum;
00180 *pixel*=quantum_state->scale;
00181 return(pixels);
00182 }
00183 quantum[0]=(*pixels++);
00184 quantum[1]=(*pixels++);
00185 quantum[2]=(*pixels++);
00186 quantum[3]=(*pixels++);
00187 p=(float *) quantum;
00188 *pixel=(*p);
00189 *pixel-=quantum_state->minimum;
00190 *pixel*=quantum_state->scale;
00191 return(pixels);
00192 }
00193
00194 static inline const unsigned char *PushQuantumPixel(
00195 QuantumState *quantum_state,const unsigned long depth,
00196 const unsigned char *pixels,unsigned long *quantum)
00197 {
00198 register long
00199 i;
00200
00201 register unsigned long
00202 quantum_bits;
00203
00204 *quantum=(QuantumAny) 0;
00205 for (i=(long) depth; i > 0L; )
00206 {
00207 if (quantum_state->bits == 0UL)
00208 {
00209 quantum_state->pixel=(*pixels++);
00210 quantum_state->bits=8UL;
00211 }
00212 quantum_bits=(unsigned long) i;
00213 if (quantum_bits > quantum_state->bits)
00214 quantum_bits=quantum_state->bits;
00215 i-=quantum_bits;
00216 quantum_state->bits-=quantum_bits;
00217 *quantum=(*quantum << quantum_bits) | ((quantum_state->pixel >>
00218 quantum_state->bits) &~ ((~0UL) << quantum_bits));
00219 }
00220 return(pixels);
00221 }
00222
00223 static inline const unsigned char *PushQuantumLongPixel(
00224 QuantumState *quantum_state,const unsigned long depth,
00225 const unsigned char *pixels,unsigned long *quantum)
00226 {
00227 register long
00228 i;
00229
00230 register unsigned long
00231 quantum_bits;
00232
00233 *quantum=0UL;
00234 for (i=(long) depth; i > 0; )
00235 {
00236 if (quantum_state->bits == 0)
00237 {
00238 pixels=PushLongPixel(quantum_state->endian,pixels,
00239 &quantum_state->pixel);
00240 quantum_state->bits=32UL;
00241 }
00242 quantum_bits=(unsigned long) i;
00243 if (quantum_bits > quantum_state->bits)
00244 quantum_bits=quantum_state->bits;
00245 *quantum|=(((quantum_state->pixel >> (32UL-quantum_state->bits)) &
00246 quantum_state->mask[quantum_bits]) << (depth-i));
00247 i-=quantum_bits;
00248 quantum_state->bits-=quantum_bits;
00249 }
00250 return(pixels);
00251 }
00252
00253 MagickExport size_t ImportQuantumPixels(Image *image,CacheView *image_view,
00254 const QuantumInfo *quantum_info,const QuantumType quantum_type,
00255 const unsigned char *pixels,ExceptionInfo *exception)
00256 {
00257 EndianType
00258 endian;
00259
00260 long
00261 bit;
00262
00263 MagickSizeType
00264 number_pixels;
00265
00266 QuantumAny
00267 range;
00268
00269 QuantumState
00270 quantum_state;
00271
00272 register const unsigned char
00273 *p;
00274
00275 register IndexPacket
00276 *indexes;
00277
00278 register long
00279 x;
00280
00281 register PixelPacket
00282 *__restrict q;
00283
00284 size_t
00285 extent;
00286
00287 unsigned long
00288 pixel;
00289
00290 assert(image != (Image *) NULL);
00291 assert(image->signature == MagickSignature);
00292 if (image->debug != MagickFalse)
00293 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
00294 assert(quantum_info != (QuantumInfo *) NULL);
00295 assert(quantum_info->signature == MagickSignature);
00296 if (pixels == (const unsigned char *) NULL)
00297 pixels=GetQuantumPixels(quantum_info);
00298 x=0;
00299 p=pixels;
00300 number_pixels=GetImageExtent(image);
00301 q=GetAuthenticPixelQueue(image);
00302 indexes=GetAuthenticIndexQueue(image);
00303 if (image_view != (CacheView *) NULL)
00304 {
00305 number_pixels=GetCacheViewExtent(image_view);
00306 q=GetCacheViewAuthenticPixelQueue(image_view);
00307 indexes=GetCacheViewAuthenticIndexQueue(image_view);
00308 }
00309 InitializeQuantumState(quantum_info,image->endian,&quantum_state);
00310 extent=GetQuantumExtent(image,quantum_info,quantum_type);
00311 endian=quantum_state.endian;
00312 switch (quantum_type)
00313 {
00314 case IndexQuantum:
00315 {
00316 MagickBooleanType
00317 range_exception;
00318
00319 if (image->storage_class != PseudoClass)
00320 {
00321 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
00322 "ColormappedImageRequired","`%s'",image->filename);
00323 return(extent);
00324 }
00325 range_exception=MagickFalse;
00326 switch (quantum_info->depth)
00327 {
00328 case 1:
00329 {
00330 register unsigned char
00331 pixel;
00332
00333 for (x=0; x < ((long) number_pixels-7); x+=8)
00334 {
00335 for (bit=0; bit < 8; bit++)
00336 {
00337 if (quantum_info->min_is_white == MagickFalse)
00338 pixel=(unsigned char) (((*p) & (1 << (7-bit))) == 0 ?
00339 0x00 : 0x01);
00340 else
00341 pixel=(unsigned char) (((*p) & (1 << (7-bit))) != 0 ?
00342 0x00 : 0x01);
00343 indexes[x+bit]=PushColormapIndex(image,pixel,&range_exception);
00344 *q=image->colormap[(long) indexes[x+bit]];
00345 q++;
00346 }
00347 p++;
00348 }
00349 for (bit=0; bit < (long) (number_pixels % 8); bit++)
00350 {
00351 if (quantum_info->min_is_white == MagickFalse)
00352 pixel=(unsigned char) (((*p) & (1 << (7-bit))) == 0 ?
00353 0x00 : 0x01);
00354 else
00355 pixel=(unsigned char) (((*p) & (1 << (7-bit))) != 0 ?
00356 0x00 : 0x01);
00357 indexes[x+bit]=PushColormapIndex(image,pixel,&range_exception);
00358 *q=image->colormap[(long) indexes[x+bit]];
00359 q++;
00360 }
00361 break;
00362 }
00363 case 4:
00364 {
00365 register unsigned char
00366 pixel;
00367
00368 for (x=0; x < ((long) number_pixels-1); x+=2)
00369 {
00370 pixel=(unsigned char) ((*p >> 4) & 0xf);
00371 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
00372 *q=image->colormap[(long) indexes[x]];
00373 q++;
00374 pixel=(unsigned char) ((*p) & 0xf);
00375 indexes[x+1]=PushColormapIndex(image,pixel,&range_exception);
00376 *q=image->colormap[(long) indexes[x+1]];
00377 p++;
00378 q++;
00379 }
00380 for (bit=0; bit < (long) (number_pixels % 2); bit++)
00381 {
00382 pixel=(unsigned char) ((*p++ >> 4) & 0xf);
00383 indexes[x+bit]=PushColormapIndex(image,pixel,&range_exception);
00384 *q=image->colormap[(long) indexes[x+bit]];
00385 q++;
00386 }
00387 break;
00388 }
00389 case 8:
00390 {
00391 unsigned char
00392 pixel;
00393
00394 for (x=0; x < (long) number_pixels; x++)
00395 {
00396 p=PushCharPixel(p,&pixel);
00397 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
00398 *q=image->colormap[(long) indexes[x]];
00399 p+=quantum_info->pad;
00400 q++;
00401 }
00402 break;
00403 }
00404 case 16:
00405 {
00406 unsigned short
00407 pixel;
00408
00409 for (x=0; x < (long) number_pixels; x++)
00410 {
00411 p=PushShortPixel(endian,p,&pixel);
00412 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
00413 *q=image->colormap[(long) indexes[x]];
00414 p+=quantum_info->pad;
00415 q++;
00416 }
00417 break;
00418 }
00419 case 32:
00420 {
00421 unsigned long
00422 pixel;
00423
00424 if (quantum_info->format == FloatingPointQuantumFormat)
00425 {
00426 float
00427 pixel;
00428
00429 for (x=0; x < (long) number_pixels; x++)
00430 {
00431 p=PushFloatPixel(&quantum_state,p,&pixel);
00432 indexes[x]=PushColormapIndex(image,RoundToQuantum(pixel),
00433 &range_exception);
00434 *q=image->colormap[(long) indexes[x]];
00435 p+=quantum_info->pad;
00436 q++;
00437 }
00438 break;
00439 }
00440 for (x=0; x < (long) number_pixels; x++)
00441 {
00442 p=PushLongPixel(endian,p,&pixel);
00443 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
00444 *q=image->colormap[(long) indexes[x]];
00445 p+=quantum_info->pad;
00446 q++;
00447 }
00448 break;
00449 }
00450 case 64:
00451 {
00452 if (quantum_info->format == FloatingPointQuantumFormat)
00453 {
00454 double
00455 pixel;
00456
00457 for (x=0; x < (long) number_pixels; x++)
00458 {
00459 p=PushDoublePixel(&quantum_state,p,&pixel);
00460 indexes[x]=PushColormapIndex(image,RoundToQuantum(pixel),
00461 &range_exception);
00462 *q=image->colormap[(long) indexes[x]];
00463 p+=quantum_info->pad;
00464 q++;
00465 }
00466 break;
00467 }
00468 }
00469 default:
00470 {
00471 for (x=0; x < (long) number_pixels; x++)
00472 {
00473 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
00474 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
00475 *q=image->colormap[(long) indexes[x]];
00476 p+=quantum_info->pad;
00477 q++;
00478 }
00479 break;
00480 }
00481 }
00482 if (range_exception != MagickFalse)
00483 (void) ThrowMagickException(exception,GetMagickModule(),
00484 CorruptImageError,"InvalidColormapIndex","`%s'",image->filename);
00485 break;
00486 }
00487 case IndexAlphaQuantum:
00488 {
00489 MagickBooleanType
00490 range_exception;
00491
00492 if (image->storage_class != PseudoClass)
00493 {
00494 (void) ThrowMagickException(exception,GetMagickModule(),
00495 ImageError,"ColormappedImageRequired","`%s'",image->filename);
00496 return(extent);
00497 }
00498 range_exception=MagickFalse;
00499 switch (quantum_info->depth)
00500 {
00501 case 1:
00502 {
00503 register unsigned char
00504 pixel;
00505
00506 for (x=0; x < ((long) number_pixels-3); x+=4)
00507 {
00508 for (bit=0; bit < 8; bit+=2)
00509 {
00510 if (quantum_info->min_is_white == MagickFalse)
00511 pixel=(unsigned char) (((*p) & (1 << (7-bit))) == 0 ?
00512 0x00 : 0x01);
00513 else
00514 pixel=(unsigned char) (((*p) & (1 << (7-bit))) != 0 ?
00515 0x00 : 0x01);
00516 indexes[x+bit/2]=(IndexPacket) (pixel == 0 ? 0 : 1);
00517 q->red=(Quantum) (pixel == 0 ? 0 : QuantumRange);
00518 q->green=q->red;
00519 q->blue=q->red;
00520 q->opacity=(Quantum) (((*p) & (1UL << (unsigned char) (6-bit)))
00521 == 0 ? TransparentOpacity : OpaqueOpacity);
00522 q++;
00523 }
00524 }
00525 for (bit=0; bit < (long) (number_pixels % 4); bit+=2)
00526 {
00527 if (quantum_info->min_is_white == MagickFalse)
00528 pixel=(unsigned char) (((*p) & (1 << (7-bit))) == 0 ?
00529 0x00 : 0x01);
00530 else
00531 pixel=(unsigned char) (((*p) & (1 << (7-bit))) != 0 ?
00532 0x00 : 0x01);
00533 indexes[x+bit/2]=(IndexPacket) (pixel == 0 ? 0 : 1);
00534 q->red=(Quantum) (pixel == 0 ? 0 : QuantumRange);
00535 q->green=q->red;
00536 q->blue=q->red;
00537 q->opacity=(Quantum) (((*p) & (1UL << (unsigned char) (6-bit))) ==
00538 0 ? TransparentOpacity : OpaqueOpacity);
00539 q++;
00540 }
00541 break;
00542 }
00543 case 4:
00544 {
00545 register unsigned char
00546 pixel;
00547
00548 range=GetQuantumRange(image->depth);
00549 for (x=0; x < (long) number_pixels; x++)
00550 {
00551 pixel=(unsigned char) ((*p >> 4) & 0xf);
00552 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
00553 *q=image->colormap[(long) indexes[x]];
00554 pixel=(unsigned char) ((*p) & 0xf);
00555 q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range));
00556 p++;
00557 q++;
00558 }
00559 break;
00560 }
00561 case 8:
00562 {
00563 unsigned char
00564 pixel;
00565
00566 for (x=0; x < (long) number_pixels; x++)
00567 {
00568 p=PushCharPixel(p,&pixel);
00569 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
00570 *q=image->colormap[(long) indexes[x]];
00571 p=PushCharPixel(p,&pixel);
00572 q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel));
00573 p+=quantum_info->pad;
00574 q++;
00575 }
00576 break;
00577 }
00578 case 16:
00579 {
00580 unsigned short
00581 pixel;
00582
00583 for (x=0; x < (long) number_pixels; x++)
00584 {
00585 p=PushShortPixel(endian,p,&pixel);
00586 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
00587 *q=image->colormap[(long) indexes[x]];
00588 p=PushShortPixel(endian,p,&pixel);
00589 q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel));
00590 p+=quantum_info->pad;
00591 q++;
00592 }
00593 break;
00594 }
00595 case 32:
00596 {
00597 unsigned long
00598 pixel;
00599
00600 if (quantum_info->format == FloatingPointQuantumFormat)
00601 {
00602 float
00603 pixel;
00604
00605 for (x=0; x < (long) number_pixels; x++)
00606 {
00607 p=PushFloatPixel(&quantum_state,p,&pixel);
00608 indexes[x]=PushColormapIndex(image,RoundToQuantum(pixel),
00609 &range_exception);
00610 *q=image->colormap[(long) indexes[x]];
00611 p=PushFloatPixel(&quantum_state,p,&pixel);
00612 q->opacity=(Quantum) (QuantumRange-RoundToQuantum(pixel));
00613 p+=quantum_info->pad;
00614 q++;
00615 }
00616 break;
00617 }
00618 for (x=0; x < (long) number_pixels; x++)
00619 {
00620 p=PushLongPixel(endian,p,&pixel);
00621 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
00622 *q=image->colormap[(long) indexes[x]];
00623 p=PushLongPixel(endian,p,&pixel);
00624 q->opacity=(Quantum) (QuantumRange-ScaleLongToQuantum(pixel));
00625 p+=quantum_info->pad;
00626 q++;
00627 }
00628 break;
00629 }
00630 case 64:
00631 {
00632 if (quantum_info->format == FloatingPointQuantumFormat)
00633 {
00634 double
00635 pixel;
00636
00637 for (x=0; x < (long) number_pixels; x++)
00638 {
00639 p=PushDoublePixel(&quantum_state,p,&pixel);
00640 indexes[x]=PushColormapIndex(image,RoundToQuantum(pixel),
00641 &range_exception);
00642 *q=image->colormap[(long) indexes[x]];
00643 p=PushDoublePixel(&quantum_state,p,&pixel);
00644 q->opacity=(Quantum) (QuantumRange-RoundToQuantum(pixel));
00645 p+=quantum_info->pad;
00646 q++;
00647 }
00648 break;
00649 }
00650 }
00651 default:
00652 {
00653 range=GetQuantumRange(image->depth);
00654 for (x=0; x < (long) number_pixels; x++)
00655 {
00656 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
00657 indexes[x]=PushColormapIndex(image,pixel,&range_exception);
00658 *q=image->colormap[(long) indexes[x]];
00659 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
00660 q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range));
00661 p+=quantum_info->pad;
00662 q++;
00663 }
00664 break;
00665 }
00666 }
00667 if (range_exception != MagickFalse)
00668 (void) ThrowMagickException(exception,GetMagickModule(),
00669 CorruptImageError,"InvalidColormapIndex","`%s'",image->filename);
00670 break;
00671 }
00672 case GrayQuantum:
00673 {
00674 switch (quantum_info->depth)
00675 {
00676 case 1:
00677 {
00678 register Quantum
00679 black,
00680 white;
00681
00682 black=0;
00683 white=(Quantum) QuantumRange;
00684 if (quantum_info->min_is_white != MagickFalse)
00685 {
00686 black=(Quantum) QuantumRange;
00687 white=0;
00688 }
00689 for (x=0; x < ((long) number_pixels-7); x+=8)
00690 {
00691 for (bit=0; bit < 8; bit++)
00692 {
00693 q->red=(((*p) & (1 << (7-bit))) == 0 ? black : white);
00694 q->green=q->red;
00695 q->blue=q->red;
00696 q++;
00697 }
00698 p++;
00699 }
00700 for (bit=0; bit < (long) (number_pixels % 8); bit++)
00701 {
00702 q->red=(((*p) & (1 << (7-bit))) == 0 ? black : white);
00703 q->green=q->red;
00704 q->blue=q->red;
00705 q++;
00706 }
00707 if (bit != 0)
00708 p++;
00709 break;
00710 }
00711 case 4:
00712 {
00713 register unsigned char
00714 pixel;
00715
00716 range=GetQuantumRange(image->depth);
00717 for (x=0; x < ((long) number_pixels-1); x+=2)
00718 {
00719 pixel=(unsigned char) ((*p >> 4) & 0xf);
00720 q->red=ScaleAnyToQuantum(pixel,range);
00721 q->green=q->red;
00722 q->blue=q->red;
00723 q++;
00724 pixel=(unsigned char) ((*p) & 0xf);
00725 q->red=ScaleAnyToQuantum(pixel,range);
00726 q->green=q->red;
00727 q->blue=q->red;
00728 p++;
00729 q++;
00730 }
00731 for (bit=0; bit < (long) (number_pixels % 2); bit++)
00732 {
00733 pixel=(unsigned char) (*p++ >> 4);
00734 q->red=ScaleAnyToQuantum(pixel,range);
00735 q->green=q->red;
00736 q->blue=q->red;
00737 q++;
00738 }
00739 break;
00740 }
00741 case 8:
00742 {
00743 unsigned char
00744 pixel;
00745
00746 if (quantum_info->min_is_white != MagickFalse)
00747 {
00748 for (x=0; x < (long) number_pixels; x++)
00749 {
00750 p=PushCharPixel(p,&pixel);
00751 q->red=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel));
00752 q->green=q->red;
00753 q->blue=q->red;
00754 q->opacity=OpaqueOpacity;
00755 p+=quantum_info->pad;
00756 q++;
00757 }
00758 break;
00759 }
00760 for (x=0; x < (long) number_pixels; x++)
00761 {
00762 p=PushCharPixel(p,&pixel);
00763 q->red=ScaleCharToQuantum(pixel);
00764 q->green=q->red;
00765 q->blue=q->red;
00766 q->opacity=OpaqueOpacity;
00767 p+=quantum_info->pad;
00768 q++;
00769 }
00770 break;
00771 }
00772 case 10:
00773 {
00774 range=GetQuantumRange(image->depth);
00775 if (quantum_info->pack == MagickFalse)
00776 {
00777 if (image->endian != LSBEndian)
00778 {
00779 for (x=0; x < (long) number_pixels/3; x++)
00780 {
00781 p=PushLongPixel(endian,p,&pixel);
00782 q->red=ScaleAnyToQuantum((pixel >> 0) & 0x3ff,range);
00783 q->green=q->red;
00784 q->blue=q->red;
00785 q++;
00786 q->red=ScaleAnyToQuantum((pixel >> 10) & 0x3ff,range);
00787 q->green=q->red;
00788 q->blue=q->red;
00789 q++;
00790 q->red=ScaleAnyToQuantum((pixel >> 20) & 0x3ff,range);
00791 q->green=q->red;
00792 q->blue=q->red;
00793 p+=quantum_info->pad;
00794 q++;
00795 }
00796 break;
00797 }
00798 for (x=0; x < (long) number_pixels/3; x++)
00799 {
00800 p=PushLongPixel(endian,p,&pixel);
00801 q->red=ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range);
00802 q->green=q->red;
00803 q->blue=q->red;
00804 q++;
00805 q->red=ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range);
00806 q->green=q->red;
00807 q->blue=q->red;
00808 q++;
00809 q->red=ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range);
00810 q->green=q->red;
00811 q->blue=q->red;
00812 p+=quantum_info->pad;
00813 q++;
00814 }
00815 break;
00816 }
00817 for (x=0; x < (long) number_pixels; x++)
00818 {
00819 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
00820 q->red=ScaleAnyToQuantum(pixel,range);
00821 q->green=q->red;
00822 q->blue=q->red;
00823 p+=quantum_info->pad;
00824 q++;
00825 }
00826 break;
00827 }
00828 case 12:
00829 {
00830 range=GetQuantumRange(image->depth);
00831 if (quantum_info->pack == MagickFalse)
00832 {
00833 unsigned short
00834 pixel;
00835
00836 for (x=0; x < (long) (number_pixels-1); x+=2)
00837 {
00838 p=PushShortPixel(endian,p,&pixel);
00839 q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
00840 q->green=q->red;
00841 q->blue=q->red;
00842 q++;
00843 p=PushShortPixel(endian,p,&pixel);
00844 q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
00845 q->green=q->red;
00846 q->blue=q->red;
00847 p+=quantum_info->pad;
00848 q++;
00849 }
00850 for (bit=0; bit < (long) (number_pixels % 2); bit++)
00851 {
00852 p=PushShortPixel(endian,p,&pixel);
00853 q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
00854 q->green=q->red;
00855 q->blue=q->red;
00856 p+=quantum_info->pad;
00857 q++;
00858 }
00859 if (bit != 0)
00860 p++;
00861 break;
00862 }
00863 for (x=0; x < (long) number_pixels; x++)
00864 {
00865 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
00866 q->red=ScaleAnyToQuantum(pixel,range);
00867 q->green=q->red;
00868 q->blue=q->red;
00869 p+=quantum_info->pad;
00870 q++;
00871 }
00872 break;
00873 }
00874 case 16:
00875 {
00876 unsigned short
00877 pixel;
00878
00879 if (quantum_info->min_is_white != MagickFalse)
00880 {
00881 for (x=0; x < (long) number_pixels; x++)
00882 {
00883 p=PushShortPixel(endian,p,&pixel);
00884 q->red=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel));
00885 q->green=q->red;
00886 q->blue=q->red;
00887 p+=quantum_info->pad;
00888 q++;
00889 }
00890 break;
00891 }
00892 for (x=0; x < (long) number_pixels; x++)
00893 {
00894 p=PushShortPixel(endian,p,&pixel);
00895 q->red=ScaleShortToQuantum(pixel);
00896 q->green=q->red;
00897 q->blue=q->red;
00898 p+=quantum_info->pad;
00899 q++;
00900 }
00901 break;
00902 }
00903 case 32:
00904 {
00905 unsigned long
00906 pixel;
00907
00908 if (quantum_info->format == FloatingPointQuantumFormat)
00909 {
00910 float
00911 pixel;
00912
00913 for (x=0; x < (long) number_pixels; x++)
00914 {
00915 p=PushFloatPixel(&quantum_state,p,&pixel);
00916 q->red=RoundToQuantum(pixel);
00917 q->green=q->red;
00918 q->blue=q->red;
00919 p+=quantum_info->pad;
00920 q++;
00921 }
00922 break;
00923 }
00924 for (x=0; x < (long) number_pixels; x++)
00925 {
00926 p=PushLongPixel(endian,p,&pixel);
00927 q->red=ScaleLongToQuantum(pixel);
00928 q->green=q->red;
00929 q->blue=q->red;
00930 p+=quantum_info->pad;
00931 q++;
00932 }
00933 break;
00934 }
00935 case 64:
00936 {
00937 if (quantum_info->format == FloatingPointQuantumFormat)
00938 {
00939 double
00940 pixel;
00941
00942 for (x=0; x < (long) number_pixels; x++)
00943 {
00944 p=PushDoublePixel(&quantum_state,p,&pixel);
00945 q->red=RoundToQuantum(pixel);
00946 q->green=q->red;
00947 q->blue=q->red;
00948 p+=quantum_info->pad;
00949 q++;
00950 }
00951 break;
00952 }
00953 }
00954 default:
00955 {
00956 range=GetQuantumRange(image->depth);
00957 for (x=0; x < (long) number_pixels; x++)
00958 {
00959 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
00960 q->red=ScaleAnyToQuantum(pixel,range);
00961 q->green=q->red;
00962 q->blue=q->red;
00963 p+=quantum_info->pad;
00964 q++;
00965 }
00966 break;
00967 }
00968 }
00969 break;
00970 }
00971 case GrayAlphaQuantum:
00972 {
00973 switch (quantum_info->depth)
00974 {
00975 case 1:
00976 {
00977 register unsigned char
00978 pixel;
00979
00980 for (x=0; x < ((long) number_pixels-3); x+=4)
00981 {
00982 for (bit=0; bit < 8; bit+=2)
00983 {
00984 pixel=(unsigned char)
00985 (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
00986 q->red=(Quantum) (pixel == 0 ? 0 : QuantumRange);
00987 q->green=q->red;
00988 q->blue=q->red;
00989 q->opacity=(Quantum) (((*p) & (1UL << (unsigned char) (6-bit)))
00990 == 0 ? TransparentOpacity : OpaqueOpacity);
00991 q++;
00992 }
00993 p++;
00994 }
00995 for (bit=0; bit < (long) (number_pixels % 4); bit+=2)
00996 {
00997 pixel=(unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
00998 q->red=(Quantum) (pixel == 0 ? 0 : QuantumRange);
00999 q->green=q->red;
01000 q->blue=q->red;
01001 q->opacity=(Quantum) (((*p) & (1UL << (unsigned char) (6-bit))) == 0
01002 ? TransparentOpacity : OpaqueOpacity);
01003 q++;
01004 }
01005 if (bit != 0)
01006 p++;
01007 break;
01008 }
01009 case 4:
01010 {
01011 register unsigned char
01012 pixel;
01013
01014 range=GetQuantumRange(image->depth);
01015 for (x=0; x < (long) number_pixels; x++)
01016 {
01017 pixel=(unsigned char) ((*p >> 4) & 0xf);
01018 q->red=ScaleAnyToQuantum(pixel,range);
01019 q->green=q->red;
01020 q->blue=q->red;
01021 pixel=(unsigned char) ((*p) & 0xf);
01022 q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range));
01023 p++;
01024 q++;
01025 }
01026 break;
01027 }
01028 case 8:
01029 {
01030 unsigned char
01031 pixel;
01032
01033 for (x=0; x < (long) number_pixels; x++)
01034 {
01035 p=PushCharPixel(p,&pixel);
01036 q->red=ScaleCharToQuantum(pixel);
01037 q->green=q->red;
01038 q->blue=q->red;
01039 p=PushCharPixel(p,&pixel);
01040 q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel));
01041 p+=quantum_info->pad;
01042 q++;
01043 }
01044 break;
01045 }
01046 case 10:
01047 {
01048 range=GetQuantumRange(image->depth);
01049 for (x=0; x < (long) number_pixels; x++)
01050 {
01051 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
01052 q->red=ScaleAnyToQuantum(pixel,range);
01053 q->green=q->red;
01054 q->blue=q->red;
01055 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
01056 q->opacity=ScaleAnyToQuantum(pixel,range);
01057 p+=quantum_info->pad;
01058 q++;
01059 }
01060 break;
01061 }
01062 case 12:
01063 {
01064 range=GetQuantumRange(image->depth);
01065 for (x=0; x < (long) number_pixels; x++)
01066 {
01067 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
01068 q->red=ScaleAnyToQuantum(pixel,range);
01069 q->green=q->red;
01070 q->blue=q->red;
01071 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
01072 q->opacity=ScaleAnyToQuantum(pixel,range);
01073 p+=quantum_info->pad;
01074 q++;
01075 }
01076 break;
01077 }
01078 case 16:
01079 {
01080 unsigned short
01081 pixel;
01082
01083 for (x=0; x < (long) number_pixels; x++)
01084 {
01085 p=PushShortPixel(endian,p,&pixel);
01086 q->red=ScaleShortToQuantum(pixel);
01087 q->green=q->red;
01088 q->blue=q->red;
01089 p=PushShortPixel(endian,p,&pixel);
01090 q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel));
01091 p+=quantum_info->pad;
01092 q++;
01093 }
01094 break;
01095 }
01096 case 32:
01097 {
01098 unsigned long
01099 pixel;
01100
01101 if (quantum_info->format == FloatingPointQuantumFormat)
01102 {
01103 float
01104 pixel;
01105
01106 for (x=0; x < (long) number_pixels; x++)
01107 {
01108 p=PushFloatPixel(&quantum_state,p,&pixel);
01109 q->red=RoundToQuantum(pixel);
01110 q->green=q->red;
01111 q->blue=q->red;
01112 p=PushFloatPixel(&quantum_state,p,&pixel);
01113 q->opacity=(Quantum) (QuantumRange-RoundToQuantum(pixel));
01114 p+=quantum_info->pad;
01115 q++;
01116 }
01117 break;
01118 }
01119 for (x=0; x < (long) number_pixels; x++)
01120 {
01121 p=PushLongPixel(endian,p,&pixel);
01122 q->red=ScaleLongToQuantum(pixel);
01123 q->green=q->red;
01124 q->blue=q->red;
01125 p=PushLongPixel(endian,p,&pixel);
01126 q->opacity=(Quantum) (QuantumRange-ScaleLongToQuantum(pixel));
01127 p+=quantum_info->pad;
01128 q++;
01129 }
01130 break;
01131 }
01132 case 64:
01133 {
01134 if (quantum_info->format == FloatingPointQuantumFormat)
01135 {
01136 double
01137 pixel;
01138
01139 for (x=0; x < (long) number_pixels; x++)
01140 {
01141 p=PushDoublePixel(&quantum_state,p,&pixel);
01142 q->red=RoundToQuantum(pixel);
01143 q->green=q->red;
01144 q->blue=q->red;
01145 p=PushDoublePixel(&quantum_state,p,&pixel);
01146 q->opacity=(Quantum) (QuantumRange-RoundToQuantum(pixel));
01147 p+=quantum_info->pad;
01148 q++;
01149 }
01150 break;
01151 }
01152 }
01153 default:
01154 {
01155 range=GetQuantumRange(image->depth);
01156 for (x=0; x < (long) number_pixels; x++)
01157 {
01158 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
01159 q->red=ScaleAnyToQuantum(pixel,range);
01160 q->green=q->red;
01161 q->blue=q->red;
01162 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
01163 q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range));
01164 p+=quantum_info->pad;
01165 q++;
01166 }
01167 break;
01168 }
01169 }
01170 break;
01171 }
01172 case RedQuantum:
01173 case CyanQuantum:
01174 {
01175 switch (quantum_info->depth)
01176 {
01177 case 8:
01178 {
01179 unsigned char
01180 pixel;
01181
01182 for (x=0; x < (long) number_pixels; x++)
01183 {
01184 p=PushCharPixel(p,&pixel);
01185 q->red=ScaleCharToQuantum(pixel);
01186 p+=quantum_info->pad;
01187 q++;
01188 }
01189 break;
01190 }
01191 case 16:
01192 {
01193 unsigned short
01194 pixel;
01195
01196 for (x=0; x < (long) number_pixels; x++)
01197 {
01198 p=PushShortPixel(endian,p,&pixel);
01199 q->red=ScaleShortToQuantum(pixel);
01200 p+=quantum_info->pad;
01201 q++;
01202 }
01203 break;
01204 }
01205 case 32:
01206 {
01207 unsigned long
01208 pixel;
01209
01210 if (quantum_info->format == FloatingPointQuantumFormat)
01211 {
01212 float
01213 pixel;
01214
01215 for (x=0; x < (long) number_pixels; x++)
01216 {
01217 p=PushFloatPixel(&quantum_state,p,&pixel);
01218 q->red=RoundToQuantum(pixel);
01219 p+=quantum_info->pad;
01220 q++;
01221 }
01222 break;
01223 }
01224 for (x=0; x < (long) number_pixels; x++)
01225 {
01226 p=PushLongPixel(endian,p,&pixel);
01227 q->red=ScaleLongToQuantum(pixel);
01228 p+=quantum_info->pad;
01229 q++;
01230 }
01231 break;
01232 }
01233 case 64:
01234 {
01235 if (quantum_info->format == FloatingPointQuantumFormat)
01236 {
01237 double
01238 pixel;
01239
01240 for (x=0; x < (long) number_pixels; x++)
01241 {
01242 p=PushDoublePixel(&quantum_state,p,&pixel);
01243 q->red=RoundToQuantum(pixel);
01244 p+=quantum_info->pad;
01245 q++;
01246 }
01247 break;
01248 }
01249 }
01250 default:
01251 {
01252 range=GetQuantumRange(image->depth);
01253 for (x=0; x < (long) number_pixels; x++)
01254 {
01255 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
01256 q->red=ScaleAnyToQuantum(pixel,range);
01257 p+=quantum_info->pad;
01258 q++;
01259 }
01260 break;
01261 }
01262 }
01263 break;
01264 }
01265 case GreenQuantum:
01266 case MagentaQuantum:
01267 {
01268 switch (quantum_info->depth)
01269 {
01270 case 8:
01271 {
01272 unsigned char
01273 pixel;
01274
01275 for (x=0; x < (long) number_pixels; x++)
01276 {
01277 p=PushCharPixel(p,&pixel);
01278 q->green=ScaleCharToQuantum(pixel);
01279 p+=quantum_info->pad;
01280 q++;
01281 }
01282 break;
01283 }
01284 case 16:
01285 {
01286 unsigned short
01287 pixel;
01288
01289 for (x=0; x < (long) number_pixels; x++)
01290 {
01291 p=PushShortPixel(endian,p,&pixel);
01292 q->green=ScaleShortToQuantum(pixel);
01293 p+=quantum_info->pad;
01294 q++;
01295 }
01296 break;
01297 }
01298 case 32:
01299 {
01300 unsigned long
01301 pixel;
01302
01303 if (quantum_info->format == FloatingPointQuantumFormat)
01304 {
01305 float
01306 pixel;
01307
01308 for (x=0; x < (long) number_pixels; x++)
01309 {
01310 p=PushFloatPixel(&quantum_state,p,&pixel);
01311 q->green=RoundToQuantum(pixel);
01312 p+=quantum_info->pad;
01313 q++;
01314 }
01315 break;
01316 }
01317 for (x=0; x < (long) number_pixels; x++)
01318 {
01319 p=PushLongPixel(endian,p,&pixel);
01320 q->green=ScaleLongToQuantum(pixel);
01321 p+=quantum_info->pad;
01322 q++;
01323 }
01324 break;
01325 }
01326 case 64:
01327 {
01328 if (quantum_info->format == FloatingPointQuantumFormat)
01329 {
01330 double
01331 pixel;
01332
01333 for (x=0; x < (long) number_pixels; x++)
01334 {
01335 p=PushDoublePixel(&quantum_state,p,&pixel);
01336 q->green=RoundToQuantum(pixel);
01337 p+=quantum_info->pad;
01338 q++;
01339 }
01340 break;
01341 }
01342 }
01343 default:
01344 {
01345 range=GetQuantumRange(image->depth);
01346 for (x=0; x < (long) number_pixels; x++)
01347 {
01348 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
01349 q->green=ScaleAnyToQuantum(pixel,range);
01350 p+=quantum_info->pad;
01351 q++;
01352 }
01353 break;
01354 }
01355 }
01356 break;
01357 }
01358 case BlueQuantum:
01359 case YellowQuantum:
01360 {
01361 switch (quantum_info->depth)
01362 {
01363 case 8:
01364 {
01365 unsigned char
01366 pixel;
01367
01368 for (x=0; x < (long) number_pixels; x++)
01369 {
01370 p=PushCharPixel(p,&pixel);
01371 q->blue=ScaleCharToQuantum(pixel);
01372 p+=quantum_info->pad;
01373 q++;
01374 }
01375 break;
01376 }
01377 case 16:
01378 {
01379 unsigned short
01380 pixel;
01381
01382 for (x=0; x < (long) number_pixels; x++)
01383 {
01384 p=PushShortPixel(endian,p,&pixel);
01385 q->blue=ScaleShortToQuantum(pixel);
01386 p+=quantum_info->pad;
01387 q++;
01388 }
01389 break;
01390 }
01391 case 32:
01392 {
01393 unsigned long
01394 pixel;
01395
01396 if (quantum_info->format == FloatingPointQuantumFormat)
01397 {
01398 float
01399 pixel;
01400
01401 for (x=0; x < (long) number_pixels; x++)
01402 {
01403 p=PushFloatPixel(&quantum_state,p,&pixel);
01404 q->blue=RoundToQuantum(pixel);
01405 p+=quantum_info->pad;
01406 q++;
01407 }
01408 break;
01409 }
01410 for (x=0; x < (long) number_pixels; x++)
01411 {
01412 p=PushLongPixel(endian,p,&pixel);
01413 q->blue=ScaleLongToQuantum(pixel);
01414 p+=quantum_info->pad;
01415 q++;
01416 }
01417 break;
01418 }
01419 case 64:
01420 {
01421 if (quantum_info->format == FloatingPointQuantumFormat)
01422 {
01423 double
01424 pixel;
01425
01426 for (x=0; x < (long) number_pixels; x++)
01427 {
01428 p=PushDoublePixel(&quantum_state,p,&pixel);
01429 q->blue=RoundToQuantum(pixel);
01430 p+=quantum_info->pad;
01431 q++;
01432 }
01433 break;
01434 }
01435 }
01436 default:
01437 {
01438 range=GetQuantumRange(image->depth);
01439 for (x=0; x < (long) number_pixels; x++)
01440 {
01441 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
01442 q->blue=ScaleAnyToQuantum(pixel,range);
01443 p+=quantum_info->pad;
01444 q++;
01445 }
01446 break;
01447 }
01448 }
01449 break;
01450 }
01451 case AlphaQuantum:
01452 {
01453 switch (quantum_info->depth)
01454 {
01455 case 8:
01456 {
01457 unsigned char
01458 pixel;
01459
01460 for (x=0; x < (long) number_pixels; x++)
01461 {
01462 p=PushCharPixel(p,&pixel);
01463 q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel));
01464 p+=quantum_info->pad;
01465 q++;
01466 }
01467 break;
01468 }
01469 case 16:
01470 {
01471 unsigned short
01472 pixel;
01473
01474 for (x=0; x < (long) number_pixels; x++)
01475 {
01476 p=PushShortPixel(endian,p,&pixel);
01477 q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel));
01478 p+=quantum_info->pad;
01479 q++;
01480 }
01481 break;
01482 }
01483 case 32:
01484 {
01485 unsigned long
01486 pixel;
01487
01488 if (quantum_info->format == FloatingPointQuantumFormat)
01489 {
01490 float
01491 pixel;
01492
01493 for (x=0; x < (long) number_pixels; x++)
01494 {
01495 p=PushFloatPixel(&quantum_state,p,&pixel);
01496 q->opacity=(Quantum) (QuantumRange-RoundToQuantum(pixel));
01497 p+=quantum_info->pad;
01498 q++;
01499 }
01500 break;
01501 }
01502 for (x=0; x < (long) number_pixels; x++)
01503 {
01504 p=PushLongPixel(endian,p,&pixel);
01505 q->opacity=(Quantum) (QuantumRange-ScaleLongToQuantum(pixel));
01506 p+=quantum_info->pad;
01507 q++;
01508 }
01509 break;
01510 }
01511 case 64:
01512 {
01513 if (quantum_info->format == FloatingPointQuantumFormat)
01514 {
01515 double
01516 pixel;
01517
01518 for (x=0; x < (long) number_pixels; x++)
01519 {
01520 p=PushDoublePixel(&quantum_state,p,&pixel);
01521 q->opacity=(Quantum) (QuantumRange-RoundToQuantum(pixel));
01522 p+=quantum_info->pad;
01523 q++;
01524 }
01525 break;
01526 }
01527 }
01528 default:
01529 {
01530 range=GetQuantumRange(image->depth);
01531 for (x=0; x < (long) number_pixels; x++)
01532 {
01533 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
01534 q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range));
01535 p+=quantum_info->pad;
01536 q++;
01537 }
01538 break;
01539 }
01540 }
01541 break;
01542 }
01543 case BlackQuantum:
01544 {
01545 if (image->colorspace != CMYKColorspace)
01546 {
01547 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
01548 "ColorSeparatedImageRequired","`%s'",image->filename);
01549 return(extent);
01550 }
01551 switch (quantum_info->depth)
01552 {
01553 case 8:
01554 {
01555 unsigned char
01556 pixel;
01557
01558 for (x=0; x < (long) number_pixels; x++)
01559 {
01560 p=PushCharPixel(p,&pixel);
01561 indexes[x]=ScaleCharToQuantum(pixel);
01562 p+=quantum_info->pad;
01563 }
01564 break;
01565 }
01566 case 16:
01567 {
01568 unsigned short
01569 pixel;
01570
01571 for (x=0; x < (long) number_pixels; x++)
01572 {
01573 p=PushShortPixel(endian,p,&pixel);
01574 indexes[x]=ScaleShortToQuantum(pixel);
01575 p+=quantum_info->pad;
01576 }
01577 break;
01578 }
01579 case 32:
01580 {
01581 unsigned long
01582 pixel;
01583
01584 if (quantum_info->format == FloatingPointQuantumFormat)
01585 {
01586 float
01587 pixel;
01588
01589 for (x=0; x < (long) number_pixels; x++)
01590 {
01591 p=PushFloatPixel(&quantum_state,p,&pixel);
01592 indexes[x]=RoundToQuantum(pixel);
01593 p+=quantum_info->pad;
01594 q++;
01595 }
01596 break;
01597 }
01598 for (x=0; x < (long) number_pixels; x++)
01599 {
01600 p=PushLongPixel(endian,p,&pixel);
01601 indexes[x]=ScaleLongToQuantum(pixel);
01602 p+=quantum_info->pad;
01603 q++;
01604 }
01605 break;
01606 }
01607 case 64:
01608 {
01609 if (quantum_info->format == FloatingPointQuantumFormat)
01610 {
01611 double
01612 pixel;
01613
01614 for (x=0; x < (long) number_pixels; x++)
01615 {
01616 p=PushDoublePixel(&quantum_state,p,&pixel);
01617 indexes[x]=RoundToQuantum(pixel);
01618 p+=quantum_info->pad;
01619 q++;
01620 }
01621 break;
01622 }
01623 }
01624 default:
01625 {
01626 range=GetQuantumRange(image->depth);
01627 for (x=0; x < (long) number_pixels; x++)
01628 {
01629 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
01630 indexes[x]=ScaleAnyToQuantum(pixel,range);
01631 p+=quantum_info->pad;
01632 q++;
01633 }
01634 break;
01635 }
01636 }
01637 break;
01638 }
01639 case RGBQuantum:
01640 case CbYCrQuantum:
01641 {
01642 switch (quantum_info->depth)
01643 {
01644 case 8:
01645 {
01646 unsigned char
01647 pixel;
01648
01649 for (x=0; x < (long) number_pixels; x++)
01650 {
01651 p=PushCharPixel(p,&pixel);
01652 q->red=ScaleCharToQuantum(pixel);
01653 p=PushCharPixel(p,&pixel);
01654 q->green=ScaleCharToQuantum(pixel);
01655 p=PushCharPixel(p,&pixel);
01656 q->blue=ScaleCharToQuantum(pixel);
01657 q->opacity=OpaqueOpacity;
01658 p+=quantum_info->pad;
01659 q++;
01660 }
01661 break;
01662 }
01663 case 10:
01664 {
01665 range=GetQuantumRange(image->depth);
01666 if (quantum_info->pack == MagickFalse)
01667 {
01668 for (x=0; x < (long) number_pixels; x++)
01669 {
01670 p=PushLongPixel(endian,p,&pixel);
01671 q->red=ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range);
01672 q->green=ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range);
01673 q->blue=ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range);
01674 p+=quantum_info->pad;
01675 q++;
01676 }
01677 break;
01678 }
01679 if (quantum_info->quantum == 32UL)
01680 {
01681 for (x=0; x < (long) number_pixels; x++)
01682 {
01683 p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel);
01684 q->red=ScaleAnyToQuantum(pixel,range);
01685 p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel);
01686 q->green=ScaleAnyToQuantum(pixel,range);
01687 p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel);
01688 q->blue=ScaleAnyToQuantum(pixel,range);
01689 q++;
01690 }
01691 break;
01692 }
01693 for (x=0; x < (long) number_pixels; x++)
01694 {
01695 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
01696 q->red=ScaleAnyToQuantum(pixel,range);
01697 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
01698 q->green=ScaleAnyToQuantum(pixel,range);
01699 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
01700 q->blue=ScaleAnyToQuantum(pixel,range);
01701 q++;
01702 }
01703 break;
01704 }
01705 case 12:
01706 {
01707 range=GetQuantumRange(image->depth);
01708 if (quantum_info->pack == MagickFalse)
01709 {
01710 unsigned short
01711 pixel;
01712
01713 for (x=0; x < (long) (3*number_pixels-1); x+=2)
01714 {
01715 p=PushShortPixel(endian,p,&pixel);
01716 switch (x % 3)
01717 {
01718 default:
01719 case 0:
01720 {
01721 q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
01722 break;
01723 }
01724 case 1:
01725 {
01726 q->green=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
01727 break;
01728 }
01729 case 2:
01730 {
01731 q->blue=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
01732 q++;
01733 break;
01734 }
01735 }
01736 p=PushShortPixel(endian,p,&pixel);
01737 switch ((x+1) % 3)
01738 {
01739 default:
01740 case 0:
01741 {
01742 q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
01743 break;
01744 }
01745 case 1:
01746 {
01747 q->green=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
01748 break;
01749 }
01750 case 2:
01751 {
01752 q->blue=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
01753 q++;
01754 break;
01755 }
01756 }
01757 p+=quantum_info->pad;
01758 }
01759 for (bit=0; bit < (long) (3*number_pixels % 2); bit++)
01760 {
01761 p=PushShortPixel(endian,p,&pixel);
01762 switch ((x+bit) % 3)
01763 {
01764 default:
01765 case 0:
01766 {
01767 q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
01768 break;
01769 }
01770 case 1:
01771 {
01772 q->green=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
01773 break;
01774 }
01775 case 2:
01776 {
01777 q->blue=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
01778 q++;
01779 break;
01780 }
01781 }
01782 p+=quantum_info->pad;
01783 }
01784 if (bit != 0)
01785 p++;
01786 break;
01787 }
01788 if (quantum_info->quantum == 32UL)
01789 {
01790 for (x=0; x < (long) number_pixels; x++)
01791 {
01792 p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel);
01793 q->red=ScaleAnyToQuantum(pixel,range);
01794 p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel);
01795 q->green=ScaleAnyToQuantum(pixel,range);
01796 p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel);
01797 q->blue=ScaleAnyToQuantum(pixel,range);
01798 q++;
01799 }
01800 break;
01801 }
01802 for (x=0; x < (long) number_pixels; x++)
01803 {
01804 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
01805 q->red=ScaleAnyToQuantum(pixel,range);
01806 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
01807 q->green=ScaleAnyToQuantum(pixel,range);
01808 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
01809 q->blue=ScaleAnyToQuantum(pixel,range);
01810 q++;
01811 }
01812 break;
01813 }
01814 case 16:
01815 {
01816 unsigned short
01817 pixel;
01818
01819 for (x=0; x < (long) number_pixels; x++)
01820 {
01821 p=PushShortPixel(endian,p,&pixel);
01822 q->red=ScaleShortToQuantum(pixel);
01823 p=PushShortPixel(endian,p,&pixel);
01824 q->green=ScaleShortToQuantum(pixel);
01825 p=PushShortPixel(endian,p,&pixel);
01826 q->blue=ScaleShortToQuantum(pixel);
01827 p+=quantum_info->pad;
01828 q++;
01829 }
01830 break;
01831 }
01832 case 32:
01833 {
01834 unsigned long
01835 pixel;
01836
01837 if (quantum_info->format == FloatingPointQuantumFormat)
01838 {
01839 float
01840 pixel;
01841
01842 for (x=0; x < (long) number_pixels; x++)
01843 {
01844 p=PushFloatPixel(&quantum_state,p,&pixel);
01845 q->red=RoundToQuantum(pixel);
01846 p=PushFloatPixel(&quantum_state,p,&pixel);
01847 q->green=RoundToQuantum(pixel);
01848 p=PushFloatPixel(&quantum_state,p,&pixel);
01849 q->blue=RoundToQuantum(pixel);
01850 p+=quantum_info->pad;
01851 q++;
01852 }
01853 break;
01854 }
01855 for (x=0; x < (long) number_pixels; x++)
01856 {
01857 p=PushLongPixel(endian,p,&pixel);
01858 q->red=ScaleLongToQuantum(pixel);
01859 p=PushLongPixel(endian,p,&pixel);
01860 q->green=ScaleLongToQuantum(pixel);
01861 p=PushLongPixel(endian,p,&pixel);
01862 q->blue=ScaleLongToQuantum(pixel);
01863 p+=quantum_info->pad;
01864 q++;
01865 }
01866 break;
01867 }
01868 case 64:
01869 {
01870 if (quantum_info->format == FloatingPointQuantumFormat)
01871 {
01872 double
01873 pixel;
01874
01875 for (x=0; x < (long) number_pixels; x++)
01876 {
01877 p=PushDoublePixel(&quantum_state,p,&pixel);
01878 q->red=RoundToQuantum(pixel);
01879 p=PushDoublePixel(&quantum_state,p,&pixel);
01880 q->green=RoundToQuantum(pixel);
01881 p=PushDoublePixel(&quantum_state,p,&pixel);
01882 q->blue=RoundToQuantum(pixel);
01883 p+=quantum_info->pad;
01884 q++;
01885 }
01886 break;
01887 }
01888 }
01889 default:
01890 {
01891 range=GetQuantumRange(image->depth);
01892 for (x=0; x < (long) number_pixels; x++)
01893 {
01894 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
01895 q->red=ScaleAnyToQuantum(pixel,range);
01896 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
01897 q->green=ScaleAnyToQuantum(pixel,range);
01898 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
01899 q->blue=ScaleAnyToQuantum(pixel,range);
01900 q++;
01901 }
01902 break;
01903 }
01904 }
01905 break;
01906 }
01907 case RGBAQuantum:
01908 case RGBOQuantum:
01909 case CbYCrAQuantum:
01910 {
01911 switch (quantum_info->depth)
01912 {
01913 case 8:
01914 {
01915 unsigned char
01916 pixel;
01917
01918 for (x=0; x < (long) number_pixels; x++)
01919 {
01920 p=PushCharPixel(p,&pixel);
01921 q->red=ScaleCharToQuantum(pixel);
01922 p=PushCharPixel(p,&pixel);
01923 q->green=ScaleCharToQuantum(pixel);
01924 p=PushCharPixel(p,&pixel);
01925 q->blue=ScaleCharToQuantum(pixel);
01926 p=PushCharPixel(p,&pixel);
01927 q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel));
01928 p+=quantum_info->pad;
01929 q++;
01930 }
01931 break;
01932 }
01933 case 10:
01934 {
01935 pixel=0;
01936 if (quantum_info->pack == MagickFalse)
01937 {
01938 long
01939 n;
01940
01941 register long
01942 i;
01943
01944 unsigned long
01945 quantum;
01946
01947 n=0;
01948 quantum=0;
01949 for (x=0; x < (long) number_pixels; x++)
01950 {
01951 for (i=0; i < 4; i++)
01952 {
01953 switch (n % 3)
01954 {
01955 case 0:
01956 {
01957 p=PushLongPixel(endian,p,&pixel);
01958 quantum=(unsigned long) (ScaleShortToQuantum(
01959 (unsigned short) (((pixel >> 22) & 0x3ff) << 6)));
01960 break;
01961 }
01962 case 1:
01963 {
01964 quantum=(unsigned long) (ScaleShortToQuantum(
01965 (unsigned short) (((pixel >> 12) & 0x3ff) << 6)));
01966 break;
01967 }
01968 case 2:
01969 {
01970 quantum=(unsigned long) (ScaleShortToQuantum(
01971 (unsigned short) (((pixel >> 2) & 0x3ff) << 6)));
01972 break;
01973 }
01974 }
01975 switch (i)
01976 {
01977 case 0: q->red=(Quantum) (quantum); break;
01978 case 1: q->green=(Quantum) (quantum); break;
01979 case 2: q->blue=(Quantum) (quantum); break;
01980 case 3: q->opacity=(Quantum) (QuantumRange-quantum); break;
01981 }
01982 n++;
01983 }
01984 p+=quantum_info->pad;
01985 q++;
01986 }
01987 break;
01988 }
01989 for (x=0; x < (long) number_pixels; x++)
01990 {
01991 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
01992 q->red=ScaleShortToQuantum((unsigned short) (pixel << 6));
01993 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
01994 q->green=ScaleShortToQuantum((unsigned short) (pixel << 6));
01995 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
01996 q->blue=ScaleShortToQuantum((unsigned short) (pixel << 6));
01997 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
01998 q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(
01999 (unsigned short) (pixel << 6)));
02000 q++;
02001 }
02002 break;
02003 }
02004 case 16:
02005 {
02006 unsigned short
02007 pixel;
02008
02009 for (x=0; x < (long) number_pixels; x++)
02010 {
02011 p=PushShortPixel(endian,p,&pixel);
02012 q->red=ScaleShortToQuantum(pixel);
02013 p=PushShortPixel(endian,p,&pixel);
02014 q->green=ScaleShortToQuantum(pixel);
02015 p=PushShortPixel(endian,p,&pixel);
02016 q->blue=ScaleShortToQuantum(pixel);
02017 p=PushShortPixel(endian,p,&pixel);
02018 q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel));
02019 p+=quantum_info->pad;
02020 q++;
02021 }
02022 break;
02023 }
02024 case 32:
02025 {
02026 unsigned long
02027 pixel;
02028
02029 if (quantum_info->format == FloatingPointQuantumFormat)
02030 {
02031 float
02032 pixel;
02033
02034 for (x=0; x < (long) number_pixels; x++)
02035 {
02036 p=PushFloatPixel(&quantum_state,p,&pixel);
02037 q->red=RoundToQuantum(pixel);
02038 p=PushFloatPixel(&quantum_state,p,&pixel);
02039 q->green=RoundToQuantum(pixel);
02040 p=PushFloatPixel(&quantum_state,p,&pixel);
02041 q->blue=RoundToQuantum(pixel);
02042 p=PushFloatPixel(&quantum_state,p,&pixel);
02043 q->opacity=(Quantum) (QuantumRange-RoundToQuantum(pixel));
02044 p+=quantum_info->pad;
02045 q++;
02046 }
02047 break;
02048 }
02049 for (x=0; x < (long) number_pixels; x++)
02050 {
02051 p=PushLongPixel(endian,p,&pixel);
02052 q->red=ScaleLongToQuantum(pixel);
02053 p=PushLongPixel(endian,p,&pixel);
02054 q->green=ScaleLongToQuantum(pixel);
02055 p=PushLongPixel(endian,p,&pixel);
02056 q->blue=ScaleLongToQuantum(pixel);
02057 p=PushLongPixel(endian,p,&pixel);
02058 q->opacity=(Quantum) (QuantumRange-ScaleLongToQuantum(pixel));
02059 p+=quantum_info->pad;
02060 q++;
02061 }
02062 break;
02063 }
02064 case 64:
02065 {
02066 if (quantum_info->format == FloatingPointQuantumFormat)
02067 {
02068 double
02069 pixel;
02070
02071 for (x=0; x < (long) number_pixels; x++)
02072 {
02073 p=PushDoublePixel(&quantum_state,p,&pixel);
02074 q->red=RoundToQuantum(pixel);
02075 p=PushDoublePixel(&quantum_state,p,&pixel);
02076 q->green=RoundToQuantum(pixel);
02077 p=PushDoublePixel(&quantum_state,p,&pixel);
02078 q->blue=RoundToQuantum(pixel);
02079 p=PushDoublePixel(&quantum_state,p,&pixel);
02080 q->opacity=(Quantum) (QuantumRange-RoundToQuantum(pixel));
02081 p+=quantum_info->pad;
02082 q++;
02083 }
02084 break;
02085 }
02086 }
02087 default:
02088 {
02089 range=GetQuantumRange(image->depth);
02090 for (x=0; x < (long) number_pixels; x++)
02091 {
02092 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
02093 q->red=ScaleAnyToQuantum(pixel,range);
02094 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
02095 q->green=ScaleAnyToQuantum(pixel,range);
02096 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
02097 q->blue=ScaleAnyToQuantum(pixel,range);
02098 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
02099 q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range));
02100 q++;
02101 }
02102 break;
02103 }
02104 }
02105 break;
02106 }
02107 case CMYKQuantum:
02108 {
02109 if (image->colorspace != CMYKColorspace)
02110 {
02111 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
02112 "ColorSeparatedImageRequired","`%s'",image->filename);
02113 return(extent);
02114 }
02115 switch (quantum_info->depth)
02116 {
02117 case 8:
02118 {
02119 unsigned char
02120 pixel;
02121
02122 for (x=0; x < (long) number_pixels; x++)
02123 {
02124 p=PushCharPixel(p,&pixel);
02125 q->red=ScaleCharToQuantum(pixel);
02126 p=PushCharPixel(p,&pixel);
02127 q->green=ScaleCharToQuantum(pixel);
02128 p=PushCharPixel(p,&pixel);
02129 q->blue=ScaleCharToQuantum(pixel);
02130 p=PushCharPixel(p,&pixel);
02131 indexes[x]=ScaleCharToQuantum(pixel);
02132 p+=quantum_info->pad;
02133 q++;
02134 }
02135 break;
02136 }
02137 case 16:
02138 {
02139 unsigned short
02140 pixel;
02141
02142 for (x=0; x < (long) number_pixels; x++)
02143 {
02144 p=PushShortPixel(endian,p,&pixel);
02145 q->red=ScaleShortToQuantum(pixel);
02146 p=PushShortPixel(endian,p,&pixel);
02147 q->green=ScaleShortToQuantum(pixel);
02148 p=PushShortPixel(endian,p,&pixel);
02149 q->blue=ScaleShortToQuantum(pixel);
02150 p=PushShortPixel(endian,p,&pixel);
02151 indexes[x]=ScaleShortToQuantum(pixel);
02152 p+=quantum_info->pad;
02153 q++;
02154 }
02155 break;
02156 }
02157 case 32:
02158 {
02159 unsigned long
02160 pixel;
02161
02162 if (quantum_info->format == FloatingPointQuantumFormat)
02163 {
02164 float
02165 pixel;
02166
02167 for (x=0; x < (long) number_pixels; x++)
02168 {
02169 p=PushFloatPixel(&quantum_state,p,&pixel);
02170 q->red=RoundToQuantum(pixel);
02171 p=PushFloatPixel(&quantum_state,p,&pixel);
02172 q->green=RoundToQuantum(pixel);
02173 p=PushFloatPixel(&quantum_state,p,&pixel);
02174 q->blue=RoundToQuantum(pixel);
02175 p=PushFloatPixel(&quantum_state,p,&pixel);
02176 indexes[x]=(IndexPacket) RoundToQuantum(pixel);
02177 p+=quantum_info->pad;
02178 q++;
02179 }
02180 break;
02181 }
02182 for (x=0; x < (long) number_pixels; x++)
02183 {
02184 p=PushLongPixel(endian,p,&pixel);
02185 q->red=ScaleLongToQuantum(pixel);
02186 p=PushLongPixel(endian,p,&pixel);
02187 q->green=ScaleLongToQuantum(pixel);
02188 p=PushLongPixel(endian,p,&pixel);
02189 q->blue=ScaleLongToQuantum(pixel);
02190 p=PushLongPixel(endian,p,&pixel);
02191 indexes[x]=ScaleLongToQuantum(pixel);
02192 p+=quantum_info->pad;
02193 q++;
02194 }
02195 break;
02196 }
02197 case 64:
02198 {
02199 if (quantum_info->format == FloatingPointQuantumFormat)
02200 {
02201 double
02202 pixel;
02203
02204 for (x=0; x < (long) number_pixels; x++)
02205 {
02206 p=PushDoublePixel(&quantum_state,p,&pixel);
02207 q->red=RoundToQuantum(pixel);
02208 p=PushDoublePixel(&quantum_state,p,&pixel);
02209 q->green=RoundToQuantum(pixel);
02210 p=PushDoublePixel(&quantum_state,p,&pixel);
02211 q->blue=RoundToQuantum(pixel);
02212 p=PushDoublePixel(&quantum_state,p,&pixel);
02213 indexes[x]=(IndexPacket) RoundToQuantum(pixel);
02214 p+=quantum_info->pad;
02215 q++;
02216 }
02217 break;
02218 }
02219 }
02220 default:
02221 {
02222 range=GetQuantumRange(image->depth);
02223 for (x=0; x < (long) number_pixels; x++)
02224 {
02225 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
02226 q->red=ScaleAnyToQuantum(pixel,range);
02227 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
02228 q->green=ScaleAnyToQuantum(pixel,range);
02229 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
02230 q->blue=ScaleAnyToQuantum(pixel,range);
02231 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
02232 indexes[x]=ScaleAnyToQuantum(pixel,range);
02233 q++;
02234 }
02235 break;
02236 }
02237 }
02238 break;
02239 }
02240 case CMYKAQuantum:
02241 case CMYKOQuantum:
02242 {
02243 if (image->colorspace != CMYKColorspace)
02244 {
02245 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
02246 "ColorSeparatedImageRequired","`%s'",image->filename);
02247 return(extent);
02248 }
02249 switch (quantum_info->depth)
02250 {
02251 case 8:
02252 {
02253 unsigned char
02254 pixel;
02255
02256 for (x=0; x < (long) number_pixels; x++)
02257 {
02258 p=PushCharPixel(p,&pixel);
02259 q->red=ScaleCharToQuantum(pixel);
02260 p=PushCharPixel(p,&pixel);
02261 q->green=ScaleCharToQuantum(pixel);
02262 p=PushCharPixel(p,&pixel);
02263 q->blue=ScaleCharToQuantum(pixel);
02264 p=PushCharPixel(p,&pixel);
02265 indexes[x]=ScaleCharToQuantum(pixel);
02266 p=PushCharPixel(p,&pixel);
02267 q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel));
02268 p+=quantum_info->pad;
02269 q++;
02270 }
02271 break;
02272 }
02273 case 16:
02274 {
02275 unsigned short
02276 pixel;
02277
02278 for (x=0; x < (long) number_pixels; x++)
02279 {
02280 p=PushShortPixel(endian,p,&pixel);
02281 q->red=ScaleShortToQuantum(pixel);
02282 p=PushShortPixel(endian,p,&pixel);
02283 q->green=ScaleShortToQuantum(pixel);
02284 p=PushShortPixel(endian,p,&pixel);
02285 q->blue=ScaleShortToQuantum(pixel);
02286 p=PushShortPixel(endian,p,&pixel);
02287 indexes[x]=ScaleShortToQuantum(pixel);
02288 p=PushShortPixel(endian,p,&pixel);
02289 q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel));
02290 p+=quantum_info->pad;
02291 q++;
02292 }
02293 break;
02294 }
02295 case 32:
02296 {
02297 unsigned long
02298 pixel;
02299
02300 if (quantum_info->format == FloatingPointQuantumFormat)
02301 {
02302 float
02303 pixel;
02304
02305 for (x=0; x < (long) number_pixels; x++)
02306 {
02307 p=PushFloatPixel(&quantum_state,p,&pixel);
02308 q->red=RoundToQuantum(pixel);
02309 p=PushFloatPixel(&quantum_state,p,&pixel);
02310 q->green=RoundToQuantum(pixel);
02311 p=PushFloatPixel(&quantum_state,p,&pixel);
02312 q->blue=RoundToQuantum(pixel);
02313 p=PushFloatPixel(&quantum_state,p,&pixel);
02314 indexes[x]=(IndexPacket) RoundToQuantum(pixel);
02315 p=PushFloatPixel(&quantum_state,p,&pixel);
02316 q->opacity=(Quantum) (QuantumRange-RoundToQuantum(pixel));
02317 p+=quantum_info->pad;
02318 q++;
02319 }
02320 break;
02321 }
02322 for (x=0; x < (long) number_pixels; x++)
02323 {
02324 p=PushLongPixel(endian,p,&pixel);
02325 q->red=ScaleLongToQuantum(pixel);
02326 p=PushLongPixel(endian,p,&pixel);
02327 q->green=ScaleLongToQuantum(pixel);
02328 p=PushLongPixel(endian,p,&pixel);
02329 q->blue=ScaleLongToQuantum(pixel);
02330 p=PushLongPixel(endian,p,&pixel);
02331 indexes[x]=ScaleLongToQuantum(pixel);
02332 p=PushLongPixel(endian,p,&pixel);
02333 q->opacity=(Quantum) (QuantumRange-ScaleLongToQuantum(pixel));
02334 p+=quantum_info->pad;
02335 q++;
02336 }
02337 break;
02338 }
02339 case 64:
02340 {
02341 if (quantum_info->format == FloatingPointQuantumFormat)
02342 {
02343 double
02344 pixel;
02345
02346 for (x=0; x < (long) number_pixels; x++)
02347 {
02348 p=PushDoublePixel(&quantum_state,p,&pixel);
02349 q->red=RoundToQuantum(pixel);
02350 p=PushDoublePixel(&quantum_state,p,&pixel);
02351 q->green=RoundToQuantum(pixel);
02352 p=PushDoublePixel(&quantum_state,p,&pixel);
02353 q->blue=RoundToQuantum(pixel);
02354 p=PushDoublePixel(&quantum_state,p,&pixel);
02355 indexes[x]=(IndexPacket) RoundToQuantum(pixel);
02356 p=PushDoublePixel(&quantum_state,p,&pixel);
02357 q->opacity=(Quantum) (QuantumRange-RoundToQuantum(pixel));
02358 p=PushDoublePixel(&quantum_state,p,&pixel);
02359 p+=quantum_info->pad;
02360 q++;
02361 }
02362 break;
02363 }
02364 }
02365 default:
02366 {
02367 range=GetQuantumRange(image->depth);
02368 for (x=0; x < (long) number_pixels; x++)
02369 {
02370 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
02371 q->red=ScaleAnyToQuantum(pixel,range);
02372 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
02373 q->green=ScaleAnyToQuantum(pixel,range);
02374 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
02375 q->blue=ScaleAnyToQuantum(pixel,range);
02376 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
02377 indexes[x]=ScaleAnyToQuantum(pixel,range);
02378 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
02379 q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range));
02380 q++;
02381 }
02382 break;
02383 }
02384 }
02385 break;
02386 }
02387 case CbYCrYQuantum:
02388 {
02389 switch (quantum_info->depth)
02390 {
02391 case 10:
02392 {
02393 Quantum
02394 cbcr[4];
02395
02396 pixel=0;
02397 if (quantum_info->pack == MagickFalse)
02398 {
02399 long
02400 n;
02401
02402 register long
02403 i;
02404
02405 unsigned long
02406 quantum;
02407
02408 n=0;
02409 quantum=0;
02410 for (x=0; x < (long) number_pixels; x+=2)
02411 {
02412 for (i=0; i < 4; i++)
02413 {
02414 switch (n % 3)
02415 {
02416 case 0:
02417 {
02418 p=PushLongPixel(endian,p,&pixel);
02419 quantum=(unsigned long) (ScaleShortToQuantum(
02420 (unsigned short) (((pixel >> 22) & 0x3ff) << 6)));
02421 break;
02422 }
02423 case 1:
02424 {
02425 quantum=(unsigned long) (ScaleShortToQuantum(
02426 (unsigned short) (((pixel >> 12) & 0x3ff) << 6)));
02427 break;
02428 }
02429 case 2:
02430 {
02431 quantum=(unsigned long) (ScaleShortToQuantum(
02432 (unsigned short) (((pixel >> 2) & 0x3ff) << 6)));
02433 break;
02434 }
02435 }
02436 cbcr[i]=(Quantum) (quantum);
02437 n++;
02438 }
02439 p+=quantum_info->pad;
02440 q->red=cbcr[1];
02441 q->green=cbcr[0];
02442 q->blue=cbcr[2];
02443 q++;
02444 q->red=cbcr[3];
02445 q->green=cbcr[0];
02446 q->blue=cbcr[2];
02447 q++;
02448 }
02449 break;
02450 }
02451 }
02452 default:
02453 {
02454 range=GetQuantumRange(image->depth);
02455 for (x=0; x < (long) number_pixels; x++)
02456 {
02457 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
02458 q->red=ScaleAnyToQuantum(pixel,range);
02459 p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
02460 q->green=ScaleAnyToQuantum(pixel,range);
02461 q++;
02462 }
02463 break;
02464 }
02465 }
02466 break;
02467 }
02468 default:
02469 break;
02470 }
02471 if ((quantum_type == CbYCrQuantum) || (quantum_type == CbYCrAQuantum))
02472 {
02473 Quantum
02474 quantum;
02475
02476 register PixelPacket
02477 *__restrict q;
02478
02479 q=GetAuthenticPixelQueue(image);
02480 if (image_view != (CacheView *) NULL)
02481 q=GetCacheViewAuthenticPixelQueue(image_view);
02482 for (x=0; x < (long) number_pixels; x++)
02483 {
02484 quantum=q->red;
02485 q->red=q->green;
02486 q->green=quantum;
02487 q++;
02488 }
02489 }
02490 if ((quantum_type == RGBOQuantum) || (quantum_type == CMYKOQuantum))
02491 {
02492 register PixelPacket
02493 *__restrict q;
02494
02495 q=GetAuthenticPixelQueue(image);
02496 if (image_view != (CacheView *) NULL)
02497 q=GetCacheViewAuthenticPixelQueue(image_view);
02498 for (x=0; x < (long) number_pixels; x++)
02499 {
02500 q->opacity=(Quantum) (QuantumRange-q->opacity);
02501 q++;
02502 }
02503 }
02504 if (quantum_info->alpha_type == DisassociatedQuantumAlpha)
02505 {
02506 MagickRealType
02507 alpha;
02508
02509 register PixelPacket
02510 *__restrict q;
02511
02512
02513
02514
02515 q=GetAuthenticPixelQueue(image);
02516 if (image_view != (CacheView *) NULL)
02517 q=GetCacheViewAuthenticPixelQueue(image_view);
02518 for (x=0; x < (long) number_pixels; x++)
02519 {
02520 alpha=QuantumScale*((MagickRealType) QuantumRange-q->opacity);
02521 alpha=1.0/(fabs(alpha) <= MagickEpsilon ? 1.0 : alpha);
02522 q->red=RoundToQuantum(alpha*q->red);
02523 q->green=RoundToQuantum(alpha*q->green);
02524 q->blue=RoundToQuantum(alpha*q->blue);
02525 q++;
02526 }
02527 }
02528 return(extent);
02529 }