|
MagickCore
6.7.5
|
00001 /* 00002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00003 % % 00004 % % 00005 % % 00006 % PPPP IIIII X X EEEEE L % 00007 % P P I X X E L % 00008 % PPPP I X EEE L % 00009 % P I X X E L % 00010 % P IIIII X X EEEEE LLLLL % 00011 % % 00012 % MagickCore Methods to Import/Export Pixels % 00013 % % 00014 % Software Design % 00015 % John Cristy % 00016 % October 1998 % 00017 % % 00018 % % 00019 % Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization % 00020 % dedicated to making software imaging solutions freely available. % 00021 % % 00022 % You may not use this file except in compliance with the License. You may % 00023 % obtain a copy of the License at % 00024 % % 00025 % http://www.imagemagick.org/script/license.php % 00026 % % 00027 % Unless required by applicable law or agreed to in writing, software % 00028 % distributed under the License is distributed on an "AS IS" BASIS, % 00029 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % 00030 % See the License for the specific language governing permissions and % 00031 % limitations under the License. % 00032 % % 00033 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00034 % 00035 % 00036 */ 00037 00038 /* 00039 Include declarations. 00040 */ 00041 #include "MagickCore/studio.h" 00042 #include "MagickCore/property.h" 00043 #include "MagickCore/blob.h" 00044 #include "MagickCore/blob-private.h" 00045 #include "MagickCore/color-private.h" 00046 #include "MagickCore/draw.h" 00047 #include "MagickCore/exception.h" 00048 #include "MagickCore/exception-private.h" 00049 #include "MagickCore/cache.h" 00050 #include "MagickCore/constitute.h" 00051 #include "MagickCore/delegate.h" 00052 #include "MagickCore/geometry.h" 00053 #include "MagickCore/image-private.h" 00054 #include "MagickCore/list.h" 00055 #include "MagickCore/magick.h" 00056 #include "MagickCore/memory_.h" 00057 #include "MagickCore/monitor.h" 00058 #include "MagickCore/option.h" 00059 #include "MagickCore/pixel.h" 00060 #include "MagickCore/pixel-accessor.h" 00061 #include "MagickCore/quantum.h" 00062 #include "MagickCore/quantum-private.h" 00063 #include "MagickCore/resource_.h" 00064 #include "MagickCore/semaphore.h" 00065 #include "MagickCore/statistic.h" 00066 #include "MagickCore/stream.h" 00067 #include "MagickCore/string_.h" 00068 #include "MagickCore/transform.h" 00069 #include "MagickCore/utility.h" 00070 00071 #define LogPixelChannels(image) \ 00072 { \ 00073 register ssize_t \ 00074 i; \ 00075 \ 00076 (void) LogMagickEvent(PixelEvent,GetMagickModule(),"%s[%.20g]", \ 00077 image->filename,(double) image->number_channels); \ 00078 for (i=0; i < (ssize_t) image->number_channels; i++) \ 00079 { \ 00080 char \ 00081 traits[MaxTextExtent]; \ 00082 \ 00083 const char \ 00084 *name; \ 00085 \ 00086 PixelChannel \ 00087 channel; \ 00088 \ 00089 switch (GetPixelChannelMapChannel(image,i)) \ 00090 { \ 00091 case RedPixelChannel: \ 00092 { \ 00093 name="red"; \ 00094 if (image->colorspace == CMYKColorspace) \ 00095 name="cyan"; \ 00096 if (image->colorspace == GRAYColorspace) \ 00097 name="gray"; \ 00098 break; \ 00099 } \ 00100 case GreenPixelChannel: \ 00101 { \ 00102 name="green"; \ 00103 if (image->colorspace == CMYKColorspace) \ 00104 name="magenta"; \ 00105 break; \ 00106 } \ 00107 case BluePixelChannel: \ 00108 { \ 00109 name="blue"; \ 00110 if (image->colorspace == CMYKColorspace) \ 00111 name="yellow"; \ 00112 break; \ 00113 } \ 00114 case BlackPixelChannel: \ 00115 { \ 00116 name="black"; \ 00117 if (image->storage_class == PseudoClass) \ 00118 name="index"; \ 00119 break; \ 00120 } \ 00121 case IndexPixelChannel: \ 00122 { \ 00123 name="index"; \ 00124 break; \ 00125 } \ 00126 case AlphaPixelChannel: \ 00127 { \ 00128 name="alpha"; \ 00129 break; \ 00130 } \ 00131 case MaskPixelChannel: \ 00132 { \ 00133 name="mask"; \ 00134 break; \ 00135 } \ 00136 case MetaPixelChannel: \ 00137 { \ 00138 name="meta"; \ 00139 break; \ 00140 } \ 00141 default: \ 00142 name="undefined"; \ 00143 } \ 00144 channel=GetPixelChannelMapChannel(image,i); \ 00145 *traits='\0'; \ 00146 if ((GetPixelChannelMapTraits(image,channel) & UpdatePixelTrait) != 0) \ 00147 (void) ConcatenateMagickString(traits,"update,",MaxTextExtent); \ 00148 if ((GetPixelChannelMapTraits(image,channel) & BlendPixelTrait) != 0) \ 00149 (void) ConcatenateMagickString(traits,"blend,",MaxTextExtent); \ 00150 if ((GetPixelChannelMapTraits(image,channel) & CopyPixelTrait) != 0) \ 00151 (void) ConcatenateMagickString(traits,"copy,",MaxTextExtent); \ 00152 if (*traits == '\0') \ 00153 (void) ConcatenateMagickString(traits,"undefined,",MaxTextExtent); \ 00154 traits[strlen(traits)-1]='\0'; \ 00155 (void) LogMagickEvent(PixelEvent,GetMagickModule()," %.20g: %s (%s)", \ 00156 (double) i,name,traits); \ 00157 } \ 00158 } 00159 00160 /* 00161 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00162 % % 00163 % % 00164 % % 00165 + A c q u i r e P i x e l C h a n n e l M a p % 00166 % % 00167 % % 00168 % % 00169 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00170 % 00171 % AcquirePixelChannelMap() acquires a pixel component map. 00172 % 00173 % The format of the AcquirePixelChannelMap() method is: 00174 % 00175 % PixelChannelMap *AcquirePixelChannelMap(void) 00176 % 00177 */ 00178 MagickExport PixelChannelMap *AcquirePixelChannelMap(void) 00179 { 00180 PixelChannelMap 00181 *channel_map; 00182 00183 register ssize_t 00184 i; 00185 00186 channel_map=(PixelChannelMap *) AcquireQuantumMemory(MaxPixelChannels, 00187 sizeof(*channel_map)); 00188 if (channel_map == (PixelChannelMap *) NULL) 00189 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); 00190 (void) ResetMagickMemory(channel_map,0,MaxPixelChannels*sizeof(*channel_map)); 00191 for (i=0; i < MaxPixelChannels; i++) 00192 channel_map[i].channel=(PixelChannel) i; 00193 return(channel_map); 00194 } 00195 00196 /* 00197 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00198 % % 00199 % % 00200 % % 00201 + C l o n e P i x e l C h a n n e l M a p % 00202 % % 00203 % % 00204 % % 00205 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00206 % 00207 % ClonePixelChannelMap() clones a pixel component map. 00208 % 00209 % The format of the ClonePixelChannelMap() method is: 00210 % 00211 % PixelChannelMap *ClonePixelChannelMap(PixelChannelMap *channel_map) 00212 % 00213 % A description of each parameter follows: 00214 % 00215 % o channel_map: the pixel component map. 00216 % 00217 */ 00218 MagickExport PixelChannelMap *ClonePixelChannelMap(PixelChannelMap *channel_map) 00219 { 00220 PixelChannelMap 00221 *clone_map; 00222 00223 assert(channel_map != (PixelChannelMap *) NULL); 00224 clone_map=AcquirePixelChannelMap(); 00225 if (clone_map == (PixelChannelMap *) NULL) 00226 return((PixelChannelMap *) NULL); 00227 (void) CopyMagickMemory(clone_map,channel_map,MaxPixelChannels* 00228 sizeof(*channel_map)); 00229 return(clone_map); 00230 } 00231 00232 /* 00233 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00234 % % 00235 % % 00236 % % 00237 + C l o n e P i x e l I n f o % 00238 % % 00239 % % 00240 % % 00241 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00242 % 00243 % ClonePixelInfo() makes a duplicate of the given pixel info structure, or if 00244 % pixel info is NULL, a new one. 00245 % 00246 % The format of the ClonePixelInfo method is: 00247 % 00248 % PixelInfo *ClonePixelInfo(const PixelInfo *pixel_info) 00249 % 00250 % A description of each parameter follows: 00251 % 00252 % o pixel_info: the pixel info. 00253 % 00254 */ 00255 MagickExport PixelInfo *ClonePixelInfo(const PixelInfo *pixel) 00256 { 00257 PixelInfo 00258 *pixel_info; 00259 00260 pixel_info=(PixelInfo *) AcquireQuantumMemory(1,sizeof(*pixel_info)); 00261 if (pixel_info == (PixelInfo *) NULL) 00262 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); 00263 *pixel_info=(*pixel); 00264 return(pixel_info); 00265 } 00266 00267 /* 00268 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00269 % % 00270 % % 00271 % % 00272 + D e s t r o y P i x e l C h a n n e l M a p % 00273 % % 00274 % % 00275 % % 00276 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00277 % 00278 % DestroyPixelChannelMap() deallocates memory associated with the pixel 00279 % channel map. 00280 % 00281 % The format of the DestroyPixelChannelMap() method is: 00282 % 00283 % PixelChannelMap *DestroyPixelChannelMap(PixelChannelMap *channel_map) 00284 % 00285 % A description of each parameter follows: 00286 % 00287 % o channel_map: the pixel component map. 00288 % 00289 */ 00290 MagickExport PixelChannelMap *DestroyPixelChannelMap( 00291 PixelChannelMap *channel_map) 00292 { 00293 assert(channel_map != (PixelChannelMap *) NULL); 00294 channel_map=(PixelChannelMap *) RelinquishMagickMemory(channel_map); 00295 return((PixelChannelMap *) RelinquishMagickMemory(channel_map)); 00296 } 00297 00298 /* 00299 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00300 % % 00301 % % 00302 % % 00303 % E x p o r t I m a g e P i x e l s % 00304 % % 00305 % % 00306 % % 00307 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00308 % 00309 % ExportImagePixels() extracts pixel data from an image and returns it to you. 00310 % The method returns MagickTrue on success otherwise MagickFalse if an error is 00311 % encountered. The data is returned as char, short int, Quantum, unsigned int, 00312 % unsigned long long, float, or double in the order specified by map. 00313 % 00314 % Suppose you want to extract the first scanline of a 640x480 image as 00315 % character data in red-green-blue order: 00316 % 00317 % ExportImagePixels(image,0,0,640,1,"RGB",CharPixel,pixels,exception); 00318 % 00319 % The format of the ExportImagePixels method is: 00320 % 00321 % MagickBooleanType ExportImagePixels(const Image *image,const ssize_t x, 00322 % const ssize_t y,const size_t width,const size_t height, 00323 % const char *map,const StorageType type,void *pixels, 00324 % ExceptionInfo *exception) 00325 % 00326 % A description of each parameter follows: 00327 % 00328 % o image: the image. 00329 % 00330 % o x,y,width,height: These values define the perimeter 00331 % of a region of pixels you want to extract. 00332 % 00333 % o map: This string reflects the expected ordering of the pixel array. 00334 % It can be any combination or order of R = red, G = green, B = blue, 00335 % A = alpha (0 is transparent), O = opacity (0 is opaque), C = cyan, 00336 % Y = yellow, M = magenta, K = black, I = intensity (for grayscale), 00337 % P = pad. 00338 % 00339 % o type: Define the data type of the pixels. Float and double types are 00340 % normalized to [0..1] otherwise [0..QuantumRange]. Choose from these 00341 % types: CharPixel (char *), DoublePixel (double *), FloatPixel (float *), 00342 % LongPixel (unsigned int *), LongLongPixel (unsigned long long *), 00343 % QuantumPixel (Quantum *), or ShortPixel (unsigned short *). 00344 % 00345 % o pixels: This array of values contain the pixel components as defined by 00346 % map and type. You must preallocate this array where the expected 00347 % length varies depending on the values of width, height, map, and type. 00348 % 00349 % o exception: return any errors or warnings in this structure. 00350 % 00351 */ 00352 00353 static void ExportCharPixel(const Image *image,const RectangleInfo *roi, 00354 const char *restrict map,const QuantumType *quantum_map,void *pixels, 00355 ExceptionInfo *exception) 00356 { 00357 register const Quantum 00358 *restrict p; 00359 00360 register ssize_t 00361 x; 00362 00363 register unsigned char 00364 *restrict q; 00365 00366 ssize_t 00367 y; 00368 00369 q=(unsigned char *) pixels; 00370 if (LocaleCompare(map,"BGR") == 0) 00371 { 00372 for (y=0; y < (ssize_t) roi->height; y++) 00373 { 00374 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 00375 if (p == (const Quantum *) NULL) 00376 break; 00377 for (x=0; x < (ssize_t) roi->width; x++) 00378 { 00379 *q++=ScaleQuantumToChar(GetPixelBlue(image,p)); 00380 *q++=ScaleQuantumToChar(GetPixelGreen(image,p)); 00381 *q++=ScaleQuantumToChar(GetPixelRed(image,p)); 00382 p+=GetPixelChannels(image); 00383 } 00384 } 00385 return; 00386 } 00387 if (LocaleCompare(map,"BGRA") == 0) 00388 { 00389 for (y=0; y < (ssize_t) roi->height; y++) 00390 { 00391 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 00392 if (p == (const Quantum *) NULL) 00393 break; 00394 for (x=0; x < (ssize_t) roi->width; x++) 00395 { 00396 *q++=ScaleQuantumToChar(GetPixelBlue(image,p)); 00397 *q++=ScaleQuantumToChar(GetPixelGreen(image,p)); 00398 *q++=ScaleQuantumToChar(GetPixelRed(image,p)); 00399 *q++=ScaleQuantumToChar(GetPixelAlpha(image,p)); 00400 p+=GetPixelChannels(image); 00401 } 00402 } 00403 return; 00404 } 00405 if (LocaleCompare(map,"BGRP") == 0) 00406 { 00407 for (y=0; y < (ssize_t) roi->height; y++) 00408 { 00409 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 00410 if (p == (const Quantum *) NULL) 00411 break; 00412 for (x=0; x < (ssize_t) roi->width; x++) 00413 { 00414 *q++=ScaleQuantumToChar(GetPixelBlue(image,p)); 00415 *q++=ScaleQuantumToChar(GetPixelGreen(image,p)); 00416 *q++=ScaleQuantumToChar(GetPixelRed(image,p)); 00417 *q++=ScaleQuantumToChar((Quantum) 0); 00418 p+=GetPixelChannels(image); 00419 } 00420 } 00421 return; 00422 } 00423 if (LocaleCompare(map,"I") == 0) 00424 { 00425 for (y=0; y < (ssize_t) roi->height; y++) 00426 { 00427 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 00428 if (p == (const Quantum *) NULL) 00429 break; 00430 for (x=0; x < (ssize_t) roi->width; x++) 00431 { 00432 *q++=ScaleQuantumToChar(GetPixelIntensity(image,p)); 00433 p+=GetPixelChannels(image); 00434 } 00435 } 00436 return; 00437 } 00438 if (LocaleCompare(map,"RGB") == 0) 00439 { 00440 for (y=0; y < (ssize_t) roi->height; y++) 00441 { 00442 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 00443 if (p == (const Quantum *) NULL) 00444 break; 00445 for (x=0; x < (ssize_t) roi->width; x++) 00446 { 00447 *q++=ScaleQuantumToChar(GetPixelRed(image,p)); 00448 *q++=ScaleQuantumToChar(GetPixelGreen(image,p)); 00449 *q++=ScaleQuantumToChar(GetPixelBlue(image,p)); 00450 p+=GetPixelChannels(image); 00451 } 00452 } 00453 return; 00454 } 00455 if (LocaleCompare(map,"RGBA") == 0) 00456 { 00457 for (y=0; y < (ssize_t) roi->height; y++) 00458 { 00459 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 00460 if (p == (const Quantum *) NULL) 00461 break; 00462 for (x=0; x < (ssize_t) roi->width; x++) 00463 { 00464 *q++=ScaleQuantumToChar(GetPixelRed(image,p)); 00465 *q++=ScaleQuantumToChar(GetPixelGreen(image,p)); 00466 *q++=ScaleQuantumToChar(GetPixelBlue(image,p)); 00467 *q++=ScaleQuantumToChar(GetPixelAlpha(image,p)); 00468 p+=GetPixelChannels(image); 00469 } 00470 } 00471 return; 00472 } 00473 if (LocaleCompare(map,"RGBP") == 0) 00474 { 00475 for (y=0; y < (ssize_t) roi->height; y++) 00476 { 00477 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 00478 if (p == (const Quantum *) NULL) 00479 break; 00480 for (x=0; x < (ssize_t) roi->width; x++) 00481 { 00482 *q++=ScaleQuantumToChar(GetPixelRed(image,p)); 00483 *q++=ScaleQuantumToChar(GetPixelGreen(image,p)); 00484 *q++=ScaleQuantumToChar(GetPixelBlue(image,p)); 00485 *q++=ScaleQuantumToChar((Quantum) 0); 00486 p+=GetPixelChannels(image); 00487 } 00488 } 00489 return; 00490 } 00491 for (y=0; y < (ssize_t) roi->height; y++) 00492 { 00493 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 00494 if (p == (const Quantum *) NULL) 00495 break; 00496 for (x=0; x < (ssize_t) roi->width; x++) 00497 { 00498 register ssize_t 00499 i; 00500 00501 for (i=0; i < (ssize_t) strlen(map); i++) 00502 { 00503 *q=0; 00504 switch (quantum_map[i]) 00505 { 00506 case RedQuantum: 00507 case CyanQuantum: 00508 { 00509 *q=ScaleQuantumToChar(GetPixelRed(image,p)); 00510 break; 00511 } 00512 case GreenQuantum: 00513 case MagentaQuantum: 00514 { 00515 *q=ScaleQuantumToChar(GetPixelGreen(image,p)); 00516 break; 00517 } 00518 case BlueQuantum: 00519 case YellowQuantum: 00520 { 00521 *q=ScaleQuantumToChar(GetPixelBlue(image,p)); 00522 break; 00523 } 00524 case AlphaQuantum: 00525 { 00526 *q=ScaleQuantumToChar(GetPixelAlpha(image,p)); 00527 break; 00528 } 00529 case OpacityQuantum: 00530 { 00531 *q=ScaleQuantumToChar(GetPixelAlpha(image,p)); 00532 break; 00533 } 00534 case BlackQuantum: 00535 { 00536 if (image->colorspace == CMYKColorspace) 00537 *q=ScaleQuantumToChar(GetPixelBlack(image,p)); 00538 break; 00539 } 00540 case IndexQuantum: 00541 { 00542 *q=ScaleQuantumToChar(GetPixelIntensity(image,p)); 00543 break; 00544 } 00545 default: 00546 break; 00547 } 00548 q++; 00549 } 00550 p+=GetPixelChannels(image); 00551 } 00552 } 00553 } 00554 00555 static void ExportDoublePixel(const Image *image,const RectangleInfo *roi, 00556 const char *restrict map,const QuantumType *quantum_map,void *pixels, 00557 ExceptionInfo *exception) 00558 { 00559 register const Quantum 00560 *restrict p; 00561 00562 register double 00563 *restrict q; 00564 00565 register ssize_t 00566 x; 00567 00568 ssize_t 00569 y; 00570 00571 q=(double *) pixels; 00572 if (LocaleCompare(map,"BGR") == 0) 00573 { 00574 for (y=0; y < (ssize_t) roi->height; y++) 00575 { 00576 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 00577 if (p == (const Quantum *) NULL) 00578 break; 00579 for (x=0; x < (ssize_t) roi->width; x++) 00580 { 00581 *q++=(double) (QuantumScale*GetPixelBlue(image,p)); 00582 *q++=(double) (QuantumScale*GetPixelGreen(image,p)); 00583 *q++=(double) (QuantumScale*GetPixelRed(image,p)); 00584 p+=GetPixelChannels(image); 00585 } 00586 } 00587 return; 00588 } 00589 if (LocaleCompare(map,"BGRA") == 0) 00590 { 00591 for (y=0; y < (ssize_t) roi->height; y++) 00592 { 00593 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 00594 if (p == (const Quantum *) NULL) 00595 break; 00596 for (x=0; x < (ssize_t) roi->width; x++) 00597 { 00598 *q++=(double) (QuantumScale*GetPixelBlue(image,p)); 00599 *q++=(double) (QuantumScale*GetPixelGreen(image,p)); 00600 *q++=(double) (QuantumScale*GetPixelRed(image,p)); 00601 *q++=(double) (QuantumScale*GetPixelAlpha(image,p)); 00602 p+=GetPixelChannels(image); 00603 } 00604 } 00605 return; 00606 } 00607 if (LocaleCompare(map,"BGRP") == 0) 00608 { 00609 for (y=0; y < (ssize_t) roi->height; y++) 00610 { 00611 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 00612 if (p == (const Quantum *) NULL) 00613 break; 00614 for (x=0; x < (ssize_t) roi->width; x++) 00615 { 00616 *q++=(double) (QuantumScale*GetPixelBlue(image,p)); 00617 *q++=(double) (QuantumScale*GetPixelGreen(image,p)); 00618 *q++=(double) (QuantumScale*GetPixelRed(image,p)); 00619 *q++=0.0; 00620 p+=GetPixelChannels(image); 00621 } 00622 } 00623 return; 00624 } 00625 if (LocaleCompare(map,"I") == 0) 00626 { 00627 for (y=0; y < (ssize_t) roi->height; y++) 00628 { 00629 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 00630 if (p == (const Quantum *) NULL) 00631 break; 00632 for (x=0; x < (ssize_t) roi->width; x++) 00633 { 00634 *q++=(double) (QuantumScale*GetPixelIntensity(image,p)); 00635 p+=GetPixelChannels(image); 00636 } 00637 } 00638 return; 00639 } 00640 if (LocaleCompare(map,"RGB") == 0) 00641 { 00642 for (y=0; y < (ssize_t) roi->height; y++) 00643 { 00644 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 00645 if (p == (const Quantum *) NULL) 00646 break; 00647 for (x=0; x < (ssize_t) roi->width; x++) 00648 { 00649 *q++=(double) (QuantumScale*GetPixelRed(image,p)); 00650 *q++=(double) (QuantumScale*GetPixelGreen(image,p)); 00651 *q++=(double) (QuantumScale*GetPixelBlue(image,p)); 00652 p+=GetPixelChannels(image); 00653 } 00654 } 00655 return; 00656 } 00657 if (LocaleCompare(map,"RGBA") == 0) 00658 { 00659 for (y=0; y < (ssize_t) roi->height; y++) 00660 { 00661 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 00662 if (p == (const Quantum *) NULL) 00663 break; 00664 for (x=0; x < (ssize_t) roi->width; x++) 00665 { 00666 *q++=(double) (QuantumScale*GetPixelRed(image,p)); 00667 *q++=(double) (QuantumScale*GetPixelGreen(image,p)); 00668 *q++=(double) (QuantumScale*GetPixelBlue(image,p)); 00669 *q++=(double) (QuantumScale*GetPixelAlpha(image,p)); 00670 p+=GetPixelChannels(image); 00671 } 00672 } 00673 return; 00674 } 00675 if (LocaleCompare(map,"RGBP") == 0) 00676 { 00677 for (y=0; y < (ssize_t) roi->height; y++) 00678 { 00679 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 00680 if (p == (const Quantum *) NULL) 00681 break; 00682 for (x=0; x < (ssize_t) roi->width; x++) 00683 { 00684 *q++=(double) (QuantumScale*GetPixelRed(image,p)); 00685 *q++=(double) (QuantumScale*GetPixelGreen(image,p)); 00686 *q++=(double) (QuantumScale*GetPixelBlue(image,p)); 00687 *q++=0.0; 00688 p+=GetPixelChannels(image); 00689 } 00690 } 00691 return; 00692 } 00693 for (y=0; y < (ssize_t) roi->height; y++) 00694 { 00695 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 00696 if (p == (const Quantum *) NULL) 00697 break; 00698 for (x=0; x < (ssize_t) roi->width; x++) 00699 { 00700 register ssize_t 00701 i; 00702 00703 for (i=0; i < (ssize_t) strlen(map); i++) 00704 { 00705 *q=0; 00706 switch (quantum_map[i]) 00707 { 00708 case RedQuantum: 00709 case CyanQuantum: 00710 { 00711 *q=(double) (QuantumScale*GetPixelRed(image,p)); 00712 break; 00713 } 00714 case GreenQuantum: 00715 case MagentaQuantum: 00716 { 00717 *q=(double) (QuantumScale*GetPixelGreen(image,p)); 00718 break; 00719 } 00720 case BlueQuantum: 00721 case YellowQuantum: 00722 { 00723 *q=(double) (QuantumScale*GetPixelBlue(image,p)); 00724 break; 00725 } 00726 case AlphaQuantum: 00727 { 00728 *q=(double) (QuantumScale*GetPixelAlpha(image,p)); 00729 break; 00730 } 00731 case OpacityQuantum: 00732 { 00733 *q=(double) (QuantumScale*GetPixelAlpha(image,p)); 00734 break; 00735 } 00736 case BlackQuantum: 00737 { 00738 if (image->colorspace == CMYKColorspace) 00739 *q=(double) (QuantumScale* 00740 GetPixelBlack(image,p)); 00741 break; 00742 } 00743 case IndexQuantum: 00744 { 00745 *q=(double) (QuantumScale*GetPixelIntensity(image,p)); 00746 break; 00747 } 00748 default: 00749 *q=0; 00750 } 00751 q++; 00752 } 00753 p+=GetPixelChannels(image); 00754 } 00755 } 00756 } 00757 00758 static void ExportFloatPixel(const Image *image,const RectangleInfo *roi, 00759 const char *restrict map,const QuantumType *quantum_map,void *pixels, 00760 ExceptionInfo *exception) 00761 { 00762 register const Quantum 00763 *restrict p; 00764 00765 register float 00766 *restrict q; 00767 00768 register ssize_t 00769 x; 00770 00771 ssize_t 00772 y; 00773 00774 q=(float *) pixels; 00775 if (LocaleCompare(map,"BGR") == 0) 00776 { 00777 for (y=0; y < (ssize_t) roi->height; y++) 00778 { 00779 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 00780 if (p == (const Quantum *) NULL) 00781 break; 00782 for (x=0; x < (ssize_t) roi->width; x++) 00783 { 00784 *q++=(float) (QuantumScale*GetPixelBlue(image,p)); 00785 *q++=(float) (QuantumScale*GetPixelGreen(image,p)); 00786 *q++=(float) (QuantumScale*GetPixelRed(image,p)); 00787 p+=GetPixelChannels(image); 00788 } 00789 } 00790 return; 00791 } 00792 if (LocaleCompare(map,"BGRA") == 0) 00793 { 00794 for (y=0; y < (ssize_t) roi->height; y++) 00795 { 00796 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 00797 if (p == (const Quantum *) NULL) 00798 break; 00799 for (x=0; x < (ssize_t) roi->width; x++) 00800 { 00801 *q++=(float) (QuantumScale*GetPixelBlue(image,p)); 00802 *q++=(float) (QuantumScale*GetPixelGreen(image,p)); 00803 *q++=(float) (QuantumScale*GetPixelRed(image,p)); 00804 *q++=(float) (QuantumScale*GetPixelAlpha(image,p)); 00805 p+=GetPixelChannels(image); 00806 } 00807 } 00808 return; 00809 } 00810 if (LocaleCompare(map,"BGRP") == 0) 00811 { 00812 for (y=0; y < (ssize_t) roi->height; y++) 00813 { 00814 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 00815 if (p == (const Quantum *) NULL) 00816 break; 00817 for (x=0; x < (ssize_t) roi->width; x++) 00818 { 00819 *q++=(float) (QuantumScale*GetPixelBlue(image,p)); 00820 *q++=(float) (QuantumScale*GetPixelGreen(image,p)); 00821 *q++=(float) (QuantumScale*GetPixelRed(image,p)); 00822 *q++=0.0; 00823 p+=GetPixelChannels(image); 00824 } 00825 } 00826 return; 00827 } 00828 if (LocaleCompare(map,"I") == 0) 00829 { 00830 for (y=0; y < (ssize_t) roi->height; y++) 00831 { 00832 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 00833 if (p == (const Quantum *) NULL) 00834 break; 00835 for (x=0; x < (ssize_t) roi->width; x++) 00836 { 00837 *q++=(float) (QuantumScale*GetPixelIntensity(image,p)); 00838 p+=GetPixelChannels(image); 00839 } 00840 } 00841 return; 00842 } 00843 if (LocaleCompare(map,"RGB") == 0) 00844 { 00845 for (y=0; y < (ssize_t) roi->height; y++) 00846 { 00847 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 00848 if (p == (const Quantum *) NULL) 00849 break; 00850 for (x=0; x < (ssize_t) roi->width; x++) 00851 { 00852 *q++=(float) (QuantumScale*GetPixelRed(image,p)); 00853 *q++=(float) (QuantumScale*GetPixelGreen(image,p)); 00854 *q++=(float) (QuantumScale*GetPixelBlue(image,p)); 00855 p+=GetPixelChannels(image); 00856 } 00857 } 00858 return; 00859 } 00860 if (LocaleCompare(map,"RGBA") == 0) 00861 { 00862 for (y=0; y < (ssize_t) roi->height; y++) 00863 { 00864 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 00865 if (p == (const Quantum *) NULL) 00866 break; 00867 for (x=0; x < (ssize_t) roi->width; x++) 00868 { 00869 *q++=(float) (QuantumScale*GetPixelRed(image,p)); 00870 *q++=(float) (QuantumScale*GetPixelGreen(image,p)); 00871 *q++=(float) (QuantumScale*GetPixelBlue(image,p)); 00872 *q++=(float) (QuantumScale*GetPixelAlpha(image,p)); 00873 p+=GetPixelChannels(image); 00874 } 00875 } 00876 return; 00877 } 00878 if (LocaleCompare(map,"RGBP") == 0) 00879 { 00880 for (y=0; y < (ssize_t) roi->height; y++) 00881 { 00882 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 00883 if (p == (const Quantum *) NULL) 00884 break; 00885 for (x=0; x < (ssize_t) roi->width; x++) 00886 { 00887 *q++=(float) (QuantumScale*GetPixelRed(image,p)); 00888 *q++=(float) (QuantumScale*GetPixelGreen(image,p)); 00889 *q++=(float) (QuantumScale*GetPixelBlue(image,p)); 00890 *q++=0.0; 00891 p+=GetPixelChannels(image); 00892 } 00893 } 00894 return; 00895 } 00896 for (y=0; y < (ssize_t) roi->height; y++) 00897 { 00898 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 00899 if (p == (const Quantum *) NULL) 00900 break; 00901 for (x=0; x < (ssize_t) roi->width; x++) 00902 { 00903 register ssize_t 00904 i; 00905 00906 for (i=0; i < (ssize_t) strlen(map); i++) 00907 { 00908 *q=0; 00909 switch (quantum_map[i]) 00910 { 00911 case RedQuantum: 00912 case CyanQuantum: 00913 { 00914 *q=(float) (QuantumScale*GetPixelRed(image,p)); 00915 break; 00916 } 00917 case GreenQuantum: 00918 case MagentaQuantum: 00919 { 00920 *q=(float) (QuantumScale*GetPixelGreen(image,p)); 00921 break; 00922 } 00923 case BlueQuantum: 00924 case YellowQuantum: 00925 { 00926 *q=(float) (QuantumScale*GetPixelBlue(image,p)); 00927 break; 00928 } 00929 case AlphaQuantum: 00930 { 00931 *q=(float) (QuantumScale*((Quantum) (GetPixelAlpha(image,p)))); 00932 break; 00933 } 00934 case OpacityQuantum: 00935 { 00936 *q=(float) (QuantumScale*GetPixelAlpha(image,p)); 00937 break; 00938 } 00939 case BlackQuantum: 00940 { 00941 if (image->colorspace == CMYKColorspace) 00942 *q=(float) (QuantumScale* GetPixelBlack(image,p)); 00943 break; 00944 } 00945 case IndexQuantum: 00946 { 00947 *q=(float) (QuantumScale*GetPixelIntensity(image,p)); 00948 break; 00949 } 00950 default: 00951 *q=0; 00952 } 00953 q++; 00954 } 00955 p+=GetPixelChannels(image); 00956 } 00957 } 00958 } 00959 00960 static void ExportLongPixel(const Image *image,const RectangleInfo *roi, 00961 const char *restrict map,const QuantumType *quantum_map,void *pixels, 00962 ExceptionInfo *exception) 00963 { 00964 register const Quantum 00965 *restrict p; 00966 00967 register ssize_t 00968 x; 00969 00970 register unsigned int 00971 *restrict q; 00972 00973 ssize_t 00974 y; 00975 00976 q=(unsigned int *) pixels; 00977 if (LocaleCompare(map,"BGR") == 0) 00978 { 00979 for (y=0; y < (ssize_t) roi->height; y++) 00980 { 00981 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 00982 if (p == (const Quantum *) NULL) 00983 break; 00984 for (x=0; x < (ssize_t) roi->width; x++) 00985 { 00986 *q++=ScaleQuantumToLong(GetPixelBlue(image,p)); 00987 *q++=ScaleQuantumToLong(GetPixelGreen(image,p)); 00988 *q++=ScaleQuantumToLong(GetPixelRed(image,p)); 00989 p+=GetPixelChannels(image); 00990 } 00991 } 00992 return; 00993 } 00994 if (LocaleCompare(map,"BGRA") == 0) 00995 { 00996 for (y=0; y < (ssize_t) roi->height; y++) 00997 { 00998 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 00999 if (p == (const Quantum *) NULL) 01000 break; 01001 for (x=0; x < (ssize_t) roi->width; x++) 01002 { 01003 *q++=ScaleQuantumToLong(GetPixelBlue(image,p)); 01004 *q++=ScaleQuantumToLong(GetPixelGreen(image,p)); 01005 *q++=ScaleQuantumToLong(GetPixelRed(image,p)); 01006 *q++=ScaleQuantumToLong(GetPixelAlpha(image,p)); 01007 p+=GetPixelChannels(image); 01008 } 01009 } 01010 return; 01011 } 01012 if (LocaleCompare(map,"BGRP") == 0) 01013 { 01014 for (y=0; y < (ssize_t) roi->height; y++) 01015 { 01016 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01017 if (p == (const Quantum *) NULL) 01018 break; 01019 for (x=0; x < (ssize_t) roi->width; x++) 01020 { 01021 *q++=ScaleQuantumToLong(GetPixelBlue(image,p)); 01022 *q++=ScaleQuantumToLong(GetPixelGreen(image,p)); 01023 *q++=ScaleQuantumToLong(GetPixelRed(image,p)); 01024 *q++=0; 01025 p+=GetPixelChannels(image); 01026 } 01027 } 01028 return; 01029 } 01030 if (LocaleCompare(map,"I") == 0) 01031 { 01032 for (y=0; y < (ssize_t) roi->height; y++) 01033 { 01034 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01035 if (p == (const Quantum *) NULL) 01036 break; 01037 for (x=0; x < (ssize_t) roi->width; x++) 01038 { 01039 *q++=ScaleQuantumToLong(GetPixelIntensity(image,p)); 01040 p+=GetPixelChannels(image); 01041 } 01042 } 01043 return; 01044 } 01045 if (LocaleCompare(map,"RGB") == 0) 01046 { 01047 for (y=0; y < (ssize_t) roi->height; y++) 01048 { 01049 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01050 if (p == (const Quantum *) NULL) 01051 break; 01052 for (x=0; x < (ssize_t) roi->width; x++) 01053 { 01054 *q++=ScaleQuantumToLong(GetPixelRed(image,p)); 01055 *q++=ScaleQuantumToLong(GetPixelGreen(image,p)); 01056 *q++=ScaleQuantumToLong(GetPixelBlue(image,p)); 01057 p+=GetPixelChannels(image); 01058 } 01059 } 01060 return; 01061 } 01062 if (LocaleCompare(map,"RGBA") == 0) 01063 { 01064 for (y=0; y < (ssize_t) roi->height; y++) 01065 { 01066 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01067 if (p == (const Quantum *) NULL) 01068 break; 01069 for (x=0; x < (ssize_t) roi->width; x++) 01070 { 01071 *q++=ScaleQuantumToLong(GetPixelRed(image,p)); 01072 *q++=ScaleQuantumToLong(GetPixelGreen(image,p)); 01073 *q++=ScaleQuantumToLong(GetPixelBlue(image,p)); 01074 *q++=ScaleQuantumToLong(GetPixelAlpha(image,p)); 01075 p+=GetPixelChannels(image); 01076 } 01077 } 01078 return; 01079 } 01080 if (LocaleCompare(map,"RGBP") == 0) 01081 { 01082 for (y=0; y < (ssize_t) roi->height; y++) 01083 { 01084 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01085 if (p == (const Quantum *) NULL) 01086 break; 01087 for (x=0; x < (ssize_t) roi->width; x++) 01088 { 01089 *q++=ScaleQuantumToLong(GetPixelRed(image,p)); 01090 *q++=ScaleQuantumToLong(GetPixelGreen(image,p)); 01091 *q++=ScaleQuantumToLong(GetPixelBlue(image,p)); 01092 *q++=0; 01093 p+=GetPixelChannels(image); 01094 } 01095 } 01096 return; 01097 } 01098 for (y=0; y < (ssize_t) roi->height; y++) 01099 { 01100 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01101 if (p == (const Quantum *) NULL) 01102 break; 01103 for (x=0; x < (ssize_t) roi->width; x++) 01104 { 01105 register ssize_t 01106 i; 01107 01108 for (i=0; i < (ssize_t) strlen(map); i++) 01109 { 01110 *q=0; 01111 switch (quantum_map[i]) 01112 { 01113 case RedQuantum: 01114 case CyanQuantum: 01115 { 01116 *q=ScaleQuantumToLong(GetPixelRed(image,p)); 01117 break; 01118 } 01119 case GreenQuantum: 01120 case MagentaQuantum: 01121 { 01122 *q=ScaleQuantumToLong(GetPixelGreen(image,p)); 01123 break; 01124 } 01125 case BlueQuantum: 01126 case YellowQuantum: 01127 { 01128 *q=ScaleQuantumToLong(GetPixelBlue(image,p)); 01129 break; 01130 } 01131 case AlphaQuantum: 01132 { 01133 *q=ScaleQuantumToLong(GetPixelAlpha(image,p)); 01134 break; 01135 } 01136 case OpacityQuantum: 01137 { 01138 *q=ScaleQuantumToLong(GetPixelAlpha(image,p)); 01139 break; 01140 } 01141 case BlackQuantum: 01142 { 01143 if (image->colorspace == CMYKColorspace) 01144 *q=ScaleQuantumToLong(GetPixelBlack(image,p)); 01145 break; 01146 } 01147 case IndexQuantum: 01148 { 01149 *q=ScaleQuantumToLong(GetPixelIntensity(image,p)); 01150 break; 01151 } 01152 default: 01153 break; 01154 } 01155 q++; 01156 } 01157 p+=GetPixelChannels(image); 01158 } 01159 } 01160 } 01161 01162 static void ExportLongLongPixel(const Image *image,const RectangleInfo *roi, 01163 const char *restrict map,const QuantumType *quantum_map,void *pixels, 01164 ExceptionInfo *exception) 01165 { 01166 register const Quantum 01167 *restrict p; 01168 01169 register ssize_t 01170 x; 01171 01172 register MagickSizeType 01173 *restrict q; 01174 01175 ssize_t 01176 y; 01177 01178 q=(MagickSizeType *) pixels; 01179 if (LocaleCompare(map,"BGR") == 0) 01180 { 01181 for (y=0; y < (ssize_t) roi->height; y++) 01182 { 01183 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01184 if (p == (const Quantum *) NULL) 01185 break; 01186 for (x=0; x < (ssize_t) roi->width; x++) 01187 { 01188 *q++=ScaleQuantumToLongLong(GetPixelBlue(image,p)); 01189 *q++=ScaleQuantumToLongLong(GetPixelGreen(image,p)); 01190 *q++=ScaleQuantumToLongLong(GetPixelRed(image,p)); 01191 p+=GetPixelChannels(image); 01192 } 01193 } 01194 return; 01195 } 01196 if (LocaleCompare(map,"BGRA") == 0) 01197 { 01198 for (y=0; y < (ssize_t) roi->height; y++) 01199 { 01200 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01201 if (p == (const Quantum *) NULL) 01202 break; 01203 for (x=0; x < (ssize_t) roi->width; x++) 01204 { 01205 *q++=ScaleQuantumToLongLong(GetPixelBlue(image,p)); 01206 *q++=ScaleQuantumToLongLong(GetPixelGreen(image,p)); 01207 *q++=ScaleQuantumToLongLong(GetPixelRed(image,p)); 01208 *q++=ScaleQuantumToLongLong(GetPixelAlpha(image,p)); 01209 p+=GetPixelChannels(image); 01210 } 01211 } 01212 return; 01213 } 01214 if (LocaleCompare(map,"BGRP") == 0) 01215 { 01216 for (y=0; y < (ssize_t) roi->height; y++) 01217 { 01218 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01219 if (p == (const Quantum *) NULL) 01220 break; 01221 for (x=0; x < (ssize_t) roi->width; x++) 01222 { 01223 *q++=ScaleQuantumToLongLong(GetPixelBlue(image,p)); 01224 *q++=ScaleQuantumToLongLong(GetPixelGreen(image,p)); 01225 *q++=ScaleQuantumToLongLong(GetPixelRed(image,p)); 01226 *q++=0; 01227 p+=GetPixelChannels(image); 01228 } 01229 } 01230 return; 01231 } 01232 if (LocaleCompare(map,"I") == 0) 01233 { 01234 for (y=0; y < (ssize_t) roi->height; y++) 01235 { 01236 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01237 if (p == (const Quantum *) NULL) 01238 break; 01239 for (x=0; x < (ssize_t) roi->width; x++) 01240 { 01241 *q++=ScaleQuantumToLongLong(GetPixelIntensity(image,p)); 01242 p+=GetPixelChannels(image); 01243 } 01244 } 01245 return; 01246 } 01247 if (LocaleCompare(map,"RGB") == 0) 01248 { 01249 for (y=0; y < (ssize_t) roi->height; y++) 01250 { 01251 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01252 if (p == (const Quantum *) NULL) 01253 break; 01254 for (x=0; x < (ssize_t) roi->width; x++) 01255 { 01256 *q++=ScaleQuantumToLongLong(GetPixelRed(image,p)); 01257 *q++=ScaleQuantumToLongLong(GetPixelGreen(image,p)); 01258 *q++=ScaleQuantumToLongLong(GetPixelBlue(image,p)); 01259 p+=GetPixelChannels(image); 01260 } 01261 } 01262 return; 01263 } 01264 if (LocaleCompare(map,"RGBA") == 0) 01265 { 01266 for (y=0; y < (ssize_t) roi->height; y++) 01267 { 01268 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01269 if (p == (const Quantum *) NULL) 01270 break; 01271 for (x=0; x < (ssize_t) roi->width; x++) 01272 { 01273 *q++=ScaleQuantumToLongLong(GetPixelRed(image,p)); 01274 *q++=ScaleQuantumToLongLong(GetPixelGreen(image,p)); 01275 *q++=ScaleQuantumToLongLong(GetPixelBlue(image,p)); 01276 *q++=ScaleQuantumToLongLong(GetPixelAlpha(image,p)); 01277 p+=GetPixelChannels(image); 01278 } 01279 } 01280 return; 01281 } 01282 if (LocaleCompare(map,"RGBP") == 0) 01283 { 01284 for (y=0; y < (ssize_t) roi->height; y++) 01285 { 01286 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01287 if (p == (const Quantum *) NULL) 01288 break; 01289 for (x=0; x < (ssize_t) roi->width; x++) 01290 { 01291 *q++=ScaleQuantumToLongLong(GetPixelRed(image,p)); 01292 *q++=ScaleQuantumToLongLong(GetPixelGreen(image,p)); 01293 *q++=ScaleQuantumToLongLong(GetPixelBlue(image,p)); 01294 *q++=0; 01295 p+=GetPixelChannels(image); 01296 } 01297 } 01298 return; 01299 } 01300 for (y=0; y < (ssize_t) roi->height; y++) 01301 { 01302 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01303 if (p == (const Quantum *) NULL) 01304 break; 01305 for (x=0; x < (ssize_t) roi->width; x++) 01306 { 01307 register ssize_t 01308 i; 01309 01310 for (i=0; i < (ssize_t) strlen(map); i++) 01311 { 01312 *q=0; 01313 switch (quantum_map[i]) 01314 { 01315 case RedQuantum: 01316 case CyanQuantum: 01317 { 01318 *q=ScaleQuantumToLongLong(GetPixelRed(image,p)); 01319 break; 01320 } 01321 case GreenQuantum: 01322 case MagentaQuantum: 01323 { 01324 *q=ScaleQuantumToLongLong(GetPixelGreen(image,p)); 01325 break; 01326 } 01327 case BlueQuantum: 01328 case YellowQuantum: 01329 { 01330 *q=ScaleQuantumToLongLong(GetPixelBlue(image,p)); 01331 break; 01332 } 01333 case AlphaQuantum: 01334 { 01335 *q=ScaleQuantumToLongLong(GetPixelAlpha(image,p)); 01336 break; 01337 } 01338 case OpacityQuantum: 01339 { 01340 *q=ScaleQuantumToLongLong(GetPixelAlpha(image,p)); 01341 break; 01342 } 01343 case BlackQuantum: 01344 { 01345 if (image->colorspace == CMYKColorspace) 01346 *q=ScaleQuantumToLongLong(GetPixelBlack(image,p)); 01347 break; 01348 } 01349 case IndexQuantum: 01350 { 01351 *q=ScaleQuantumToLongLong(GetPixelIntensity(image,p)); 01352 break; 01353 } 01354 default: 01355 break; 01356 } 01357 q++; 01358 } 01359 p+=GetPixelChannels(image); 01360 } 01361 } 01362 } 01363 01364 static void ExportQuantumPixel(const Image *image,const RectangleInfo *roi, 01365 const char *restrict map,const QuantumType *quantum_map,void *pixels, 01366 ExceptionInfo *exception) 01367 { 01368 register const Quantum 01369 *restrict p; 01370 01371 register Quantum 01372 *restrict q; 01373 01374 register ssize_t 01375 x; 01376 01377 ssize_t 01378 y; 01379 01380 q=(Quantum *) pixels; 01381 if (LocaleCompare(map,"BGR") == 0) 01382 { 01383 for (y=0; y < (ssize_t) roi->height; y++) 01384 { 01385 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01386 if (p == (const Quantum *) NULL) 01387 break; 01388 for (x=0; x < (ssize_t) roi->width; x++) 01389 { 01390 *q++=GetPixelBlue(image,p); 01391 *q++=GetPixelGreen(image,p); 01392 *q++=GetPixelRed(image,p); 01393 p+=GetPixelChannels(image); 01394 } 01395 } 01396 return; 01397 } 01398 if (LocaleCompare(map,"BGRA") == 0) 01399 { 01400 for (y=0; y < (ssize_t) roi->height; y++) 01401 { 01402 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01403 if (p == (const Quantum *) NULL) 01404 break; 01405 for (x=0; x < (ssize_t) roi->width; x++) 01406 { 01407 *q++=GetPixelBlue(image,p); 01408 *q++=GetPixelGreen(image,p); 01409 *q++=GetPixelRed(image,p); 01410 *q++=(Quantum) (GetPixelAlpha(image,p)); 01411 p+=GetPixelChannels(image); 01412 } 01413 } 01414 return; 01415 } 01416 if (LocaleCompare(map,"BGRP") == 0) 01417 { 01418 for (y=0; y < (ssize_t) roi->height; y++) 01419 { 01420 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01421 if (p == (const Quantum *) NULL) 01422 break; 01423 for (x=0; x < (ssize_t) roi->width; x++) 01424 { 01425 *q++=GetPixelBlue(image,p); 01426 *q++=GetPixelGreen(image,p); 01427 *q++=GetPixelRed(image,p); 01428 *q++=(Quantum) 0; 01429 p+=GetPixelChannels(image); 01430 } 01431 } 01432 return; 01433 } 01434 if (LocaleCompare(map,"I") == 0) 01435 { 01436 for (y=0; y < (ssize_t) roi->height; y++) 01437 { 01438 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01439 if (p == (const Quantum *) NULL) 01440 break; 01441 for (x=0; x < (ssize_t) roi->width; x++) 01442 { 01443 *q++=GetPixelIntensity(image,p); 01444 p+=GetPixelChannels(image); 01445 } 01446 } 01447 return; 01448 } 01449 if (LocaleCompare(map,"RGB") == 0) 01450 { 01451 for (y=0; y < (ssize_t) roi->height; y++) 01452 { 01453 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01454 if (p == (const Quantum *) NULL) 01455 break; 01456 for (x=0; x < (ssize_t) roi->width; x++) 01457 { 01458 *q++=GetPixelRed(image,p); 01459 *q++=GetPixelGreen(image,p); 01460 *q++=GetPixelBlue(image,p); 01461 p+=GetPixelChannels(image); 01462 } 01463 } 01464 return; 01465 } 01466 if (LocaleCompare(map,"RGBA") == 0) 01467 { 01468 for (y=0; y < (ssize_t) roi->height; y++) 01469 { 01470 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01471 if (p == (const Quantum *) NULL) 01472 break; 01473 for (x=0; x < (ssize_t) roi->width; x++) 01474 { 01475 *q++=GetPixelRed(image,p); 01476 *q++=GetPixelGreen(image,p); 01477 *q++=GetPixelBlue(image,p); 01478 *q++=(Quantum) (GetPixelAlpha(image,p)); 01479 p+=GetPixelChannels(image); 01480 } 01481 } 01482 return; 01483 } 01484 if (LocaleCompare(map,"RGBP") == 0) 01485 { 01486 for (y=0; y < (ssize_t) roi->height; y++) 01487 { 01488 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01489 if (p == (const Quantum *) NULL) 01490 break; 01491 for (x=0; x < (ssize_t) roi->width; x++) 01492 { 01493 *q++=GetPixelRed(image,p); 01494 *q++=GetPixelGreen(image,p); 01495 *q++=GetPixelBlue(image,p); 01496 *q++=(Quantum) 0; 01497 p+=GetPixelChannels(image); 01498 } 01499 } 01500 return; 01501 } 01502 for (y=0; y < (ssize_t) roi->height; y++) 01503 { 01504 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01505 if (p == (const Quantum *) NULL) 01506 break; 01507 for (x=0; x < (ssize_t) roi->width; x++) 01508 { 01509 register ssize_t 01510 i; 01511 01512 for (i=0; i < (ssize_t) strlen(map); i++) 01513 { 01514 *q=(Quantum) 0; 01515 switch (quantum_map[i]) 01516 { 01517 case RedQuantum: 01518 case CyanQuantum: 01519 { 01520 *q=GetPixelRed(image,p); 01521 break; 01522 } 01523 case GreenQuantum: 01524 case MagentaQuantum: 01525 { 01526 *q=GetPixelGreen(image,p); 01527 break; 01528 } 01529 case BlueQuantum: 01530 case YellowQuantum: 01531 { 01532 *q=GetPixelBlue(image,p); 01533 break; 01534 } 01535 case AlphaQuantum: 01536 { 01537 *q=GetPixelAlpha(image,p); 01538 break; 01539 } 01540 case OpacityQuantum: 01541 { 01542 *q=GetPixelAlpha(image,p); 01543 break; 01544 } 01545 case BlackQuantum: 01546 { 01547 if (image->colorspace == CMYKColorspace) 01548 *q=GetPixelBlack(image,p); 01549 break; 01550 } 01551 case IndexQuantum: 01552 { 01553 *q=(GetPixelIntensity(image,p)); 01554 break; 01555 } 01556 default: 01557 { 01558 *q=(Quantum) 0; 01559 break; 01560 } 01561 } 01562 q++; 01563 } 01564 p+=GetPixelChannels(image); 01565 } 01566 } 01567 } 01568 01569 static void ExportShortPixel(const Image *image,const RectangleInfo *roi, 01570 const char *restrict map,const QuantumType *quantum_map,void *pixels, 01571 ExceptionInfo *exception) 01572 { 01573 register const Quantum 01574 *restrict p; 01575 01576 register ssize_t 01577 x; 01578 01579 ssize_t 01580 y; 01581 01582 register unsigned short 01583 *restrict q; 01584 01585 q=(unsigned short *) pixels; 01586 if (LocaleCompare(map,"BGR") == 0) 01587 { 01588 for (y=0; y < (ssize_t) roi->height; y++) 01589 { 01590 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01591 if (p == (const Quantum *) NULL) 01592 break; 01593 for (x=0; x < (ssize_t) roi->width; x++) 01594 { 01595 *q++=ScaleQuantumToShort(GetPixelBlue(image,p)); 01596 *q++=ScaleQuantumToShort(GetPixelGreen(image,p)); 01597 *q++=ScaleQuantumToShort(GetPixelRed(image,p)); 01598 p+=GetPixelChannels(image); 01599 } 01600 } 01601 return; 01602 } 01603 if (LocaleCompare(map,"BGRA") == 0) 01604 { 01605 for (y=0; y < (ssize_t) roi->height; y++) 01606 { 01607 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01608 if (p == (const Quantum *) NULL) 01609 break; 01610 for (x=0; x < (ssize_t) roi->width; x++) 01611 { 01612 *q++=ScaleQuantumToShort(GetPixelBlue(image,p)); 01613 *q++=ScaleQuantumToShort(GetPixelGreen(image,p)); 01614 *q++=ScaleQuantumToShort(GetPixelRed(image,p)); 01615 *q++=ScaleQuantumToShort(GetPixelAlpha(image,p)); 01616 p+=GetPixelChannels(image); 01617 } 01618 } 01619 return; 01620 } 01621 if (LocaleCompare(map,"BGRP") == 0) 01622 { 01623 for (y=0; y < (ssize_t) roi->height; y++) 01624 { 01625 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01626 if (p == (const Quantum *) NULL) 01627 break; 01628 for (x=0; x < (ssize_t) roi->width; x++) 01629 { 01630 *q++=ScaleQuantumToShort(GetPixelBlue(image,p)); 01631 *q++=ScaleQuantumToShort(GetPixelGreen(image,p)); 01632 *q++=ScaleQuantumToShort(GetPixelRed(image,p)); 01633 *q++=0; 01634 p+=GetPixelChannels(image); 01635 } 01636 } 01637 return; 01638 } 01639 if (LocaleCompare(map,"I") == 0) 01640 { 01641 for (y=0; y < (ssize_t) roi->height; y++) 01642 { 01643 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01644 if (p == (const Quantum *) NULL) 01645 break; 01646 for (x=0; x < (ssize_t) roi->width; x++) 01647 { 01648 *q++=ScaleQuantumToShort(GetPixelIntensity(image,p)); 01649 p+=GetPixelChannels(image); 01650 } 01651 } 01652 return; 01653 } 01654 if (LocaleCompare(map,"RGB") == 0) 01655 { 01656 for (y=0; y < (ssize_t) roi->height; y++) 01657 { 01658 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01659 if (p == (const Quantum *) NULL) 01660 break; 01661 for (x=0; x < (ssize_t) roi->width; x++) 01662 { 01663 *q++=ScaleQuantumToShort(GetPixelRed(image,p)); 01664 *q++=ScaleQuantumToShort(GetPixelGreen(image,p)); 01665 *q++=ScaleQuantumToShort(GetPixelBlue(image,p)); 01666 p+=GetPixelChannels(image); 01667 } 01668 } 01669 return; 01670 } 01671 if (LocaleCompare(map,"RGBA") == 0) 01672 { 01673 for (y=0; y < (ssize_t) roi->height; y++) 01674 { 01675 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01676 if (p == (const Quantum *) NULL) 01677 break; 01678 for (x=0; x < (ssize_t) roi->width; x++) 01679 { 01680 *q++=ScaleQuantumToShort(GetPixelRed(image,p)); 01681 *q++=ScaleQuantumToShort(GetPixelGreen(image,p)); 01682 *q++=ScaleQuantumToShort(GetPixelBlue(image,p)); 01683 *q++=ScaleQuantumToShort(GetPixelAlpha(image,p)); 01684 p+=GetPixelChannels(image); 01685 } 01686 } 01687 return; 01688 } 01689 if (LocaleCompare(map,"RGBP") == 0) 01690 { 01691 for (y=0; y < (ssize_t) roi->height; y++) 01692 { 01693 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01694 if (p == (const Quantum *) NULL) 01695 break; 01696 for (x=0; x < (ssize_t) roi->width; x++) 01697 { 01698 *q++=ScaleQuantumToShort(GetPixelRed(image,p)); 01699 *q++=ScaleQuantumToShort(GetPixelGreen(image,p)); 01700 *q++=ScaleQuantumToShort(GetPixelBlue(image,p)); 01701 *q++=0; 01702 p+=GetPixelChannels(image); 01703 } 01704 } 01705 return; 01706 } 01707 for (y=0; y < (ssize_t) roi->height; y++) 01708 { 01709 p=GetVirtualPixels(image,roi->x,roi->y+y,roi->width,1,exception); 01710 if (p == (const Quantum *) NULL) 01711 break; 01712 for (x=0; x < (ssize_t) roi->width; x++) 01713 { 01714 register ssize_t 01715 i; 01716 01717 for (i=0; i < (ssize_t) strlen(map); i++) 01718 { 01719 *q=0; 01720 switch (quantum_map[i]) 01721 { 01722 case RedQuantum: 01723 case CyanQuantum: 01724 { 01725 *q=ScaleQuantumToShort(GetPixelRed(image,p)); 01726 break; 01727 } 01728 case GreenQuantum: 01729 case MagentaQuantum: 01730 { 01731 *q=ScaleQuantumToShort(GetPixelGreen(image,p)); 01732 break; 01733 } 01734 case BlueQuantum: 01735 case YellowQuantum: 01736 { 01737 *q=ScaleQuantumToShort(GetPixelBlue(image,p)); 01738 break; 01739 } 01740 case AlphaQuantum: 01741 { 01742 *q=ScaleQuantumToShort(GetPixelAlpha(image,p)); 01743 break; 01744 } 01745 case OpacityQuantum: 01746 { 01747 *q=ScaleQuantumToShort(GetPixelAlpha(image,p)); 01748 break; 01749 } 01750 case BlackQuantum: 01751 { 01752 if (image->colorspace == CMYKColorspace) 01753 *q=ScaleQuantumToShort(GetPixelBlack(image,p)); 01754 break; 01755 } 01756 case IndexQuantum: 01757 { 01758 *q=ScaleQuantumToShort(GetPixelIntensity(image,p)); 01759 break; 01760 } 01761 default: 01762 break; 01763 } 01764 q++; 01765 } 01766 p+=GetPixelChannels(image); 01767 } 01768 } 01769 } 01770 01771 MagickExport MagickBooleanType ExportImagePixels(const Image *image, 01772 const ssize_t x,const ssize_t y,const size_t width,const size_t height, 01773 const char *map,const StorageType type,void *pixels,ExceptionInfo *exception) 01774 { 01775 QuantumType 01776 *quantum_map; 01777 01778 RectangleInfo 01779 roi; 01780 01781 register ssize_t 01782 i; 01783 01784 assert(image != (Image *) NULL); 01785 assert(image->signature == MagickSignature); 01786 if (image->debug != MagickFalse) 01787 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); 01788 quantum_map=(QuantumType *) AcquireQuantumMemory(strlen(map), 01789 sizeof(*quantum_map)); 01790 if (quantum_map == (QuantumType *) NULL) 01791 { 01792 (void) ThrowMagickException(exception,GetMagickModule(), 01793 ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename); 01794 return(MagickFalse); 01795 } 01796 for (i=0; i < (ssize_t) strlen(map); i++) 01797 { 01798 switch (map[i]) 01799 { 01800 case 'A': 01801 case 'a': 01802 { 01803 quantum_map[i]=AlphaQuantum; 01804 break; 01805 } 01806 case 'B': 01807 case 'b': 01808 { 01809 quantum_map[i]=BlueQuantum; 01810 break; 01811 } 01812 case 'C': 01813 case 'c': 01814 { 01815 quantum_map[i]=CyanQuantum; 01816 if (image->colorspace == CMYKColorspace) 01817 break; 01818 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); 01819 (void) ThrowMagickException(exception,GetMagickModule(),ImageError, 01820 "ColorSeparatedImageRequired","`%s'",map); 01821 return(MagickFalse); 01822 } 01823 case 'g': 01824 case 'G': 01825 { 01826 quantum_map[i]=GreenQuantum; 01827 break; 01828 } 01829 case 'I': 01830 case 'i': 01831 { 01832 quantum_map[i]=IndexQuantum; 01833 break; 01834 } 01835 case 'K': 01836 case 'k': 01837 { 01838 quantum_map[i]=BlackQuantum; 01839 if (image->colorspace == CMYKColorspace) 01840 break; 01841 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); 01842 (void) ThrowMagickException(exception,GetMagickModule(),ImageError, 01843 "ColorSeparatedImageRequired","`%s'",map); 01844 return(MagickFalse); 01845 } 01846 case 'M': 01847 case 'm': 01848 { 01849 quantum_map[i]=MagentaQuantum; 01850 if (image->colorspace == CMYKColorspace) 01851 break; 01852 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); 01853 (void) ThrowMagickException(exception,GetMagickModule(),ImageError, 01854 "ColorSeparatedImageRequired","`%s'",map); 01855 return(MagickFalse); 01856 } 01857 case 'o': 01858 case 'O': 01859 { 01860 quantum_map[i]=OpacityQuantum; 01861 break; 01862 } 01863 case 'P': 01864 case 'p': 01865 { 01866 quantum_map[i]=UndefinedQuantum; 01867 break; 01868 } 01869 case 'R': 01870 case 'r': 01871 { 01872 quantum_map[i]=RedQuantum; 01873 break; 01874 } 01875 case 'Y': 01876 case 'y': 01877 { 01878 quantum_map[i]=YellowQuantum; 01879 if (image->colorspace == CMYKColorspace) 01880 break; 01881 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); 01882 (void) ThrowMagickException(exception,GetMagickModule(),ImageError, 01883 "ColorSeparatedImageRequired","`%s'",map); 01884 return(MagickFalse); 01885 } 01886 default: 01887 { 01888 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); 01889 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, 01890 "UnrecognizedPixelMap","`%s'",map); 01891 return(MagickFalse); 01892 } 01893 } 01894 } 01895 roi.width=width; 01896 roi.height=height; 01897 roi.x=x; 01898 roi.y=y; 01899 switch (type) 01900 { 01901 case CharPixel: 01902 { 01903 ExportCharPixel(image,&roi,map,quantum_map,pixels,exception); 01904 break; 01905 } 01906 case DoublePixel: 01907 { 01908 ExportDoublePixel(image,&roi,map,quantum_map,pixels,exception); 01909 break; 01910 } 01911 case FloatPixel: 01912 { 01913 ExportFloatPixel(image,&roi,map,quantum_map,pixels,exception); 01914 break; 01915 } 01916 case LongPixel: 01917 { 01918 ExportLongPixel(image,&roi,map,quantum_map,pixels,exception); 01919 break; 01920 } 01921 case LongLongPixel: 01922 { 01923 ExportLongLongPixel(image,&roi,map,quantum_map,pixels,exception); 01924 break; 01925 } 01926 case QuantumPixel: 01927 { 01928 ExportQuantumPixel(image,&roi,map,quantum_map,pixels,exception); 01929 break; 01930 } 01931 case ShortPixel: 01932 { 01933 ExportShortPixel(image,&roi,map,quantum_map,pixels,exception); 01934 break; 01935 } 01936 default: 01937 { 01938 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); 01939 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, 01940 "UnrecognizedPixelMap","`%s'",map); 01941 break; 01942 } 01943 } 01944 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); 01945 return(MagickTrue); 01946 } 01947 01948 /* 01949 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 01950 % % 01951 % % 01952 % % 01953 % G e t P i x e l I n f o % 01954 % % 01955 % % 01956 % % 01957 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 01958 % 01959 % GetPixelInfo() initializes the PixelInfo structure. 01960 % 01961 % The format of the GetPixelInfo method is: 01962 % 01963 % GetPixelInfo(const Image *image,PixelInfo *pixel) 01964 % 01965 % A description of each parameter follows: 01966 % 01967 % o image: the image. 01968 % 01969 % o pixel: Specifies a pointer to a PixelInfo structure. 01970 % 01971 */ 01972 MagickExport void GetPixelInfo(const Image *image,PixelInfo *pixel) 01973 { 01974 pixel->storage_class=DirectClass; 01975 pixel->colorspace=RGBColorspace; 01976 pixel->matte=MagickFalse; 01977 pixel->fuzz=0.0; 01978 pixel->depth=MAGICKCORE_QUANTUM_DEPTH; 01979 pixel->red=0.0; 01980 pixel->green=0.0; 01981 pixel->blue=0.0; 01982 pixel->black=0.0; 01983 pixel->alpha=(MagickRealType) OpaqueAlpha; 01984 pixel->index=0.0; 01985 if (image == (const Image *) NULL) 01986 return; 01987 pixel->storage_class=image->storage_class; 01988 pixel->colorspace=image->colorspace; 01989 pixel->matte=image->matte; 01990 pixel->depth=image->depth; 01991 pixel->fuzz=image->fuzz; 01992 } 01993 01994 /* 01995 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 01996 % % 01997 % % 01998 % % 01999 % I m p o r t I m a g e P i x e l s % 02000 % % 02001 % % 02002 % % 02003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 02004 % 02005 % ImportImagePixels() accepts pixel data and stores in the image at the 02006 % location you specify. The method returns MagickTrue on success otherwise 02007 % MagickFalse if an error is encountered. The pixel data can be either char, 02008 % Quantum, short int, unsigned int, unsigned long long, float, or double in 02009 % the order specified by map. 02010 % 02011 % Suppose your want to upload the first scanline of a 640x480 image from 02012 % character data in red-green-blue order: 02013 % 02014 % ImportImagePixels(image,0,0,640,1,"RGB",CharPixel,pixels); 02015 % 02016 % The format of the ImportImagePixels method is: 02017 % 02018 % MagickBooleanType ImportImagePixels(Image *image,const ssize_t x, 02019 % const ssize_t y,const size_t width,const size_t height, 02020 % const char *map,const StorageType type,const void *pixels, 02021 % ExceptionInfo *exception) 02022 % 02023 % A description of each parameter follows: 02024 % 02025 % o image: the image. 02026 % 02027 % o x,y,width,height: These values define the perimeter 02028 % of a region of pixels you want to define. 02029 % 02030 % o map: This string reflects the expected ordering of the pixel array. 02031 % It can be any combination or order of R = red, G = green, B = blue, 02032 % A = alpha (0 is transparent), O = opacity (0 is opaque), C = cyan, 02033 % Y = yellow, M = magenta, K = black, I = intensity (for grayscale), 02034 % P = pad. 02035 % 02036 % o type: Define the data type of the pixels. Float and double types are 02037 % normalized to [0..1] otherwise [0..QuantumRange]. Choose from these 02038 % types: CharPixel (char *), DoublePixel (double *), FloatPixel (float *), 02039 % LongPixel (unsigned int *), LongLongPixel (unsigned long long *), 02040 % QuantumPixel (Quantum *), or ShortPixel (unsigned short *). 02041 % 02042 % o pixels: This array of values contain the pixel components as defined by 02043 % map and type. You must preallocate this array where the expected 02044 % length varies depending on the values of width, height, map, and type. 02045 % 02046 % o exception: return any errors or warnings in this structure. 02047 % 02048 */ 02049 02050 static void ImportCharPixel(Image *image,const RectangleInfo *roi, 02051 const char *restrict map,const QuantumType *quantum_map,const void *pixels, 02052 ExceptionInfo *exception) 02053 { 02054 register const unsigned char 02055 *restrict p; 02056 02057 register Quantum 02058 *restrict q; 02059 02060 register ssize_t 02061 x; 02062 02063 ssize_t 02064 y; 02065 02066 p=(const unsigned char *) pixels; 02067 if (LocaleCompare(map,"BGR") == 0) 02068 { 02069 for (y=0; y < (ssize_t) roi->height; y++) 02070 { 02071 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02072 if (q == (Quantum *) NULL) 02073 break; 02074 for (x=0; x < (ssize_t) roi->width; x++) 02075 { 02076 SetPixelBlue(image,ScaleCharToQuantum(*p++),q); 02077 SetPixelGreen(image,ScaleCharToQuantum(*p++),q); 02078 SetPixelRed(image,ScaleCharToQuantum(*p++),q); 02079 q+=GetPixelChannels(image); 02080 } 02081 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02082 break; 02083 } 02084 return; 02085 } 02086 if (LocaleCompare(map,"BGRA") == 0) 02087 { 02088 for (y=0; y < (ssize_t) roi->height; y++) 02089 { 02090 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02091 if (q == (Quantum *) NULL) 02092 break; 02093 for (x=0; x < (ssize_t) roi->width; x++) 02094 { 02095 SetPixelBlue(image,ScaleCharToQuantum(*p++),q); 02096 SetPixelGreen(image,ScaleCharToQuantum(*p++),q); 02097 SetPixelRed(image,ScaleCharToQuantum(*p++),q); 02098 SetPixelAlpha(image,ScaleCharToQuantum(*p++),q); 02099 q+=GetPixelChannels(image); 02100 } 02101 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02102 break; 02103 } 02104 return; 02105 } 02106 if (LocaleCompare(map,"BGRO") == 0) 02107 { 02108 for (y=0; y < (ssize_t) roi->height; y++) 02109 { 02110 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02111 if (q == (Quantum *) NULL) 02112 break; 02113 for (x=0; x < (ssize_t) roi->width; x++) 02114 { 02115 SetPixelBlue(image,ScaleCharToQuantum(*p++),q); 02116 SetPixelGreen(image,ScaleCharToQuantum(*p++),q); 02117 SetPixelRed(image,ScaleCharToQuantum(*p++),q); 02118 SetPixelAlpha(image,ScaleCharToQuantum(*p++),q); 02119 q+=GetPixelChannels(image); 02120 } 02121 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02122 break; 02123 } 02124 return; 02125 } 02126 if (LocaleCompare(map,"BGRP") == 0) 02127 { 02128 for (y=0; y < (ssize_t) roi->height; y++) 02129 { 02130 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02131 if (q == (Quantum *) NULL) 02132 break; 02133 for (x=0; x < (ssize_t) roi->width; x++) 02134 { 02135 SetPixelBlue(image,ScaleCharToQuantum(*p++),q); 02136 SetPixelGreen(image,ScaleCharToQuantum(*p++),q); 02137 SetPixelRed(image,ScaleCharToQuantum(*p++),q); 02138 p++; 02139 q+=GetPixelChannels(image); 02140 } 02141 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02142 break; 02143 } 02144 return; 02145 } 02146 if (LocaleCompare(map,"I") == 0) 02147 { 02148 for (y=0; y < (ssize_t) roi->height; y++) 02149 { 02150 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02151 if (q == (Quantum *) NULL) 02152 break; 02153 for (x=0; x < (ssize_t) roi->width; x++) 02154 { 02155 SetPixelGray(image,ScaleCharToQuantum(*p++),q); 02156 q+=GetPixelChannels(image); 02157 } 02158 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02159 break; 02160 } 02161 return; 02162 } 02163 if (LocaleCompare(map,"RGB") == 0) 02164 { 02165 for (y=0; y < (ssize_t) roi->height; y++) 02166 { 02167 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02168 if (q == (Quantum *) NULL) 02169 break; 02170 for (x=0; x < (ssize_t) roi->width; x++) 02171 { 02172 SetPixelRed(image,ScaleCharToQuantum(*p++),q); 02173 SetPixelGreen(image,ScaleCharToQuantum(*p++),q); 02174 SetPixelBlue(image,ScaleCharToQuantum(*p++),q); 02175 q+=GetPixelChannels(image); 02176 } 02177 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02178 break; 02179 } 02180 return; 02181 } 02182 if (LocaleCompare(map,"RGBA") == 0) 02183 { 02184 for (y=0; y < (ssize_t) roi->height; y++) 02185 { 02186 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02187 if (q == (Quantum *) NULL) 02188 break; 02189 for (x=0; x < (ssize_t) roi->width; x++) 02190 { 02191 SetPixelRed(image,ScaleCharToQuantum(*p++),q); 02192 SetPixelGreen(image,ScaleCharToQuantum(*p++),q); 02193 SetPixelBlue(image,ScaleCharToQuantum(*p++),q); 02194 SetPixelAlpha(image,ScaleCharToQuantum(*p++),q); 02195 q+=GetPixelChannels(image); 02196 } 02197 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02198 break; 02199 } 02200 return; 02201 } 02202 if (LocaleCompare(map,"RGBO") == 0) 02203 { 02204 for (y=0; y < (ssize_t) roi->height; y++) 02205 { 02206 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02207 if (q == (Quantum *) NULL) 02208 break; 02209 for (x=0; x < (ssize_t) roi->width; x++) 02210 { 02211 SetPixelRed(image,ScaleCharToQuantum(*p++),q); 02212 SetPixelGreen(image,ScaleCharToQuantum(*p++),q); 02213 SetPixelBlue(image,ScaleCharToQuantum(*p++),q); 02214 SetPixelAlpha(image,ScaleCharToQuantum(*p++),q); 02215 q+=GetPixelChannels(image); 02216 } 02217 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02218 break; 02219 } 02220 return; 02221 } 02222 if (LocaleCompare(map,"RGBP") == 0) 02223 { 02224 for (y=0; y < (ssize_t) roi->height; y++) 02225 { 02226 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02227 if (q == (Quantum *) NULL) 02228 break; 02229 for (x=0; x < (ssize_t) roi->width; x++) 02230 { 02231 SetPixelRed(image,ScaleCharToQuantum(*p++),q); 02232 SetPixelGreen(image,ScaleCharToQuantum(*p++),q); 02233 SetPixelBlue(image,ScaleCharToQuantum(*p++),q); 02234 p++; 02235 q+=GetPixelChannels(image); 02236 } 02237 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02238 break; 02239 } 02240 return; 02241 } 02242 for (y=0; y < (ssize_t) roi->height; y++) 02243 { 02244 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02245 if (q == (Quantum *) NULL) 02246 break; 02247 for (x=0; x < (ssize_t) roi->width; x++) 02248 { 02249 register ssize_t 02250 i; 02251 02252 for (i=0; i < (ssize_t) strlen(map); i++) 02253 { 02254 switch (quantum_map[i]) 02255 { 02256 case RedQuantum: 02257 case CyanQuantum: 02258 { 02259 SetPixelRed(image,ScaleCharToQuantum(*p),q); 02260 break; 02261 } 02262 case GreenQuantum: 02263 case MagentaQuantum: 02264 { 02265 SetPixelGreen(image,ScaleCharToQuantum(*p),q); 02266 break; 02267 } 02268 case BlueQuantum: 02269 case YellowQuantum: 02270 { 02271 SetPixelBlue(image,ScaleCharToQuantum(*p),q); 02272 break; 02273 } 02274 case AlphaQuantum: 02275 { 02276 SetPixelAlpha(image,ScaleCharToQuantum(*p),q); 02277 break; 02278 } 02279 case OpacityQuantum: 02280 { 02281 SetPixelAlpha(image,ScaleCharToQuantum(*p),q); 02282 break; 02283 } 02284 case BlackQuantum: 02285 { 02286 SetPixelBlack(image,ScaleCharToQuantum(*p),q); 02287 break; 02288 } 02289 case IndexQuantum: 02290 { 02291 SetPixelGray(image,ScaleCharToQuantum(*p),q); 02292 break; 02293 } 02294 default: 02295 break; 02296 } 02297 p++; 02298 } 02299 q+=GetPixelChannels(image); 02300 } 02301 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02302 break; 02303 } 02304 } 02305 02306 static void ImportDoublePixel(Image *image,const RectangleInfo *roi, 02307 const char *restrict map,const QuantumType *quantum_map,const void *pixels, 02308 ExceptionInfo *exception) 02309 { 02310 register const double 02311 *restrict p; 02312 02313 register Quantum 02314 *restrict q; 02315 02316 register ssize_t 02317 x; 02318 02319 ssize_t 02320 y; 02321 02322 p=(const double *) pixels; 02323 if (LocaleCompare(map,"BGR") == 0) 02324 { 02325 for (y=0; y < (ssize_t) roi->height; y++) 02326 { 02327 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02328 if (q == (Quantum *) NULL) 02329 break; 02330 for (x=0; x < (ssize_t) roi->width; x++) 02331 { 02332 SetPixelBlue(image,ClampToQuantum((MagickRealType) QuantumRange* 02333 (*p)),q); 02334 p++; 02335 SetPixelGreen(image,ClampToQuantum((MagickRealType) QuantumRange* 02336 (*p)),q); 02337 p++; 02338 SetPixelRed(image,ClampToQuantum((MagickRealType) QuantumRange* 02339 (*p)),q); 02340 p++; 02341 q+=GetPixelChannels(image); 02342 } 02343 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02344 break; 02345 } 02346 return; 02347 } 02348 if (LocaleCompare(map,"BGRA") == 0) 02349 { 02350 for (y=0; y < (ssize_t) roi->height; y++) 02351 { 02352 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02353 if (q == (Quantum *) NULL) 02354 break; 02355 for (x=0; x < (ssize_t) roi->width; x++) 02356 { 02357 SetPixelBlue(image,ClampToQuantum((MagickRealType) QuantumRange* 02358 (*p)),q); 02359 p++; 02360 SetPixelGreen(image,ClampToQuantum((MagickRealType) QuantumRange* 02361 (*p)),q); 02362 p++; 02363 SetPixelRed(image,ClampToQuantum((MagickRealType) QuantumRange* 02364 (*p)),q); 02365 p++; 02366 SetPixelAlpha(image,ClampToQuantum((MagickRealType) QuantumRange* 02367 (*p)),q); 02368 p++; 02369 q+=GetPixelChannels(image); 02370 } 02371 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02372 break; 02373 } 02374 return; 02375 } 02376 if (LocaleCompare(map,"BGRP") == 0) 02377 { 02378 for (y=0; y < (ssize_t) roi->height; y++) 02379 { 02380 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02381 if (q == (Quantum *) NULL) 02382 break; 02383 for (x=0; x < (ssize_t) roi->width; x++) 02384 { 02385 SetPixelBlue(image,ClampToQuantum((MagickRealType) QuantumRange* 02386 (*p)),q); 02387 p++; 02388 SetPixelGreen(image,ClampToQuantum((MagickRealType) QuantumRange* 02389 (*p)),q); 02390 p++; 02391 SetPixelRed(image,ClampToQuantum((MagickRealType) QuantumRange* 02392 (*p)),q); 02393 p++; 02394 p++; 02395 q+=GetPixelChannels(image); 02396 } 02397 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02398 break; 02399 } 02400 return; 02401 } 02402 if (LocaleCompare(map,"I") == 0) 02403 { 02404 for (y=0; y < (ssize_t) roi->height; y++) 02405 { 02406 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02407 if (q == (Quantum *) NULL) 02408 break; 02409 for (x=0; x < (ssize_t) roi->width; x++) 02410 { 02411 SetPixelGray(image,ClampToQuantum((MagickRealType) QuantumRange* 02412 (*p)),q); 02413 p++; 02414 q+=GetPixelChannels(image); 02415 } 02416 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02417 break; 02418 } 02419 return; 02420 } 02421 if (LocaleCompare(map,"RGB") == 0) 02422 { 02423 for (y=0; y < (ssize_t) roi->height; y++) 02424 { 02425 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02426 if (q == (Quantum *) NULL) 02427 break; 02428 for (x=0; x < (ssize_t) roi->width; x++) 02429 { 02430 SetPixelRed(image,ClampToQuantum((MagickRealType) QuantumRange* 02431 (*p)),q); 02432 p++; 02433 SetPixelGreen(image,ClampToQuantum((MagickRealType) QuantumRange* 02434 (*p)),q); 02435 p++; 02436 SetPixelBlue(image,ClampToQuantum((MagickRealType) QuantumRange* 02437 (*p)),q); 02438 p++; 02439 q+=GetPixelChannels(image); 02440 } 02441 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02442 break; 02443 } 02444 return; 02445 } 02446 if (LocaleCompare(map,"RGBA") == 0) 02447 { 02448 for (y=0; y < (ssize_t) roi->height; y++) 02449 { 02450 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02451 if (q == (Quantum *) NULL) 02452 break; 02453 for (x=0; x < (ssize_t) roi->width; x++) 02454 { 02455 SetPixelRed(image,ClampToQuantum((MagickRealType) QuantumRange* 02456 (*p)),q); 02457 p++; 02458 SetPixelGreen(image,ClampToQuantum((MagickRealType) QuantumRange* 02459 (*p)),q); 02460 p++; 02461 SetPixelBlue(image,ClampToQuantum((MagickRealType) QuantumRange* 02462 (*p)),q); 02463 p++; 02464 SetPixelAlpha(image,ClampToQuantum((MagickRealType) QuantumRange* 02465 (*p)),q); 02466 p++; 02467 q+=GetPixelChannels(image); 02468 } 02469 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02470 break; 02471 } 02472 return; 02473 } 02474 if (LocaleCompare(map,"RGBP") == 0) 02475 { 02476 for (y=0; y < (ssize_t) roi->height; y++) 02477 { 02478 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02479 if (q == (Quantum *) NULL) 02480 break; 02481 for (x=0; x < (ssize_t) roi->width; x++) 02482 { 02483 SetPixelRed(image,ClampToQuantum((MagickRealType) QuantumRange* 02484 (*p)),q); 02485 p++; 02486 SetPixelGreen(image,ClampToQuantum((MagickRealType) QuantumRange* 02487 (*p)),q); 02488 p++; 02489 SetPixelBlue(image,ClampToQuantum((MagickRealType) QuantumRange* 02490 (*p)),q); 02491 p++; 02492 q+=GetPixelChannels(image); 02493 } 02494 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02495 break; 02496 } 02497 return; 02498 } 02499 for (y=0; y < (ssize_t) roi->height; y++) 02500 { 02501 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02502 if (q == (Quantum *) NULL) 02503 break; 02504 for (x=0; x < (ssize_t) roi->width; x++) 02505 { 02506 register ssize_t 02507 i; 02508 02509 for (i=0; i < (ssize_t) strlen(map); i++) 02510 { 02511 switch (quantum_map[i]) 02512 { 02513 case RedQuantum: 02514 case CyanQuantum: 02515 { 02516 SetPixelRed(image,ClampToQuantum((MagickRealType) 02517 QuantumRange*(*p)),q); 02518 break; 02519 } 02520 case GreenQuantum: 02521 case MagentaQuantum: 02522 { 02523 SetPixelGreen(image,ClampToQuantum((MagickRealType) 02524 QuantumRange*(*p)),q); 02525 break; 02526 } 02527 case BlueQuantum: 02528 case YellowQuantum: 02529 { 02530 SetPixelBlue(image,ClampToQuantum((MagickRealType) 02531 QuantumRange*(*p)),q); 02532 break; 02533 } 02534 case AlphaQuantum: 02535 { 02536 SetPixelAlpha(image,ClampToQuantum((MagickRealType) 02537 QuantumRange*(*p)),q); 02538 break; 02539 } 02540 case OpacityQuantum: 02541 { 02542 SetPixelAlpha(image,ClampToQuantum((MagickRealType) 02543 QuantumRange*(*p)),q); 02544 break; 02545 } 02546 case BlackQuantum: 02547 { 02548 SetPixelBlack(image,ClampToQuantum((MagickRealType) 02549 QuantumRange*(*p)),q); 02550 break; 02551 } 02552 case IndexQuantum: 02553 { 02554 SetPixelGray(image,ClampToQuantum((MagickRealType) 02555 QuantumRange*(*p)),q); 02556 break; 02557 } 02558 default: 02559 break; 02560 } 02561 p++; 02562 } 02563 q+=GetPixelChannels(image); 02564 } 02565 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02566 break; 02567 } 02568 } 02569 02570 static void ImportFloatPixel(Image *image,const RectangleInfo *roi, 02571 const char *restrict map,const QuantumType *quantum_map,const void *pixels, 02572 ExceptionInfo *exception) 02573 { 02574 register const float 02575 *restrict p; 02576 02577 register Quantum 02578 *restrict q; 02579 02580 register ssize_t 02581 x; 02582 02583 ssize_t 02584 y; 02585 02586 p=(const float *) pixels; 02587 if (LocaleCompare(map,"BGR") == 0) 02588 { 02589 for (y=0; y < (ssize_t) roi->height; y++) 02590 { 02591 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02592 if (q == (Quantum *) NULL) 02593 break; 02594 for (x=0; x < (ssize_t) roi->width; x++) 02595 { 02596 SetPixelBlue(image,ClampToQuantum((MagickRealType) QuantumRange* 02597 (*p)),q); 02598 p++; 02599 SetPixelGreen(image,ClampToQuantum((MagickRealType) QuantumRange* 02600 (*p)),q); 02601 p++; 02602 SetPixelRed(image,ClampToQuantum((MagickRealType) QuantumRange* 02603 (*p)),q); 02604 p++; 02605 q+=GetPixelChannels(image); 02606 } 02607 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02608 break; 02609 } 02610 return; 02611 } 02612 if (LocaleCompare(map,"BGRA") == 0) 02613 { 02614 for (y=0; y < (ssize_t) roi->height; y++) 02615 { 02616 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02617 if (q == (Quantum *) NULL) 02618 break; 02619 for (x=0; x < (ssize_t) roi->width; x++) 02620 { 02621 SetPixelBlue(image,ClampToQuantum((MagickRealType) QuantumRange* 02622 (*p)),q); 02623 p++; 02624 SetPixelGreen(image,ClampToQuantum((MagickRealType) QuantumRange* 02625 (*p)),q); 02626 p++; 02627 SetPixelRed(image,ClampToQuantum((MagickRealType) QuantumRange* 02628 (*p)),q); 02629 p++; 02630 SetPixelAlpha(image,ClampToQuantum((MagickRealType) QuantumRange* 02631 (*p)),q); 02632 p++; 02633 q+=GetPixelChannels(image); 02634 } 02635 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02636 break; 02637 } 02638 return; 02639 } 02640 if (LocaleCompare(map,"BGRP") == 0) 02641 { 02642 for (y=0; y < (ssize_t) roi->height; y++) 02643 { 02644 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02645 if (q == (Quantum *) NULL) 02646 break; 02647 for (x=0; x < (ssize_t) roi->width; x++) 02648 { 02649 SetPixelBlue(image,ClampToQuantum((MagickRealType) QuantumRange* 02650 (*p)),q); 02651 p++; 02652 SetPixelGreen(image,ClampToQuantum((MagickRealType) QuantumRange* 02653 (*p)),q); 02654 p++; 02655 SetPixelRed(image,ClampToQuantum((MagickRealType) QuantumRange* 02656 (*p)),q); 02657 p++; 02658 p++; 02659 q+=GetPixelChannels(image); 02660 } 02661 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02662 break; 02663 } 02664 return; 02665 } 02666 if (LocaleCompare(map,"I") == 0) 02667 { 02668 for (y=0; y < (ssize_t) roi->height; y++) 02669 { 02670 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02671 if (q == (Quantum *) NULL) 02672 break; 02673 for (x=0; x < (ssize_t) roi->width; x++) 02674 { 02675 SetPixelGray(image,ClampToQuantum((MagickRealType) QuantumRange* 02676 (*p)),q); 02677 p++; 02678 q+=GetPixelChannels(image); 02679 } 02680 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02681 break; 02682 } 02683 return; 02684 } 02685 if (LocaleCompare(map,"RGB") == 0) 02686 { 02687 for (y=0; y < (ssize_t) roi->height; y++) 02688 { 02689 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02690 if (q == (Quantum *) NULL) 02691 break; 02692 for (x=0; x < (ssize_t) roi->width; x++) 02693 { 02694 SetPixelRed(image,ClampToQuantum((MagickRealType) QuantumRange* 02695 (*p)),q); 02696 p++; 02697 SetPixelGreen(image,ClampToQuantum((MagickRealType) QuantumRange* 02698 (*p)),q); 02699 p++; 02700 SetPixelBlue(image,ClampToQuantum((MagickRealType) QuantumRange* 02701 (*p)),q); 02702 p++; 02703 q+=GetPixelChannels(image); 02704 } 02705 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02706 break; 02707 } 02708 return; 02709 } 02710 if (LocaleCompare(map,"RGBA") == 0) 02711 { 02712 for (y=0; y < (ssize_t) roi->height; y++) 02713 { 02714 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02715 if (q == (Quantum *) NULL) 02716 break; 02717 for (x=0; x < (ssize_t) roi->width; x++) 02718 { 02719 SetPixelRed(image,ClampToQuantum((MagickRealType) 02720 QuantumRange*(*p)),q); 02721 p++; 02722 SetPixelGreen(image,ClampToQuantum((MagickRealType) QuantumRange* 02723 (*p)),q); 02724 p++; 02725 SetPixelBlue(image,ClampToQuantum((MagickRealType) QuantumRange* 02726 (*p)),q); 02727 p++; 02728 SetPixelAlpha(image,ClampToQuantum((MagickRealType) QuantumRange* 02729 (*p)),q); 02730 p++; 02731 q+=GetPixelChannels(image); 02732 } 02733 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02734 break; 02735 } 02736 return; 02737 } 02738 if (LocaleCompare(map,"RGBP") == 0) 02739 { 02740 for (y=0; y < (ssize_t) roi->height; y++) 02741 { 02742 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02743 if (q == (Quantum *) NULL) 02744 break; 02745 for (x=0; x < (ssize_t) roi->width; x++) 02746 { 02747 SetPixelRed(image,ClampToQuantum((MagickRealType) QuantumRange* 02748 (*p)),q); 02749 p++; 02750 SetPixelGreen(image,ClampToQuantum((MagickRealType) QuantumRange* 02751 (*p)),q); 02752 p++; 02753 SetPixelBlue(image,ClampToQuantum((MagickRealType) QuantumRange* 02754 (*p)),q); 02755 p++; 02756 q+=GetPixelChannels(image); 02757 } 02758 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02759 break; 02760 } 02761 return; 02762 } 02763 for (y=0; y < (ssize_t) roi->height; y++) 02764 { 02765 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02766 if (q == (Quantum *) NULL) 02767 break; 02768 for (x=0; x < (ssize_t) roi->width; x++) 02769 { 02770 register ssize_t 02771 i; 02772 02773 for (i=0; i < (ssize_t) strlen(map); i++) 02774 { 02775 switch (quantum_map[i]) 02776 { 02777 case RedQuantum: 02778 case CyanQuantum: 02779 { 02780 SetPixelRed(image,ClampToQuantum((MagickRealType) 02781 QuantumRange*(*p)),q); 02782 break; 02783 } 02784 case GreenQuantum: 02785 case MagentaQuantum: 02786 { 02787 SetPixelGreen(image,ClampToQuantum((MagickRealType) 02788 QuantumRange*(*p)),q); 02789 break; 02790 } 02791 case BlueQuantum: 02792 case YellowQuantum: 02793 { 02794 SetPixelBlue(image,ClampToQuantum((MagickRealType) 02795 QuantumRange*(*p)),q); 02796 break; 02797 } 02798 case AlphaQuantum: 02799 { 02800 SetPixelAlpha(image,ClampToQuantum((MagickRealType) 02801 QuantumRange*(*p)),q); 02802 break; 02803 } 02804 case OpacityQuantum: 02805 { 02806 SetPixelAlpha(image,ClampToQuantum((MagickRealType) 02807 QuantumRange*(*p)),q); 02808 break; 02809 } 02810 case BlackQuantum: 02811 { 02812 SetPixelBlack(image,ClampToQuantum((MagickRealType) 02813 QuantumRange*(*p)),q); 02814 break; 02815 } 02816 case IndexQuantum: 02817 { 02818 SetPixelGray(image,ClampToQuantum((MagickRealType) 02819 QuantumRange*(*p)),q); 02820 break; 02821 } 02822 default: 02823 break; 02824 } 02825 p++; 02826 } 02827 q+=GetPixelChannels(image); 02828 } 02829 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02830 break; 02831 } 02832 } 02833 02834 static void ImportLongPixel(Image *image,const RectangleInfo *roi, 02835 const char *restrict map,const QuantumType *quantum_map,const void *pixels, 02836 ExceptionInfo *exception) 02837 { 02838 register const unsigned int 02839 *restrict p; 02840 02841 register Quantum 02842 *restrict q; 02843 02844 register ssize_t 02845 x; 02846 02847 ssize_t 02848 y; 02849 02850 p=(const unsigned int *) pixels; 02851 if (LocaleCompare(map,"BGR") == 0) 02852 { 02853 for (y=0; y < (ssize_t) roi->height; y++) 02854 { 02855 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02856 if (q == (Quantum *) NULL) 02857 break; 02858 for (x=0; x < (ssize_t) roi->width; x++) 02859 { 02860 SetPixelBlue(image,ScaleLongToQuantum(*p++),q); 02861 SetPixelGreen(image,ScaleLongToQuantum(*p++),q); 02862 SetPixelRed(image,ScaleLongToQuantum(*p++),q); 02863 q+=GetPixelChannels(image); 02864 } 02865 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02866 break; 02867 } 02868 return; 02869 } 02870 if (LocaleCompare(map,"BGRA") == 0) 02871 { 02872 for (y=0; y < (ssize_t) roi->height; y++) 02873 { 02874 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02875 if (q == (Quantum *) NULL) 02876 break; 02877 for (x=0; x < (ssize_t) roi->width; x++) 02878 { 02879 SetPixelBlue(image,ScaleLongToQuantum(*p++),q); 02880 SetPixelGreen(image,ScaleLongToQuantum(*p++),q); 02881 SetPixelRed(image,ScaleLongToQuantum(*p++),q); 02882 SetPixelAlpha(image,ScaleLongToQuantum(*p++),q); 02883 q+=GetPixelChannels(image); 02884 } 02885 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02886 break; 02887 } 02888 return; 02889 } 02890 if (LocaleCompare(map,"BGRP") == 0) 02891 { 02892 for (y=0; y < (ssize_t) roi->height; y++) 02893 { 02894 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02895 if (q == (Quantum *) NULL) 02896 break; 02897 for (x=0; x < (ssize_t) roi->width; x++) 02898 { 02899 SetPixelBlue(image,ScaleLongToQuantum(*p++),q); 02900 SetPixelGreen(image,ScaleLongToQuantum(*p++),q); 02901 SetPixelRed(image,ScaleLongToQuantum(*p++),q); 02902 p++; 02903 q+=GetPixelChannels(image); 02904 } 02905 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02906 break; 02907 } 02908 return; 02909 } 02910 if (LocaleCompare(map,"I") == 0) 02911 { 02912 for (y=0; y < (ssize_t) roi->height; y++) 02913 { 02914 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02915 if (q == (Quantum *) NULL) 02916 break; 02917 for (x=0; x < (ssize_t) roi->width; x++) 02918 { 02919 SetPixelGray(image,ScaleLongToQuantum(*p++),q); 02920 q+=GetPixelChannels(image); 02921 } 02922 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02923 break; 02924 } 02925 return; 02926 } 02927 if (LocaleCompare(map,"RGB") == 0) 02928 { 02929 for (y=0; y < (ssize_t) roi->height; y++) 02930 { 02931 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02932 if (q == (Quantum *) NULL) 02933 break; 02934 for (x=0; x < (ssize_t) roi->width; x++) 02935 { 02936 SetPixelRed(image,ScaleLongToQuantum(*p++),q); 02937 SetPixelGreen(image,ScaleLongToQuantum(*p++),q); 02938 SetPixelBlue(image,ScaleLongToQuantum(*p++),q); 02939 q+=GetPixelChannels(image); 02940 } 02941 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02942 break; 02943 } 02944 return; 02945 } 02946 if (LocaleCompare(map,"RGBA") == 0) 02947 { 02948 for (y=0; y < (ssize_t) roi->height; y++) 02949 { 02950 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02951 if (q == (Quantum *) NULL) 02952 break; 02953 for (x=0; x < (ssize_t) roi->width; x++) 02954 { 02955 SetPixelRed(image,ScaleLongToQuantum(*p++),q); 02956 SetPixelGreen(image,ScaleLongToQuantum(*p++),q); 02957 SetPixelBlue(image,ScaleLongToQuantum(*p++),q); 02958 SetPixelAlpha(image,ScaleLongToQuantum(*p++),q); 02959 q+=GetPixelChannels(image); 02960 } 02961 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02962 break; 02963 } 02964 return; 02965 } 02966 if (LocaleCompare(map,"RGBP") == 0) 02967 { 02968 for (y=0; y < (ssize_t) roi->height; y++) 02969 { 02970 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02971 if (q == (Quantum *) NULL) 02972 break; 02973 for (x=0; x < (ssize_t) roi->width; x++) 02974 { 02975 SetPixelRed(image,ScaleLongToQuantum(*p++),q); 02976 SetPixelGreen(image,ScaleLongToQuantum(*p++),q); 02977 SetPixelBlue(image,ScaleLongToQuantum(*p++),q); 02978 p++; 02979 q+=GetPixelChannels(image); 02980 } 02981 if (SyncAuthenticPixels(image,exception) == MagickFalse) 02982 break; 02983 } 02984 return; 02985 } 02986 for (y=0; y < (ssize_t) roi->height; y++) 02987 { 02988 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 02989 if (q == (Quantum *) NULL) 02990 break; 02991 for (x=0; x < (ssize_t) roi->width; x++) 02992 { 02993 register ssize_t 02994 i; 02995 02996 for (i=0; i < (ssize_t) strlen(map); i++) 02997 { 02998 switch (quantum_map[i]) 02999 { 03000 case RedQuantum: 03001 case CyanQuantum: 03002 { 03003 SetPixelRed(image,ScaleLongToQuantum(*p),q); 03004 break; 03005 } 03006 case GreenQuantum: 03007 case MagentaQuantum: 03008 { 03009 SetPixelGreen(image,ScaleLongToQuantum(*p),q); 03010 break; 03011 } 03012 case BlueQuantum: 03013 case YellowQuantum: 03014 { 03015 SetPixelBlue(image,ScaleLongToQuantum(*p),q); 03016 break; 03017 } 03018 case AlphaQuantum: 03019 { 03020 SetPixelAlpha(image,ScaleLongToQuantum(*p),q); 03021 break; 03022 } 03023 case OpacityQuantum: 03024 { 03025 SetPixelAlpha(image,ScaleLongToQuantum(*p),q); 03026 break; 03027 } 03028 case BlackQuantum: 03029 { 03030 SetPixelBlack(image,ScaleLongToQuantum(*p),q); 03031 break; 03032 } 03033 case IndexQuantum: 03034 { 03035 SetPixelGray(image,ScaleLongToQuantum(*p),q); 03036 break; 03037 } 03038 default: 03039 break; 03040 } 03041 p++; 03042 } 03043 q+=GetPixelChannels(image); 03044 } 03045 if (SyncAuthenticPixels(image,exception) == MagickFalse) 03046 break; 03047 } 03048 } 03049 03050 static void ImportLongLongPixel(Image *image,const RectangleInfo *roi, 03051 const char *restrict map,const QuantumType *quantum_map,const void *pixels, 03052 ExceptionInfo *exception) 03053 { 03054 register const MagickSizeType 03055 *restrict p; 03056 03057 register Quantum 03058 *restrict q; 03059 03060 register ssize_t 03061 x; 03062 03063 ssize_t 03064 y; 03065 03066 p=(const MagickSizeType *) pixels; 03067 if (LocaleCompare(map,"BGR") == 0) 03068 { 03069 for (y=0; y < (ssize_t) roi->height; y++) 03070 { 03071 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 03072 if (q == (Quantum *) NULL) 03073 break; 03074 for (x=0; x < (ssize_t) roi->width; x++) 03075 { 03076 SetPixelBlue(image,ScaleLongLongToQuantum(*p++),q); 03077 SetPixelGreen(image,ScaleLongLongToQuantum(*p++),q); 03078 SetPixelRed(image,ScaleLongLongToQuantum(*p++),q); 03079 q+=GetPixelChannels(image); 03080 } 03081 if (SyncAuthenticPixels(image,exception) == MagickFalse) 03082 break; 03083 } 03084 return; 03085 } 03086 if (LocaleCompare(map,"BGRA") == 0) 03087 { 03088 for (y=0; y < (ssize_t) roi->height; y++) 03089 { 03090 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 03091 if (q == (Quantum *) NULL) 03092 break; 03093 for (x=0; x < (ssize_t) roi->width; x++) 03094 { 03095 SetPixelBlue(image,ScaleLongLongToQuantum(*p++),q); 03096 SetPixelGreen(image,ScaleLongLongToQuantum(*p++),q); 03097 SetPixelRed(image,ScaleLongLongToQuantum(*p++),q); 03098 SetPixelAlpha(image,ScaleLongLongToQuantum(*p++),q); 03099 q+=GetPixelChannels(image); 03100 } 03101 if (SyncAuthenticPixels(image,exception) == MagickFalse) 03102 break; 03103 } 03104 return; 03105 } 03106 if (LocaleCompare(map,"BGRP") == 0) 03107 { 03108 for (y=0; y < (ssize_t) roi->height; y++) 03109 { 03110 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 03111 if (q == (Quantum *) NULL) 03112 break; 03113 for (x=0; x < (ssize_t) roi->width; x++) 03114 { 03115 SetPixelBlue(image,ScaleLongLongToQuantum(*p++),q); 03116 SetPixelGreen(image,ScaleLongLongToQuantum(*p++),q); 03117 SetPixelRed(image,ScaleLongLongToQuantum(*p++),q); 03118 p++; 03119 q+=GetPixelChannels(image); 03120 } 03121 if (SyncAuthenticPixels(image,exception) == MagickFalse) 03122 break; 03123 } 03124 return; 03125 } 03126 if (LocaleCompare(map,"I") == 0) 03127 { 03128 for (y=0; y < (ssize_t) roi->height; y++) 03129 { 03130 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 03131 if (q == (Quantum *) NULL) 03132 break; 03133 for (x=0; x < (ssize_t) roi->width; x++) 03134 { 03135 SetPixelGray(image,ScaleLongLongToQuantum(*p++),q); 03136 q+=GetPixelChannels(image); 03137 } 03138 if (SyncAuthenticPixels(image,exception) == MagickFalse) 03139 break; 03140 } 03141 return; 03142 } 03143 if (LocaleCompare(map,"RGB") == 0) 03144 { 03145 for (y=0; y < (ssize_t) roi->height; y++) 03146 { 03147 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 03148 if (q == (Quantum *) NULL) 03149 break; 03150 for (x=0; x < (ssize_t) roi->width; x++) 03151 { 03152 SetPixelRed(image,ScaleLongLongToQuantum(*p++),q); 03153 SetPixelGreen(image,ScaleLongLongToQuantum(*p++),q); 03154 SetPixelBlue(image,ScaleLongLongToQuantum(*p++),q); 03155 q+=GetPixelChannels(image); 03156 } 03157 if (SyncAuthenticPixels(image,exception) == MagickFalse) 03158 break; 03159 } 03160 return; 03161 } 03162 if (LocaleCompare(map,"RGBA") == 0) 03163 { 03164 for (y=0; y < (ssize_t) roi->height; y++) 03165 { 03166 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 03167 if (q == (Quantum *) NULL) 03168 break; 03169 for (x=0; x < (ssize_t) roi->width; x++) 03170 { 03171 SetPixelRed(image,ScaleLongLongToQuantum(*p++),q); 03172 SetPixelGreen(image,ScaleLongLongToQuantum(*p++),q); 03173 SetPixelBlue(image,ScaleLongLongToQuantum(*p++),q); 03174 SetPixelAlpha(image,ScaleLongLongToQuantum(*p++),q); 03175 q+=GetPixelChannels(image); 03176 } 03177 if (SyncAuthenticPixels(image,exception) == MagickFalse) 03178 break; 03179 } 03180 return; 03181 } 03182 if (LocaleCompare(map,"RGBP") == 0) 03183 { 03184 for (y=0; y < (ssize_t) roi->height; y++) 03185 { 03186 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 03187 if (q == (Quantum *) NULL) 03188 break; 03189 for (x=0; x < (ssize_t) roi->width; x++) 03190 { 03191 SetPixelRed(image,ScaleLongLongToQuantum(*p++),q); 03192 SetPixelGreen(image,ScaleLongLongToQuantum(*p++),q); 03193 SetPixelBlue(image,ScaleLongLongToQuantum(*p++),q); 03194 p++; 03195 q+=GetPixelChannels(image); 03196 } 03197 if (SyncAuthenticPixels(image,exception) == MagickFalse) 03198 break; 03199 } 03200 return; 03201 } 03202 for (y=0; y < (ssize_t) roi->height; y++) 03203 { 03204 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 03205 if (q == (Quantum *) NULL) 03206 break; 03207 for (x=0; x < (ssize_t) roi->width; x++) 03208 { 03209 register ssize_t 03210 i; 03211 03212 for (i=0; i < (ssize_t) strlen(map); i++) 03213 { 03214 switch (quantum_map[i]) 03215 { 03216 case RedQuantum: 03217 case CyanQuantum: 03218 { 03219 SetPixelRed(image,ScaleLongLongToQuantum(*p),q); 03220 break; 03221 } 03222 case GreenQuantum: 03223 case MagentaQuantum: 03224 { 03225 SetPixelGreen(image,ScaleLongLongToQuantum(*p),q); 03226 break; 03227 } 03228 case BlueQuantum: 03229 case YellowQuantum: 03230 { 03231 SetPixelBlue(image,ScaleLongLongToQuantum(*p),q); 03232 break; 03233 } 03234 case AlphaQuantum: 03235 { 03236 SetPixelAlpha(image,ScaleLongLongToQuantum(*p),q); 03237 break; 03238 } 03239 case OpacityQuantum: 03240 { 03241 SetPixelAlpha(image,ScaleLongLongToQuantum(*p),q); 03242 break; 03243 } 03244 case BlackQuantum: 03245 { 03246 SetPixelBlack(image,ScaleLongLongToQuantum(*p),q); 03247 break; 03248 } 03249 case IndexQuantum: 03250 { 03251 SetPixelGray(image,ScaleLongLongToQuantum(*p),q); 03252 break; 03253 } 03254 default: 03255 break; 03256 } 03257 p++; 03258 } 03259 q+=GetPixelChannels(image); 03260 } 03261 if (SyncAuthenticPixels(image,exception) == MagickFalse) 03262 break; 03263 } 03264 } 03265 03266 static void ImportQuantumPixel(Image *image,const RectangleInfo *roi, 03267 const char *restrict map,const QuantumType *quantum_map,const void *pixels, 03268 ExceptionInfo *exception) 03269 { 03270 register const Quantum 03271 *restrict p; 03272 03273 register Quantum 03274 *restrict q; 03275 03276 register ssize_t 03277 x; 03278 03279 ssize_t 03280 y; 03281 03282 p=(const Quantum *) pixels; 03283 if (LocaleCompare(map,"BGR") == 0) 03284 { 03285 for (y=0; y < (ssize_t) roi->height; y++) 03286 { 03287 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 03288 if (q == (Quantum *) NULL) 03289 break; 03290 for (x=0; x < (ssize_t) roi->width; x++) 03291 { 03292 SetPixelBlue(image,*p++,q); 03293 SetPixelGreen(image,*p++,q); 03294 SetPixelRed(image,*p++,q); 03295 q+=GetPixelChannels(image); 03296 } 03297 if (SyncAuthenticPixels(image,exception) == MagickFalse) 03298 break; 03299 } 03300 return; 03301 } 03302 if (LocaleCompare(map,"BGRA") == 0) 03303 { 03304 for (y=0; y < (ssize_t) roi->height; y++) 03305 { 03306 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 03307 if (q == (Quantum *) NULL) 03308 break; 03309 for (x=0; x < (ssize_t) roi->width; x++) 03310 { 03311 SetPixelBlue(image,*p++,q); 03312 SetPixelGreen(image,*p++,q); 03313 SetPixelRed(image,*p++,q); 03314 SetPixelAlpha(image,*p++,q); 03315 q+=GetPixelChannels(image); 03316 } 03317 if (SyncAuthenticPixels(image,exception) == MagickFalse) 03318 break; 03319 } 03320 return; 03321 } 03322 if (LocaleCompare(map,"BGRP") == 0) 03323 { 03324 for (y=0; y < (ssize_t) roi->height; y++) 03325 { 03326 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 03327 if (q == (Quantum *) NULL) 03328 break; 03329 for (x=0; x < (ssize_t) roi->width; x++) 03330 { 03331 SetPixelBlue(image,*p++,q); 03332 SetPixelGreen(image,*p++,q); 03333 SetPixelRed(image,*p++,q); 03334 p++; 03335 q+=GetPixelChannels(image); 03336 } 03337 if (SyncAuthenticPixels(image,exception) == MagickFalse) 03338 break; 03339 } 03340 return; 03341 } 03342 if (LocaleCompare(map,"I") == 0) 03343 { 03344 for (y=0; y < (ssize_t) roi->height; y++) 03345 { 03346 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 03347 if (q == (Quantum *) NULL) 03348 break; 03349 for (x=0; x < (ssize_t) roi->width; x++) 03350 { 03351 SetPixelGray(image,*p++,q); 03352 q+=GetPixelChannels(image); 03353 } 03354 if (SyncAuthenticPixels(image,exception) == MagickFalse) 03355 break; 03356 } 03357 return; 03358 } 03359 if (LocaleCompare(map,"RGB") == 0) 03360 { 03361 for (y=0; y < (ssize_t) roi->height; y++) 03362 { 03363 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 03364 if (q == (Quantum *) NULL) 03365 break; 03366 for (x=0; x < (ssize_t) roi->width; x++) 03367 { 03368 SetPixelRed(image,*p++,q); 03369 SetPixelGreen(image,*p++,q); 03370 SetPixelBlue(image,*p++,q); 03371 q+=GetPixelChannels(image); 03372 } 03373 if (SyncAuthenticPixels(image,exception) == MagickFalse) 03374 break; 03375 } 03376 return; 03377 } 03378 if (LocaleCompare(map,"RGBA") == 0) 03379 { 03380 for (y=0; y < (ssize_t) roi->height; y++) 03381 { 03382 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 03383 if (q == (Quantum *) NULL) 03384 break; 03385 for (x=0; x < (ssize_t) roi->width; x++) 03386 { 03387 SetPixelRed(image,*p++,q); 03388 SetPixelGreen(image,*p++,q); 03389 SetPixelBlue(image,*p++,q); 03390 SetPixelAlpha(image,*p++,q); 03391 q+=GetPixelChannels(image); 03392 } 03393 if (SyncAuthenticPixels(image,exception) == MagickFalse) 03394 break; 03395 } 03396 return; 03397 } 03398 if (LocaleCompare(map,"RGBP") == 0) 03399 { 03400 for (y=0; y < (ssize_t) roi->height; y++) 03401 { 03402 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 03403 if (q == (Quantum *) NULL) 03404 break; 03405 for (x=0; x < (ssize_t) roi->width; x++) 03406 { 03407 SetPixelRed(image,*p++,q); 03408 SetPixelGreen(image,*p++,q); 03409 SetPixelBlue(image,*p++,q); 03410 p++; 03411 q+=GetPixelChannels(image); 03412 } 03413 if (SyncAuthenticPixels(image,exception) == MagickFalse) 03414 break; 03415 } 03416 return; 03417 } 03418 for (y=0; y < (ssize_t) roi->height; y++) 03419 { 03420 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 03421 if (q == (Quantum *) NULL) 03422 break; 03423 for (x=0; x < (ssize_t) roi->width; x++) 03424 { 03425 register ssize_t 03426 i; 03427 03428 for (i=0; i < (ssize_t) strlen(map); i++) 03429 { 03430 switch (quantum_map[i]) 03431 { 03432 case RedQuantum: 03433 case CyanQuantum: 03434 { 03435 SetPixelRed(image,*p,q); 03436 break; 03437 } 03438 case GreenQuantum: 03439 case MagentaQuantum: 03440 { 03441 SetPixelGreen(image,*p,q); 03442 break; 03443 } 03444 case BlueQuantum: 03445 case YellowQuantum: 03446 { 03447 SetPixelBlue(image,*p,q); 03448 break; 03449 } 03450 case AlphaQuantum: 03451 { 03452 SetPixelAlpha(image,*p,q); 03453 break; 03454 } 03455 case OpacityQuantum: 03456 { 03457 SetPixelAlpha(image,*p,q); 03458 break; 03459 } 03460 case BlackQuantum: 03461 { 03462 SetPixelBlack(image,*p,q); 03463 break; 03464 } 03465 case IndexQuantum: 03466 { 03467 SetPixelGray(image,*p,q); 03468 break; 03469 } 03470 default: 03471 break; 03472 } 03473 p++; 03474 } 03475 q+=GetPixelChannels(image); 03476 } 03477 if (SyncAuthenticPixels(image,exception) == MagickFalse) 03478 break; 03479 } 03480 } 03481 03482 static void ImportShortPixel(Image *image,const RectangleInfo *roi, 03483 const char *restrict map,const QuantumType *quantum_map,const void *pixels, 03484 ExceptionInfo *exception) 03485 { 03486 register const unsigned short 03487 *restrict p; 03488 03489 register Quantum 03490 *restrict q; 03491 03492 register ssize_t 03493 x; 03494 03495 ssize_t 03496 y; 03497 03498 p=(const unsigned short *) pixels; 03499 if (LocaleCompare(map,"BGR") == 0) 03500 { 03501 for (y=0; y < (ssize_t) roi->height; y++) 03502 { 03503 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 03504 if (q == (Quantum *) NULL) 03505 break; 03506 for (x=0; x < (ssize_t) roi->width; x++) 03507 { 03508 SetPixelBlue(image,ScaleShortToQuantum(*p++),q); 03509 SetPixelGreen(image,ScaleShortToQuantum(*p++),q); 03510 SetPixelRed(image,ScaleShortToQuantum(*p++),q); 03511 q+=GetPixelChannels(image); 03512 } 03513 if (SyncAuthenticPixels(image,exception) == MagickFalse) 03514 break; 03515 } 03516 return; 03517 } 03518 if (LocaleCompare(map,"BGRA") == 0) 03519 { 03520 for (y=0; y < (ssize_t) roi->height; y++) 03521 { 03522 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 03523 if (q == (Quantum *) NULL) 03524 break; 03525 for (x=0; x < (ssize_t) roi->width; x++) 03526 { 03527 SetPixelBlue(image,ScaleShortToQuantum(*p++),q); 03528 SetPixelGreen(image,ScaleShortToQuantum(*p++),q); 03529 SetPixelRed(image,ScaleShortToQuantum(*p++),q); 03530 SetPixelAlpha(image,ScaleShortToQuantum(*p++),q); 03531 q+=GetPixelChannels(image); 03532 } 03533 if (SyncAuthenticPixels(image,exception) == MagickFalse) 03534 break; 03535 } 03536 return; 03537 } 03538 if (LocaleCompare(map,"BGRP") == 0) 03539 { 03540 for (y=0; y < (ssize_t) roi->height; y++) 03541 { 03542 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 03543 if (q == (Quantum *) NULL) 03544 break; 03545 for (x=0; x < (ssize_t) roi->width; x++) 03546 { 03547 SetPixelBlue(image,ScaleShortToQuantum(*p++),q); 03548 SetPixelGreen(image,ScaleShortToQuantum(*p++),q); 03549 SetPixelRed(image,ScaleShortToQuantum(*p++),q); 03550 p++; 03551 q+=GetPixelChannels(image); 03552 } 03553 if (SyncAuthenticPixels(image,exception) == MagickFalse) 03554 break; 03555 } 03556 return; 03557 } 03558 if (LocaleCompare(map,"I") == 0) 03559 { 03560 for (y=0; y < (ssize_t) roi->height; y++) 03561 { 03562 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 03563 if (q == (Quantum *) NULL) 03564 break; 03565 for (x=0; x < (ssize_t) roi->width; x++) 03566 { 03567 SetPixelGray(image,ScaleShortToQuantum(*p++),q); 03568 q+=GetPixelChannels(image); 03569 } 03570 if (SyncAuthenticPixels(image,exception) == MagickFalse) 03571 break; 03572 } 03573 return; 03574 } 03575 if (LocaleCompare(map,"RGB") == 0) 03576 { 03577 for (y=0; y < (ssize_t) roi->height; y++) 03578 { 03579 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 03580 if (q == (Quantum *) NULL) 03581 break; 03582 for (x=0; x < (ssize_t) roi->width; x++) 03583 { 03584 SetPixelRed(image,ScaleShortToQuantum(*p++),q); 03585 SetPixelGreen(image,ScaleShortToQuantum(*p++),q); 03586 SetPixelBlue(image,ScaleShortToQuantum(*p++),q); 03587 q+=GetPixelChannels(image); 03588 } 03589 if (SyncAuthenticPixels(image,exception) == MagickFalse) 03590 break; 03591 } 03592 return; 03593 } 03594 if (LocaleCompare(map,"RGBA") == 0) 03595 { 03596 for (y=0; y < (ssize_t) roi->height; y++) 03597 { 03598 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 03599 if (q == (Quantum *) NULL) 03600 break; 03601 for (x=0; x < (ssize_t) roi->width; x++) 03602 { 03603 SetPixelRed(image,ScaleShortToQuantum(*p++),q); 03604 SetPixelGreen(image,ScaleShortToQuantum(*p++),q); 03605 SetPixelBlue(image,ScaleShortToQuantum(*p++),q); 03606 SetPixelAlpha(image,ScaleShortToQuantum(*p++),q); 03607 q+=GetPixelChannels(image); 03608 } 03609 if (SyncAuthenticPixels(image,exception) == MagickFalse) 03610 break; 03611 } 03612 return; 03613 } 03614 if (LocaleCompare(map,"RGBP") == 0) 03615 { 03616 for (y=0; y < (ssize_t) roi->height; y++) 03617 { 03618 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 03619 if (q == (Quantum *) NULL) 03620 break; 03621 for (x=0; x < (ssize_t) roi->width; x++) 03622 { 03623 SetPixelRed(image,ScaleShortToQuantum(*p++),q); 03624 SetPixelGreen(image,ScaleShortToQuantum(*p++),q); 03625 SetPixelBlue(image,ScaleShortToQuantum(*p++),q); 03626 p++; 03627 q+=GetPixelChannels(image); 03628 } 03629 if (SyncAuthenticPixels(image,exception) == MagickFalse) 03630 break; 03631 } 03632 return; 03633 } 03634 for (y=0; y < (ssize_t) roi->height; y++) 03635 { 03636 q=GetAuthenticPixels(image,roi->x,roi->y+y,roi->width,1,exception); 03637 if (q == (Quantum *) NULL) 03638 break; 03639 for (x=0; x < (ssize_t) roi->width; x++) 03640 { 03641 register ssize_t 03642 i; 03643 03644 for (i=0; i < (ssize_t) strlen(map); i++) 03645 { 03646 switch (quantum_map[i]) 03647 { 03648 case RedQuantum: 03649 case CyanQuantum: 03650 { 03651 SetPixelRed(image,ScaleShortToQuantum(*p),q); 03652 break; 03653 } 03654 case GreenQuantum: 03655 case MagentaQuantum: 03656 { 03657 SetPixelGreen(image,ScaleShortToQuantum(*p),q); 03658 break; 03659 } 03660 case BlueQuantum: 03661 case YellowQuantum: 03662 { 03663 SetPixelBlue(image,ScaleShortToQuantum(*p),q); 03664 break; 03665 } 03666 case AlphaQuantum: 03667 { 03668 SetPixelAlpha(image,ScaleShortToQuantum(*p),q); 03669 break; 03670 } 03671 case OpacityQuantum: 03672 { 03673 SetPixelAlpha(image,ScaleShortToQuantum(*p),q); 03674 break; 03675 } 03676 case BlackQuantum: 03677 { 03678 SetPixelBlack(image,ScaleShortToQuantum(*p),q); 03679 break; 03680 } 03681 case IndexQuantum: 03682 { 03683 SetPixelGray(image,ScaleShortToQuantum(*p),q); 03684 break; 03685 } 03686 default: 03687 break; 03688 } 03689 p++; 03690 } 03691 q+=GetPixelChannels(image); 03692 } 03693 if (SyncAuthenticPixels(image,exception) == MagickFalse) 03694 break; 03695 } 03696 } 03697 03698 MagickExport MagickBooleanType ImportImagePixels(Image *image,const ssize_t x, 03699 const ssize_t y,const size_t width,const size_t height,const char *map, 03700 const StorageType type,const void *pixels,ExceptionInfo *exception) 03701 { 03702 QuantumType 03703 *quantum_map; 03704 03705 RectangleInfo 03706 roi; 03707 03708 register ssize_t 03709 i; 03710 03711 /* 03712 Allocate image structure. 03713 */ 03714 assert(image != (Image *) NULL); 03715 assert(image->signature == MagickSignature); 03716 if (image->debug != MagickFalse) 03717 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); 03718 quantum_map=(QuantumType *) AcquireQuantumMemory(strlen(map), 03719 sizeof(*quantum_map)); 03720 if (quantum_map == (QuantumType *) NULL) 03721 ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", 03722 image->filename); 03723 for (i=0; i < (ssize_t) strlen(map); i++) 03724 { 03725 switch (map[i]) 03726 { 03727 case 'a': 03728 case 'A': 03729 { 03730 quantum_map[i]=AlphaQuantum; 03731 image->matte=MagickTrue; 03732 break; 03733 } 03734 case 'B': 03735 case 'b': 03736 { 03737 quantum_map[i]=BlueQuantum; 03738 break; 03739 } 03740 case 'C': 03741 case 'c': 03742 { 03743 quantum_map[i]=CyanQuantum; 03744 (void) SetImageColorspace(image,CMYKColorspace,exception); 03745 break; 03746 } 03747 case 'g': 03748 case 'G': 03749 { 03750 quantum_map[i]=GreenQuantum; 03751 break; 03752 } 03753 case 'K': 03754 case 'k': 03755 { 03756 quantum_map[i]=BlackQuantum; 03757 (void) SetImageColorspace(image,CMYKColorspace,exception); 03758 break; 03759 } 03760 case 'I': 03761 case 'i': 03762 { 03763 quantum_map[i]=IndexQuantum; 03764 break; 03765 } 03766 case 'm': 03767 case 'M': 03768 { 03769 quantum_map[i]=MagentaQuantum; 03770 (void) SetImageColorspace(image,CMYKColorspace,exception); 03771 break; 03772 } 03773 case 'O': 03774 case 'o': 03775 { 03776 quantum_map[i]=OpacityQuantum; 03777 image->matte=MagickTrue; 03778 break; 03779 } 03780 case 'P': 03781 case 'p': 03782 { 03783 quantum_map[i]=UndefinedQuantum; 03784 break; 03785 } 03786 case 'R': 03787 case 'r': 03788 { 03789 quantum_map[i]=RedQuantum; 03790 break; 03791 } 03792 case 'Y': 03793 case 'y': 03794 { 03795 quantum_map[i]=YellowQuantum; 03796 (void) SetImageColorspace(image,CMYKColorspace,exception); 03797 break; 03798 } 03799 default: 03800 { 03801 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); 03802 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, 03803 "UnrecognizedPixelMap","`%s'",map); 03804 return(MagickFalse); 03805 } 03806 } 03807 } 03808 if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse) 03809 return(MagickFalse); 03810 /* 03811 Transfer the pixels from the pixel data to the image. 03812 */ 03813 roi.width=width; 03814 roi.height=height; 03815 roi.x=x; 03816 roi.y=y; 03817 switch (type) 03818 { 03819 case CharPixel: 03820 { 03821 ImportCharPixel(image,&roi,map,quantum_map,pixels,exception); 03822 break; 03823 } 03824 case DoublePixel: 03825 { 03826 ImportDoublePixel(image,&roi,map,quantum_map,pixels,exception); 03827 break; 03828 } 03829 case FloatPixel: 03830 { 03831 ImportFloatPixel(image,&roi,map,quantum_map,pixels,exception); 03832 break; 03833 } 03834 case LongPixel: 03835 { 03836 ImportLongPixel(image,&roi,map,quantum_map,pixels,exception); 03837 break; 03838 } 03839 case LongLongPixel: 03840 { 03841 ImportLongLongPixel(image,&roi,map,quantum_map,pixels,exception); 03842 break; 03843 } 03844 case QuantumPixel: 03845 { 03846 ImportQuantumPixel(image,&roi,map,quantum_map,pixels,exception); 03847 break; 03848 } 03849 case ShortPixel: 03850 { 03851 ImportShortPixel(image,&roi,map,quantum_map,pixels,exception); 03852 break; 03853 } 03854 default: 03855 { 03856 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); 03857 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, 03858 "UnrecognizedPixelMap","`%s'",map); 03859 break; 03860 } 03861 } 03862 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); 03863 return(MagickTrue); 03864 } 03865 03866 /* 03867 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 03868 % % 03869 % % 03870 % % 03871 + I n i t i a l i z e P i x e l C h a n n e l M a p % 03872 % % 03873 % % 03874 % % 03875 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 03876 % 03877 % InitializePixelChannelMap() defines the standard pixel component map. 03878 % 03879 % The format of the InitializePixelChannelMap() method is: 03880 % 03881 % void InitializePixelChannelMap(Image *image) 03882 % 03883 % A description of each parameter follows: 03884 % 03885 % o image: the image. 03886 % 03887 */ 03888 MagickExport void InitializePixelChannelMap(Image *image) 03889 { 03890 PixelTrait 03891 trait; 03892 03893 register ssize_t 03894 i; 03895 03896 ssize_t 03897 n; 03898 03899 assert(image != (Image *) NULL); 03900 assert(image->signature == MagickSignature); 03901 (void) ResetMagickMemory(image->channel_map,0,MaxPixelChannels* 03902 sizeof(*image->channel_map)); 03903 trait=UpdatePixelTrait; 03904 if (image->matte != MagickFalse) 03905 trait=(PixelTrait) (trait | BlendPixelTrait); 03906 n=0; 03907 if (image->colorspace == GRAYColorspace) 03908 { 03909 SetPixelChannelMap(image,BluePixelChannel,trait,n); 03910 SetPixelChannelMap(image,GreenPixelChannel,trait,n); 03911 SetPixelChannelMap(image,RedPixelChannel,trait,n++); 03912 } 03913 else 03914 { 03915 SetPixelChannelMap(image,RedPixelChannel,trait,n++); 03916 SetPixelChannelMap(image,GreenPixelChannel,trait,n++); 03917 SetPixelChannelMap(image,BluePixelChannel,trait,n++); 03918 } 03919 if (image->colorspace == CMYKColorspace) 03920 SetPixelChannelMap(image,BlackPixelChannel,trait,n++); 03921 if (image->matte != MagickFalse) 03922 SetPixelChannelMap(image,AlphaPixelChannel,CopyPixelTrait,n++); 03923 if (image->storage_class == PseudoClass) 03924 SetPixelChannelMap(image,IndexPixelChannel,CopyPixelTrait,n++); 03925 if (image->mask != MagickFalse) 03926 SetPixelChannelMap(image,MaskPixelChannel,CopyPixelTrait,n++); 03927 assert((n+image->number_meta_channels) < MaxPixelChannels); 03928 for (i=0; i < (ssize_t) image->number_meta_channels; i++) 03929 SetPixelChannelMap(image,(PixelChannel) (MetaPixelChannel+i),CopyPixelTrait, 03930 n++); 03931 image->number_channels=(size_t) n; 03932 if (image->debug != MagickFalse) 03933 LogPixelChannels(image); 03934 (void) SetPixelChannelMask(image,image->channel_mask); 03935 } 03936 03937 /* 03938 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 03939 % % 03940 % % 03941 % % 03942 % I n t e r p o l a t e P i x e l C h a n n e l % 03943 % % 03944 % % 03945 % % 03946 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 03947 % 03948 % InterpolatePixelChannel() applies a pixel interpolation method between a 03949 % floating point coordinate and the pixels surrounding that coordinate. No 03950 % pixel area resampling, or scaling of the result is performed. 03951 % 03952 % The format of the InterpolatePixelChannel method is: 03953 % 03954 % MagickBooleanType InterpolatePixelChannel(const Image *image, 03955 % const CacheView *image_view,const PixelChannel channel, 03956 % const PixelInterpolateMethod method,const double x,const double y, 03957 % double *pixel,ExceptionInfo *exception) 03958 % 03959 % A description of each parameter follows: 03960 % 03961 % o image: the image. 03962 % 03963 % o image_view: the image view. 03964 % 03965 % o channel: the pixel channel to interpolate. 03966 % 03967 % o method: the pixel color interpolation method. 03968 % 03969 % o x,y: A double representing the current (x,y) position of the pixel. 03970 % 03971 % o pixel: return the interpolated pixel here. 03972 % 03973 % o exception: return any errors or warnings in this structure. 03974 % 03975 */ 03976 03977 static inline double MagickMax(const MagickRealType x,const MagickRealType y) 03978 { 03979 if (x > y) 03980 return(x); 03981 return(y); 03982 } 03983 03984 static inline MagickRealType CubicWeightingFunction(const MagickRealType x) 03985 { 03986 MagickRealType 03987 alpha, 03988 gamma; 03989 03990 alpha=MagickMax(x+2.0,0.0); 03991 gamma=1.0*alpha*alpha*alpha; 03992 alpha=MagickMax(x+1.0,0.0); 03993 gamma-=4.0*alpha*alpha*alpha; 03994 alpha=MagickMax(x+0.0,0.0); 03995 gamma+=6.0*alpha*alpha*alpha; 03996 alpha=MagickMax(x-1.0,0.0); 03997 gamma-=4.0*alpha*alpha*alpha; 03998 return(gamma/6.0); 03999 } 04000 04001 static inline double MeshInterpolate(const PointInfo *delta,const double p, 04002 const double x,const double y) 04003 { 04004 return(delta->x*x+delta->y*y+(1.0-delta->x-delta->y)*p); 04005 } 04006 04007 static inline ssize_t NearestNeighbor(const MagickRealType x) 04008 { 04009 if (x >= 0.0) 04010 return((ssize_t) (x+0.5)); 04011 return((ssize_t) (x-0.5)); 04012 } 04013 04014 MagickExport MagickBooleanType InterpolatePixelChannel(const Image *image, 04015 const CacheView *image_view,const PixelChannel channel, 04016 const PixelInterpolateMethod method,const double x,const double y, 04017 double *pixel,ExceptionInfo *exception) 04018 { 04019 MagickBooleanType 04020 status; 04021 04022 MagickRealType 04023 alpha[16], 04024 gamma, 04025 pixels[16]; 04026 04027 PixelTrait 04028 traits; 04029 04030 register const Quantum 04031 *p; 04032 04033 register ssize_t 04034 i; 04035 04036 ssize_t 04037 x_offset, 04038 y_offset; 04039 04040 assert(image != (Image *) NULL); 04041 assert(image != (Image *) NULL); 04042 assert(image->signature == MagickSignature); 04043 assert(image_view != (CacheView *) NULL); 04044 status=MagickTrue; 04045 *pixel=0.0; 04046 traits=GetPixelChannelMapTraits(image,channel); 04047 x_offset=(ssize_t) floor(x); 04048 y_offset=(ssize_t) floor(y); 04049 switch (method == UndefinedInterpolatePixel ? image->interpolate : method) 04050 { 04051 case AverageInterpolatePixel: 04052 { 04053 p=GetCacheViewVirtualPixels(image_view,x_offset-1,y_offset-1,4,4, 04054 exception); 04055 if (p == (const Quantum *) NULL) 04056 { 04057 status=MagickFalse; 04058 break; 04059 } 04060 if ((traits & BlendPixelTrait) == 0) 04061 for (i=0; i < 16; i++) 04062 { 04063 alpha[i]=1.0; 04064 pixels[i]=(MagickRealType) p[i*GetPixelChannels(image)+channel]; 04065 } 04066 else 04067 for (i=0; i < 16; i++) 04068 { 04069 alpha[i]=QuantumScale*GetPixelAlpha(image,p+i* 04070 GetPixelChannels(image)); 04071 pixels[i]=alpha[i]*p[i*GetPixelChannels(image)+channel]; 04072 } 04073 for (i=0; i < 16; i++) 04074 { 04075 gamma=1.0/(fabs((double) alpha[i]) <= MagickEpsilon ? 1.0 : alpha[i]); 04076 *pixel+=gamma*0.0625*pixels[i]; 04077 } 04078 break; 04079 } 04080 case BicubicInterpolatePixel: 04081 { 04082 MagickRealType 04083 u[4], 04084 v[4]; 04085 04086 PointInfo 04087 delta; 04088 04089 p=GetCacheViewVirtualPixels(image_view,x_offset-1,y_offset-1,4,4, 04090 exception); 04091 if (p == (const Quantum *) NULL) 04092 { 04093 status=MagickFalse; 04094 break; 04095 } 04096 if ((traits & BlendPixelTrait) == 0) 04097 for (i=0; i < 16; i++) 04098 { 04099 alpha[i]=1.0; 04100 pixels[i]=(MagickRealType) p[i*GetPixelChannels(image)+channel]; 04101 } 04102 else 04103 for (i=0; i < 16; i++) 04104 { 04105 alpha[i]=QuantumScale*GetPixelAlpha(image,p+i* 04106 GetPixelChannels(image)); 04107 pixels[i]=alpha[i]*p[i*GetPixelChannels(image)+channel]; 04108 } 04109 delta.x=x-x_offset; 04110 delta.y=y-y_offset; 04111 for (i=0; i < 4; i++) 04112 { 04113 u[0]=(pixels[4*i+3]-pixels[4*i+2])-(pixels[4*i+0]-pixels[4*i+1]); 04114 u[1]=(pixels[4*i+0]-pixels[4*i+1])-u[0]; 04115 u[2]=pixels[4*i+2]-pixels[4*i+0]; 04116 u[3]=pixels[4*i+1]; 04117 v[i]=(delta.x*delta.x*delta.x*u[0])+(delta.x*delta.x*u[1])+(delta.x* 04118 u[2])+u[3]; 04119 } 04120 u[0]=(v[3]-v[2])-(v[0]-v[1]); 04121 u[1]=(v[0]-v[1])-u[0]; 04122 u[2]=v[2]-v[0]; 04123 u[3]=v[1]; 04124 *pixel=(delta.y*delta.y*delta.y*u[0])+(delta.y*delta.y*u[1])+(delta.y* 04125 u[2])+u[3]; 04126 break; 04127 } 04128 case BilinearInterpolatePixel: 04129 default: 04130 { 04131 PointInfo 04132 delta, 04133 epsilon; 04134 04135 p=GetCacheViewVirtualPixels(image_view,x_offset,y_offset,2,2,exception); 04136 if (p == (const Quantum *) NULL) 04137 { 04138 status=MagickFalse; 04139 break; 04140 } 04141 if ((traits & BlendPixelTrait) == 0) 04142 for (i=0; i < 4; i++) 04143 { 04144 alpha[i]=1.0; 04145 pixels[i]=(MagickRealType) p[i*GetPixelChannels(image)+channel]; 04146 } 04147 else 04148 for (i=0; i < 4; i++) 04149 { 04150 alpha[i]=QuantumScale*GetPixelAlpha(image,p+i* 04151 GetPixelChannels(image)); 04152 pixels[i]=alpha[i]*p[i*GetPixelChannels(image)+channel]; 04153 } 04154 delta.x=x-x_offset; 04155 delta.y=y-y_offset; 04156 epsilon.x=1.0-delta.x; 04157 epsilon.y=1.0-delta.y; 04158 gamma=((epsilon.y*(epsilon.x*alpha[0]+delta.x*alpha[1])+delta.y* 04159 (epsilon.x*alpha[2]+delta.