quantum.h

Go to the documentation of this file.
00001 /*
00002   Copyright 1999-2008 ImageMagick Studio LLC, a non-profit organization
00003   dedicated to making software imaging solutions freely available.
00004 
00005   You may not use this file except in compliance with the License.
00006   obtain a copy of the License at
00007 
00008     http://www.imagemagick.org/script/license.php
00009 
00010   Unless required by applicable law or agreed to in writing, software
00011   distributed under the License is distributed on an "AS IS" BASIS,
00012   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013   See the License for the specific language governing permissions and
00014   limitations under the License.
00015 
00016   MagickCore quantum inline methods.
00017 */
00018 #ifndef _MAGICKCORE_QUANTUM_H
00019 #define _MAGICKCORE_QUANTUM_H
00020 
00021 #if defined(__cplusplus) || defined(c_plusplus)
00022 extern "C" {
00023 #endif
00024 
00025 #include "magick/semaphore.h"
00026 
00027 typedef enum
00028 {
00029   UndefinedEndian,
00030   LSBEndian,
00031   MSBEndian
00032 } EndianType;
00033 
00034 typedef enum
00035 {
00036   UndefinedQuantumAlpha,
00037   AssociatedQuantumAlpha,
00038   DisassociatedQuantumAlpha
00039 } QuantumAlphaType;
00040 
00041 typedef enum
00042 {
00043   UndefinedQuantumFormat,
00044   FloatingPointQuantumFormat,
00045   SignedQuantumFormat,
00046   UnsignedQuantumFormat
00047 } QuantumFormatType;
00048 
00049 typedef enum
00050 {
00051   UndefinedQuantum,
00052   AlphaQuantum,
00053   BlackQuantum,
00054   BlueQuantum,
00055   CMYKAQuantum,
00056   CMYKQuantum,
00057   CyanQuantum,
00058   GrayAlphaQuantum,
00059   GrayQuantum,
00060   GreenQuantum,
00061   IndexAlphaQuantum,
00062   IndexQuantum,
00063   MagentaQuantum,
00064   OpacityQuantum,
00065   RedQuantum,
00066   RGBAQuantum,
00067   RGBOQuantum,
00068   RGBQuantum,
00069   YellowQuantum,
00070   GrayPadQuantum,  /* deprecated */
00071   RGBPadQuantum,
00072   CbYCrYQuantum,
00073   CbYCrQuantum,
00074   CbYCrAQuantum
00075 } QuantumType;
00076 
00077 typedef struct _QuantumInfo
00078   QuantumInfo;
00079 
00080 static inline Quantum RoundToQuantum(const MagickRealType value)
00081 {
00082 #if defined(MAGICKCORE_HDRI_SUPPORT)
00083   return((Quantum) value);
00084 #else
00085   if (value <= 0.0)
00086     return((Quantum) 0);
00087   if (value >= QuantumRange)
00088     return((Quantum) QuantumRange);
00089   return((Quantum) (value+0.5));
00090 #endif
00091 }
00092 
00093 #if (MAGICKCORE_QUANTUM_DEPTH == 8)
00094 static inline unsigned char ScaleQuantumToChar(const Quantum quantum)
00095 {
00096 #if !defined(MAGICKCORE_HDRI_SUPPORT)
00097   return((unsigned char) quantum);
00098 #else
00099   if (quantum <= 0.0)
00100     return(0UL);
00101   if (quantum >= 255.0)
00102     return(255);
00103   return((unsigned char) (quantum+0.5));
00104 #endif
00105 }
00106 #elif (MAGICKCORE_QUANTUM_DEPTH == 16)
00107 static inline unsigned char ScaleQuantumToChar(const Quantum quantum)
00108 {
00109 #if !defined(MAGICKCORE_HDRI_SUPPORT)
00110   return((unsigned char) (((quantum+128UL)-((quantum+128UL) >> 8)) >> 8));
00111 #else
00112   if (quantum <= 0.0)
00113     return(0);
00114   if ((quantum/257.0) >= 255.0)
00115     return(255);
00116   return((unsigned char) (quantum/257.0+0.5));
00117 #endif
00118 }
00119 #elif (MAGICKCORE_QUANTUM_DEPTH == 32)
00120 static inline unsigned char ScaleQuantumToChar(const Quantum quantum)
00121 {
00122 #if !defined(MAGICKCORE_HDRI_SUPPORT)
00123   return((unsigned char) ((quantum+MagickULLConstant(8421504))/
00124     MagickULLConstant(16843009)));
00125 #else
00126   if (quantum <= 0.0)
00127     return(0);
00128   if ((quantum/16843009.0) >= 255.0)
00129     return(255);
00130   return((unsigned char) (quantum/16843009.0+0.5));
00131 #endif
00132 }
00133 #elif (MAGICKCORE_QUANTUM_DEPTH == 64)
00134 static inline unsigned char ScaleQuantumToChar(const Quantum quantum)
00135 {
00136 #if !defined(MAGICKCORE_HDRI_SUPPORT)
00137   return((unsigned char) ((quantum+2155839615.0)/71777214294589695.0));
00138 #else
00139   return((unsigned char) (quantum/71777214294589695.0+0.5));
00140 #endif
00141 }
00142 #endif
00143 
00144 extern MagickExport MagickBooleanType
00145   SetQuantumDepth(const Image *,QuantumInfo *,const unsigned long),
00146   SetQuantumFormat(const Image *,QuantumInfo *,const QuantumFormatType),
00147   SetQuantumPad(const Image *,QuantumInfo *,const unsigned long);
00148 
00149 extern MagickExport QuantumInfo
00150   *AcquireQuantumInfo(const ImageInfo *,Image *),
00151   *DestroyQuantumInfo(QuantumInfo *);
00152 
00153 extern MagickExport QuantumType
00154   GetQuantumType(Image *,ExceptionInfo *);
00155 
00156 extern MagickExport size_t
00157   ExportQuantumPixels(const Image *,const ViewInfo *,const QuantumInfo *,
00158     const QuantumType,unsigned char *,ExceptionInfo *),
00159   GetQuantumExtent(const Image *,const QuantumInfo *,const QuantumType),
00160   ImportQuantumPixels(Image *,ViewInfo *,const QuantumInfo *,const QuantumType,
00161     const unsigned char *,ExceptionInfo *);
00162 
00163 extern MagickExport unsigned char
00164   *GetQuantumPixels(const QuantumInfo *);
00165 
00166 extern MagickExport void
00167   GetQuantumInfo(const ImageInfo *,QuantumInfo *),
00168   SetQuantumAlphaType(QuantumInfo *,const QuantumAlphaType),
00169   SetQuantumImageType(Image *,const QuantumType),
00170   SetQuantumMinIsWhite(QuantumInfo *,const MagickBooleanType),
00171   SetQuantumPack(QuantumInfo *,const MagickBooleanType),
00172   SetQuantumQuantum(QuantumInfo *,const unsigned long),
00173   SetQuantumScale(QuantumInfo *,const double);
00174 
00175 #if defined(__cplusplus) || defined(c_plusplus)
00176 }
00177 #endif
00178 
00179 #endif

Generated on Thu Jul 2 12:03:21 2009 for MagickCore by  doxygen 1.5.8