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

Generated on 21 Nov 2009 for MagickCore by  doxygen 1.6.1