|
MagickCore
6.7.5
|
00001 /* 00002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00003 % % 00004 % % 00005 % % 00006 % QQQ U U AAA N N TTTTT U U M M % 00007 % Q Q U U A A NN N T U U MM MM % 00008 % Q Q U U AAAAA N N N T U U M M M % 00009 % Q QQ U U A A N NN T U U M M % 00010 % QQQQ UUU A A N N T UUU M M % 00011 % % 00012 % MagicCore Methods to Acquire / Destroy Quantum Pixels % 00013 % % 00014 % Software Design % 00015 % John Cristy % 00016 % October 1998 % 00017 % % 00018 % % 00019 % Copyright 1999-2008 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/attribute.h" 00043 #include "MagickCore/blob.h" 00044 #include "MagickCore/blob-private.h" 00045 #include "MagickCore/color-private.h" 00046 #include "MagickCore/exception.h" 00047 #include "MagickCore/exception-private.h" 00048 #include "MagickCore/cache.h" 00049 #include "MagickCore/constitute.h" 00050 #include "MagickCore/delegate.h" 00051 #include "MagickCore/geometry.h" 00052 #include "MagickCore/list.h" 00053 #include "MagickCore/magick.h" 00054 #include "MagickCore/memory_.h" 00055 #include "MagickCore/monitor.h" 00056 #include "MagickCore/option.h" 00057 #include "MagickCore/pixel.h" 00058 #include "MagickCore/pixel-accessor.h" 00059 #include "MagickCore/property.h" 00060 #include "MagickCore/quantum.h" 00061 #include "MagickCore/quantum-private.h" 00062 #include "MagickCore/resource_.h" 00063 #include "MagickCore/semaphore.h" 00064 #include "MagickCore/statistic.h" 00065 #include "MagickCore/stream.h" 00066 #include "MagickCore/string_.h" 00067 #include "MagickCore/string-private.h" 00068 #include "MagickCore/thread-private.h" 00069 #include "MagickCore/utility.h" 00070 00071 /* 00072 Define declarations. 00073 */ 00074 #define QuantumSignature 0xab 00075 00076 /* 00077 Forward declarations. 00078 */ 00079 static void 00080 DestroyQuantumPixels(QuantumInfo *); 00081 00082 /* 00083 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00084 % % 00085 % % 00086 % % 00087 % A c q u i r e Q u a n t u m I n f o % 00088 % % 00089 % % 00090 % % 00091 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00092 % 00093 % AcquireQuantumInfo() allocates the QuantumInfo structure. 00094 % 00095 % The format of the AcquireQuantumInfo method is: 00096 % 00097 % QuantumInfo *AcquireQuantumInfo(const ImageInfo *image_info,Image *image) 00098 % 00099 % A description of each parameter follows: 00100 % 00101 % o image_info: the image info. 00102 % 00103 % o image: the image. 00104 % 00105 */ 00106 00107 static inline size_t MagickMax(const size_t x, 00108 const size_t y) 00109 { 00110 if (x > y) 00111 return(x); 00112 return(y); 00113 } 00114 00115 MagickExport QuantumInfo *AcquireQuantumInfo(const ImageInfo *image_info, 00116 Image *image) 00117 { 00118 MagickBooleanType 00119 status; 00120 00121 QuantumInfo 00122 *quantum_info; 00123 00124 quantum_info=(QuantumInfo *) AcquireMagickMemory(sizeof(*quantum_info)); 00125 if (quantum_info == (QuantumInfo *) NULL) 00126 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); 00127 quantum_info->signature=MagickSignature; 00128 GetQuantumInfo(image_info,quantum_info); 00129 if (image == (const Image *) NULL) 00130 return(quantum_info); 00131 status=SetQuantumDepth(image,quantum_info,image->depth); 00132 if (status == MagickFalse) 00133 quantum_info=DestroyQuantumInfo(quantum_info); 00134 quantum_info->endian=image->endian; 00135 return(quantum_info); 00136 } 00137 00138 /* 00139 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00140 % % 00141 % % 00142 % % 00143 + A c q u i r e Q u a n t u m P i x e l s % 00144 % % 00145 % % 00146 % % 00147 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00148 % 00149 % AcquireQuantumPixels() allocates the unsigned char structure. 00150 % 00151 % The format of the AcquireQuantumPixels method is: 00152 % 00153 % MagickBooleanType AcquireQuantumPixels(QuantumInfo *quantum_info, 00154 % const size_t extent) 00155 % 00156 % A description of each parameter follows: 00157 % 00158 % o quantum_info: the quantum info. 00159 % 00160 % o extent: the quantum info. 00161 % 00162 */ 00163 static MagickBooleanType AcquireQuantumPixels(QuantumInfo *quantum_info, 00164 const size_t extent) 00165 { 00166 register ssize_t 00167 i; 00168 00169 assert(quantum_info != (QuantumInfo *) NULL); 00170 assert(quantum_info->signature == MagickSignature); 00171 quantum_info->number_threads=GetOpenMPMaximumThreads(); 00172 quantum_info->pixels=(unsigned char **) AcquireQuantumMemory( 00173 quantum_info->number_threads,sizeof(*quantum_info->pixels)); 00174 if (quantum_info->pixels == (unsigned char **) NULL) 00175 return(MagickFalse); 00176 quantum_info->extent=extent; 00177 (void) ResetMagickMemory(quantum_info->pixels,0, 00178 quantum_info->number_threads*sizeof(*quantum_info->pixels)); 00179 for (i=0; i < (ssize_t) quantum_info->number_threads; i++) 00180 { 00181 quantum_info->pixels[i]=(unsigned char *) AcquireQuantumMemory(extent+1, 00182 sizeof(**quantum_info->pixels)); 00183 if (quantum_info->pixels[i] == (unsigned char *) NULL) 00184 return(MagickFalse); 00185 (void) ResetMagickMemory(quantum_info->pixels[i],0,(extent+1)* 00186 sizeof(**quantum_info->pixels)); 00187 quantum_info->pixels[i][extent]=QuantumSignature; 00188 } 00189 return(MagickTrue); 00190 } 00191 00192 /* 00193 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00194 % % 00195 % % 00196 % % 00197 % D e s t r o y Q u a n t u m I n f o % 00198 % % 00199 % % 00200 % % 00201 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00202 % 00203 % DestroyQuantumInfo() deallocates memory associated with the QuantumInfo 00204 % structure. 00205 % 00206 % The format of the DestroyQuantumInfo method is: 00207 % 00208 % QuantumInfo *DestroyQuantumInfo(QuantumInfo *quantum_info) 00209 % 00210 % A description of each parameter follows: 00211 % 00212 % o quantum_info: the quantum info. 00213 % 00214 */ 00215 MagickExport QuantumInfo *DestroyQuantumInfo(QuantumInfo *quantum_info) 00216 { 00217 assert(quantum_info != (QuantumInfo *) NULL); 00218 assert(quantum_info->signature == MagickSignature); 00219 if (quantum_info->pixels != (unsigned char **) NULL) 00220 DestroyQuantumPixels(quantum_info); 00221 if (quantum_info->semaphore != (SemaphoreInfo *) NULL) 00222 DestroySemaphoreInfo(&quantum_info->semaphore); 00223 quantum_info->signature=(~MagickSignature); 00224 quantum_info=(QuantumInfo *) RelinquishMagickMemory(quantum_info); 00225 return(quantum_info); 00226 } 00227 00228 /* 00229 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00230 % % 00231 % % 00232 % % 00233 + D e s t r o y Q u a n t u m P i x e l s % 00234 % % 00235 % % 00236 % % 00237 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00238 % 00239 % DestroyQuantumPixels() destroys the quantum pixels. 00240 % 00241 % The format of the DestroyQuantumPixels() method is: 00242 % 00243 % void DestroyQuantumPixels(QuantumInfo *quantum_info) 00244 % 00245 % A description of each parameter follows: 00246 % 00247 % o quantum_info: the quantum info. 00248 % 00249 */ 00250 static void DestroyQuantumPixels(QuantumInfo *quantum_info) 00251 { 00252 register ssize_t 00253 i; 00254 00255 ssize_t 00256 extent; 00257 00258 assert(quantum_info != (QuantumInfo *) NULL); 00259 assert(quantum_info->signature == MagickSignature); 00260 assert(quantum_info->pixels != (unsigned char **) NULL); 00261 extent=(ssize_t) quantum_info->extent; 00262 for (i=0; i < (ssize_t) quantum_info->number_threads; i++) 00263 if (quantum_info->pixels[i] != (unsigned char *) NULL) 00264 { 00265 /* 00266 Did we overrun our quantum buffer? 00267 */ 00268 assert(quantum_info->pixels[i][extent] == QuantumSignature); 00269 quantum_info->pixels[i]=(unsigned char *) RelinquishMagickMemory( 00270 quantum_info->pixels[i]); 00271 } 00272 quantum_info->pixels=(unsigned char **) RelinquishMagickMemory( 00273 quantum_info->pixels); 00274 } 00275 00276 /* 00277 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00278 % % 00279 % % 00280 % % 00281 % G e t Q u a n t u m E x t e n t % 00282 % % 00283 % % 00284 % % 00285 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00286 % 00287 % GetQuantumExtent() returns the quantum pixel buffer extent. 00288 % 00289 % The format of the GetQuantumExtent method is: 00290 % 00291 % size_t GetQuantumExtent(Image *image,const QuantumInfo *quantum_info, 00292 % const QuantumType quantum_type) 00293 % 00294 % A description of each parameter follows: 00295 % 00296 % o image: the image. 00297 % 00298 % o quantum_info: the quantum info. 00299 % 00300 % o quantum_type: Declare which pixel components to transfer (red, green, 00301 % blue, opacity, RGB, or RGBA). 00302 % 00303 */ 00304 MagickExport size_t GetQuantumExtent(const Image *image, 00305 const QuantumInfo *quantum_info,const QuantumType quantum_type) 00306 { 00307 size_t 00308 packet_size; 00309 00310 assert(quantum_info != (QuantumInfo *) NULL); 00311 assert(quantum_info->signature == MagickSignature); 00312 packet_size=1; 00313 switch (quantum_type) 00314 { 00315 case GrayAlphaQuantum: packet_size=2; break; 00316 case IndexAlphaQuantum: packet_size=2; break; 00317 case RGBQuantum: packet_size=3; break; 00318 case BGRQuantum: packet_size=3; break; 00319 case RGBAQuantum: packet_size=4; break; 00320 case RGBOQuantum: packet_size=4; break; 00321 case BGRAQuantum: packet_size=4; break; 00322 case CMYKQuantum: packet_size=4; break; 00323 case CMYKAQuantum: packet_size=5; break; 00324 default: break; 00325 } 00326 if (quantum_info->pack == MagickFalse) 00327 return((size_t) (packet_size*image->columns*((quantum_info->depth+7)/8))); 00328 return((size_t) ((packet_size*image->columns*quantum_info->depth+7)/8)); 00329 } 00330 00331 /* 00332 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00333 % % 00334 % % 00335 % % 00336 % G e t Q u a n t u m F o r m a t % 00337 % % 00338 % % 00339 % % 00340 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00341 % 00342 % GetQuantumFormat() returns the quantum format of the image. 00343 % 00344 % The format of the GetQuantumFormat method is: 00345 % 00346 % QuantumFormatType GetQuantumFormat(const QuantumInfo *quantum_info) 00347 % 00348 % A description of each parameter follows: 00349 % 00350 % o quantum_info: the quantum info. 00351 % 00352 */ 00353 MagickExport QuantumFormatType GetQuantumFormat(const QuantumInfo *quantum_info) 00354 { 00355 assert(quantum_info != (QuantumInfo *) NULL); 00356 assert(quantum_info->signature == MagickSignature); 00357 return(quantum_info->format); 00358 } 00359 00360 /* 00361 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00362 % % 00363 % % 00364 % % 00365 % G e t Q u a n t u m I n f o % 00366 % % 00367 % % 00368 % % 00369 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00370 % 00371 % GetQuantumInfo() initializes the QuantumInfo structure to default values. 00372 % 00373 % The format of the GetQuantumInfo method is: 00374 % 00375 % GetQuantumInfo(const ImageInfo *image_info,QuantumInfo *quantum_info) 00376 % 00377 % A description of each parameter follows: 00378 % 00379 % o image_info: the image info. 00380 % 00381 % o quantum_info: the quantum info. 00382 % 00383 */ 00384 MagickExport void GetQuantumInfo(const ImageInfo *image_info, 00385 QuantumInfo *quantum_info) 00386 { 00387 const char 00388 *option; 00389 00390 assert(quantum_info != (QuantumInfo *) NULL); 00391 (void) ResetMagickMemory(quantum_info,0,sizeof(*quantum_info)); 00392 quantum_info->quantum=8; 00393 quantum_info->maximum=1.0; 00394 quantum_info->scale=QuantumRange; 00395 quantum_info->pack=MagickTrue; 00396 quantum_info->semaphore=AllocateSemaphoreInfo(); 00397 quantum_info->signature=MagickSignature; 00398 if (image_info == (const ImageInfo *) NULL) 00399 return; 00400 option=GetImageOption(image_info,"quantum:format"); 00401 if (option != (char *) NULL) 00402 quantum_info->format=(QuantumFormatType) ParseCommandOption( 00403 MagickQuantumFormatOptions,MagickFalse,option); 00404 option=GetImageOption(image_info,"quantum:minimum"); 00405 if (option != (char *) NULL) 00406 quantum_info->minimum=StringToDouble(option,(char **) NULL); 00407 option=GetImageOption(image_info,"quantum:maximum"); 00408 if (option != (char *) NULL) 00409 quantum_info->maximum=StringToDouble(option,(char **) NULL); 00410 if ((quantum_info->minimum == 0.0) && (quantum_info->maximum == 0.0)) 00411 quantum_info->scale=0.0; 00412 else 00413 if (quantum_info->minimum == quantum_info->maximum) 00414 { 00415 quantum_info->scale=(MagickRealType) QuantumRange/quantum_info->minimum; 00416 quantum_info->minimum=0.0; 00417 } 00418 else 00419 quantum_info->scale=(MagickRealType) QuantumRange/(quantum_info->maximum- 00420 quantum_info->minimum); 00421 option=GetImageOption(image_info,"quantum:scale"); 00422 if (option != (char *) NULL) 00423 quantum_info->scale=StringToDouble(option,(char **) NULL); 00424 option=GetImageOption(image_info,"quantum:polarity"); 00425 if (option != (char *) NULL) 00426 quantum_info->min_is_white=LocaleCompare(option,"min-is-white") == 0 ? 00427 MagickTrue : MagickFalse; 00428 quantum_info->endian=image_info->endian; 00429 ResetQuantumState(quantum_info); 00430 } 00431 00432 /* 00433 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00434 % % 00435 % % 00436 % % 00437 % G e t Q u a n t u m P i x e l s % 00438 % % 00439 % % 00440 % % 00441 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00442 % 00443 % GetQuantumPixels() returns the quantum pixels. 00444 % 00445 % The format of the GetQuantumPixels method is: 00446 % 00447 % unsigned char *QuantumPixels GetQuantumPixels( 00448 % const QuantumInfo *quantum_info) 00449 % 00450 % A description of each parameter follows: 00451 % 00452 % o image: the image. 00453 % 00454 */ 00455 MagickExport unsigned char *GetQuantumPixels(const QuantumInfo *quantum_info) 00456 { 00457 const int 00458 id = GetOpenMPThreadId(); 00459 00460 assert(quantum_info != (QuantumInfo *) NULL); 00461 assert(quantum_info->signature == MagickSignature); 00462 return(quantum_info->pixels[id]); 00463 } 00464 00465 /* 00466 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00467 % % 00468 % % 00469 % % 00470 % G e t Q u a n t u m T y p e % 00471 % % 00472 % % 00473 % % 00474 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00475 % 00476 % GetQuantumType() returns the quantum type of the image. 00477 % 00478 % The format of the GetQuantumType method is: 00479 % 00480 % QuantumType GetQuantumType(Image *image,ExceptionInfo *exception) 00481 % 00482 % A description of each parameter follows: 00483 % 00484 % o image: the image. 00485 % 00486 */ 00487 MagickExport QuantumType GetQuantumType(Image *image,ExceptionInfo *exception) 00488 { 00489 QuantumType 00490 quantum_type; 00491 00492 assert(image != (Image *) NULL); 00493 assert(image->signature == MagickSignature); 00494 if (image->debug != MagickFalse) 00495 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); 00496 quantum_type=RGBQuantum; 00497 if (image->matte != MagickFalse) 00498 quantum_type=RGBAQuantum; 00499 if (image->colorspace == CMYKColorspace) 00500 { 00501 quantum_type=CMYKQuantum; 00502 if (image->matte != MagickFalse) 00503 quantum_type=CMYKAQuantum; 00504 } 00505 if (IsImageGray(image,exception) != MagickFalse) 00506 { 00507 quantum_type=GrayQuantum; 00508 if (image->matte != MagickFalse) 00509 quantum_type=GrayAlphaQuantum; 00510 } 00511 else 00512 if (image->storage_class == PseudoClass) 00513 { 00514 quantum_type=IndexQuantum; 00515 if (image->matte != MagickFalse) 00516 quantum_type=IndexAlphaQuantum; 00517 } 00518 return(quantum_type); 00519 } 00520 00521 /* 00522 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00523 % % 00524 % % 00525 % % 00526 + R e s e t Q u a n t u m S t a t e % 00527 % % 00528 % % 00529 % % 00530 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00531 % 00532 % ResetQuantumState() resets the quantum state. 00533 % 00534 % The format of the ResetQuantumState method is: 00535 % 00536 % void ResetQuantumState(QuantumInfo *quantum_info) 00537 % 00538 % A description of each parameter follows: 00539 % 00540 % o quantum_info: the quantum info. 00541 % 00542 */ 00543 MagickPrivate void ResetQuantumState(QuantumInfo *quantum_info) 00544 { 00545 static const unsigned int mask[32] = 00546 { 00547 0x00000000U, 0x00000001U, 0x00000003U, 0x00000007U, 0x0000000fU, 00548 0x0000001fU, 0x0000003fU, 0x0000007fU, 0x000000ffU, 0x000001ffU, 00549 0x000003ffU, 0x000007ffU, 0x00000fffU, 0x00001fffU, 0x00003fffU, 00550 0x00007fffU, 0x0000ffffU, 0x0001ffffU, 0x0003ffffU, 0x0007ffffU, 00551 0x000fffffU, 0x001fffffU, 0x003fffffU, 0x007fffffU, 0x00ffffffU, 00552 0x01ffffffU, 0x03ffffffU, 0x07ffffffU, 0x0fffffffU, 0x1fffffffU, 00553 0x3fffffffU, 0x7fffffffU 00554 }; 00555 00556 assert(quantum_info != (QuantumInfo *) NULL); 00557 assert(quantum_info->signature == MagickSignature); 00558 quantum_info->state.inverse_scale=1.0; 00559 if (fabs(quantum_info->scale) >= MagickEpsilon) 00560 quantum_info->state.inverse_scale/=quantum_info->scale; 00561 quantum_info->state.pixel=0U; 00562 quantum_info->state.bits=0U; 00563 quantum_info->state.mask=mask; 00564 } 00565 00566 /* 00567 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00568 % % 00569 % % 00570 % % 00571 % S e t Q u a n t u m F o r m a t % 00572 % % 00573 % % 00574 % % 00575 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00576 % 00577 % SetQuantumAlphaType() sets the quantum format. 00578 % 00579 % The format of the SetQuantumAlphaType method is: 00580 % 00581 % void SetQuantumAlphaType(QuantumInfo *quantum_info, 00582 % const QuantumAlphaType type) 00583 % 00584 % A description of each parameter follows: 00585 % 00586 % o quantum_info: the quantum info. 00587 % 00588 % o type: the alpha type (e.g. associate). 00589 % 00590 */ 00591 MagickExport void SetQuantumAlphaType(QuantumInfo *quantum_info, 00592 const QuantumAlphaType type) 00593 { 00594 assert(quantum_info != (QuantumInfo *) NULL); 00595 assert(quantum_info->signature == MagickSignature); 00596 quantum_info->alpha_type=type; 00597 } 00598 00599 /* 00600 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00601 % % 00602 % % 00603 % % 00604 % S e t Q u a n t u m D e p t h % 00605 % % 00606 % % 00607 % % 00608 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00609 % 00610 % SetQuantumDepth() sets the quantum depth. 00611 % 00612 % The format of the SetQuantumDepth method is: 00613 % 00614 % MagickBooleanType SetQuantumDepth(const Image *image, 00615 % QuantumInfo *quantum_info,const size_t depth) 00616 % 00617 % A description of each parameter follows: 00618 % 00619 % o image: the image. 00620 % 00621 % o quantum_info: the quantum info. 00622 % 00623 % o depth: the quantum depth. 00624 % 00625 */ 00626 MagickExport MagickBooleanType SetQuantumDepth(const Image *image, 00627 QuantumInfo *quantum_info,const size_t depth) 00628 { 00629 MagickBooleanType 00630 status; 00631 00632 /* 00633 Allocate the quantum pixel buffer. 00634 */ 00635 assert(image != (Image *) NULL); 00636 assert(image->signature == MagickSignature); 00637 if (image->debug != MagickFalse) 00638 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); 00639 assert(quantum_info != (QuantumInfo *) NULL); 00640 assert(quantum_info->signature == MagickSignature); 00641 quantum_info->depth=depth; 00642 if (quantum_info->format == FloatingPointQuantumFormat) 00643 { 00644 if (quantum_info->depth > 32) 00645 quantum_info->depth=64; 00646 else 00647 if (quantum_info->depth > 16) 00648 quantum_info->depth=32; 00649 else 00650 quantum_info->depth=16; 00651 } 00652 if (quantum_info->pixels != (unsigned char **) NULL) 00653 DestroyQuantumPixels(quantum_info); 00654 status=AcquireQuantumPixels(quantum_info,(6+quantum_info->pad)*image->columns* 00655 ((quantum_info->depth+7)/8)); /* allow for CMYKA + RLE byte + pad */ 00656 return(status); 00657 } 00658 00659 /* 00660 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00661 % % 00662 % % 00663 % % 00664 % S e t Q u a n t u m F o r m a t % 00665 % % 00666 % % 00667 % % 00668 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00669 % 00670 % SetQuantumFormat() sets the quantum format. 00671 % 00672 % The format of the SetQuantumFormat method is: 00673 % 00674 % MagickBooleanType SetQuantumFormat(const Image *image, 00675 % QuantumInfo *quantum_info,const QuantumFormatType format) 00676 % 00677 % A description of each parameter follows: 00678 % 00679 % o image: the image. 00680 % 00681 % o quantum_info: the quantum info. 00682 % 00683 % o format: the quantum format. 00684 % 00685 */ 00686 MagickExport MagickBooleanType SetQuantumFormat(const Image *image, 00687 QuantumInfo *quantum_info,const QuantumFormatType format) 00688 { 00689 assert(image != (Image *) NULL); 00690 assert(image->signature == MagickSignature); 00691 if (image->debug != MagickFalse) 00692 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); 00693 assert(quantum_info != (QuantumInfo *) NULL); 00694 assert(quantum_info->signature == MagickSignature); 00695 quantum_info->format=format; 00696 return(SetQuantumDepth(image,quantum_info,quantum_info->depth)); 00697 } 00698 00699 /* 00700 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00701 % % 00702 % % 00703 % % 00704 % S e t Q u a n t u m I m a g e T y p e % 00705 % % 00706 % % 00707 % % 00708 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00709 % 00710 % SetQuantumImageType() sets the image type based on the quantum type. 00711 % 00712 % The format of the SetQuantumImageType method is: 00713 % 00714 % void ImageType SetQuantumImageType(Image *image, 00715 % const QuantumType quantum_type) 00716 % 00717 % A description of each parameter follows: 00718 % 00719 % o image: the image. 00720 % 00721 % o quantum_type: Declare which pixel components to transfer (red, green, 00722 % blue, opacity, RGB, or RGBA). 00723 % 00724 */ 00725 MagickExport void SetQuantumImageType(Image *image, 00726 const QuantumType quantum_type) 00727 { 00728 assert(image != (Image *) NULL); 00729 assert(image->signature == MagickSignature); 00730 if (image->debug != MagickFalse) 00731 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); 00732 switch (quantum_type) 00733 { 00734 case IndexQuantum: 00735 case IndexAlphaQuantum: 00736 { 00737 image->type=PaletteType; 00738 break; 00739 } 00740 case GrayQuantum: 00741 case GrayAlphaQuantum: 00742 { 00743 image->type=GrayscaleType; 00744 if (image->depth == 1) 00745 image->type=BilevelType; 00746 break; 00747 } 00748 case CyanQuantum: 00749 case MagentaQuantum: 00750 case YellowQuantum: 00751 case BlackQuantum: 00752 case CMYKQuantum: 00753 case CMYKAQuantum: 00754 { 00755 image->type=ColorSeparationType; 00756 break; 00757 } 00758 default: 00759 { 00760 image->type=TrueColorType; 00761 break; 00762 } 00763 } 00764 } 00765 00766 /* 00767 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00768 % % 00769 % % 00770 % % 00771 % S e t Q u a n t u m P a c k % 00772 % % 00773 % % 00774 % % 00775 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00776 % 00777 % SetQuantumPack() sets the quantum pack flag. 00778 % 00779 % The format of the SetQuantumPack method is: 00780 % 00781 % void SetQuantumPack(QuantumInfo *quantum_info, 00782 % const MagickBooleanType pack) 00783 % 00784 % A description of each parameter follows: 00785 % 00786 % o quantum_info: the quantum info. 00787 % 00788 % o pack: the pack flag. 00789 % 00790 */ 00791 MagickExport void SetQuantumPack(QuantumInfo *quantum_info, 00792 const MagickBooleanType pack) 00793 { 00794 assert(quantum_info != (QuantumInfo *) NULL); 00795 assert(quantum_info->signature == MagickSignature); 00796 quantum_info->pack=pack; 00797 } 00798 00799 00800 /* 00801 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00802 % % 00803 % % 00804 % % 00805 % S e t Q u a n t u m P a d % 00806 % % 00807 % % 00808 % % 00809 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00810 % 00811 % SetQuantumPad() sets the quantum pad. 00812 % 00813 % The format of the SetQuantumPad method is: 00814 % 00815 % MagickBooleanType SetQuantumPad(const Image *image, 00816 % QuantumInfo *quantum_info,const size_t pad) 00817 % 00818 % A description of each parameter follows: 00819 % 00820 % o image: the image. 00821 % 00822 % o quantum_info: the quantum info. 00823 % 00824 % o pad: the quantum pad. 00825 % 00826 */ 00827 MagickExport MagickBooleanType SetQuantumPad(const Image *image, 00828 QuantumInfo *quantum_info,const size_t pad) 00829 { 00830 assert(image != (Image *) NULL); 00831 assert(image->signature == MagickSignature); 00832 if (image->debug != MagickFalse) 00833 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); 00834 assert(quantum_info != (QuantumInfo *) NULL); 00835 assert(quantum_info->signature == MagickSignature); 00836 quantum_info->pad=pad; 00837 return(SetQuantumDepth(image,quantum_info,quantum_info->depth)); 00838 } 00839 00840 /* 00841 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00842 % % 00843 % % 00844 % % 00845 % S e t Q u a n t u m M i n I s W h i t e % 00846 % % 00847 % % 00848 % % 00849 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00850 % 00851 % SetQuantumMinIsWhite() sets the quantum min-is-white flag. 00852 % 00853 % The format of the SetQuantumMinIsWhite method is: 00854 % 00855 % void SetQuantumMinIsWhite(QuantumInfo *quantum_info, 00856 % const MagickBooleanType min_is_white) 00857 % 00858 % A description of each parameter follows: 00859 % 00860 % o quantum_info: the quantum info. 00861 % 00862 % o min_is_white: the min-is-white flag. 00863 % 00864 */ 00865 MagickExport void SetQuantumMinIsWhite(QuantumInfo *quantum_info, 00866 const MagickBooleanType min_is_white) 00867 { 00868 assert(quantum_info != (QuantumInfo *) NULL); 00869 assert(quantum_info->signature == MagickSignature); 00870 quantum_info->min_is_white=min_is_white; 00871 } 00872 00873 /* 00874 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00875 % % 00876 % % 00877 % % 00878 % S e t Q u a n t u m Q u a n t u m % 00879 % % 00880 % % 00881 % % 00882 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00883 % 00884 % SetQuantumQuantum() sets the quantum quantum. 00885 % 00886 % The format of the SetQuantumQuantum method is: 00887 % 00888 % void SetQuantumQuantum(QuantumInfo *quantum_info, 00889 % const size_t quantum) 00890 % 00891 % A description of each parameter follows: 00892 % 00893 % o quantum_info: the quantum info. 00894 % 00895 % o quantum: the quantum quantum. 00896 % 00897 */ 00898 MagickExport void SetQuantumQuantum(QuantumInfo *quantum_info, 00899 const size_t quantum) 00900 { 00901 assert(quantum_info != (QuantumInfo *) NULL); 00902 assert(quantum_info->signature == MagickSignature); 00903 quantum_info->quantum=quantum; 00904 } 00905 00906 /* 00907 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00908 % % 00909 % % 00910 % % 00911 % S e t Q u a n t u m S c a l e % 00912 % % 00913 % % 00914 % % 00915 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00916 % 00917 % SetQuantumScale() sets the quantum scale. 00918 % 00919 % The format of the SetQuantumScale method is: 00920 % 00921 % void SetQuantumScale(QuantumInfo *quantum_info,const double scale) 00922 % 00923 % A description of each parameter follows: 00924 % 00925 % o quantum_info: the quantum info. 00926 % 00927 % o scale: the quantum scale. 00928 % 00929 */ 00930 MagickExport void SetQuantumScale(QuantumInfo *quantum_info,const double scale) 00931 { 00932 assert(quantum_info != (QuantumInfo *) NULL); 00933 assert(quantum_info->signature == MagickSignature); 00934 quantum_info->scale=scale; 00935 }