quantum.c

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