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 } QuantumType;
00074 
00075 typedef struct _QuantumInfo
00076   QuantumInfo;
00077 
00078 static inline Quantum RoundToQuantum(const MagickRealType value)
00079 {
00080 #if defined(MAGICKCORE_HDRI_SUPPORT)
00081   return((Quantum) value);
00082 #else
00083   if (value <= 0.0)
00084     return((Quantum) 0);
00085   if (value >= QuantumRange)
00086     return((Quantum) QuantumRange);
00087   return((Quantum) (value+0.5));
00088 #endif
00089 }
00090 
00091 #if (MAGICKCORE_QUANTUM_DEPTH == 8)
00092 static inline unsigned char ScaleQuantumToChar(const Quantum quantum)
00093 {
00094 #if !defined(MAGICKCORE_HDRI_SUPPORT)
00095   return((unsigned char) quantum);
00096 #else
00097   if (quantum <= 0.0)
00098     return(0UL);
00099   if (quantum >= 255.0)
00100     return(255);
00101   return((unsigned char) (quantum+0.5));
00102 #endif
00103 }
00104 #elif (MAGICKCORE_QUANTUM_DEPTH == 16)
00105 static inline unsigned char ScaleQuantumToChar(const Quantum quantum)
00106 {
00107 #if !defined(MAGICKCORE_HDRI_SUPPORT)
00108   return((unsigned char) (((quantum+128UL)-((quantum+128UL) >> 8)) >> 8));
00109 #else
00110   if (quantum <= 0.0)
00111     return(0);
00112   if ((quantum/257.0) >= 255.0)
00113     return(255);
00114   return((unsigned char) (quantum/257.0+0.5));
00115 #endif
00116 }
00117 #elif (MAGICKCORE_QUANTUM_DEPTH == 32)
00118 static inline unsigned char ScaleQuantumToChar(const Quantum quantum)
00119 {
00120 #if !defined(MAGICKCORE_HDRI_SUPPORT)
00121   return((unsigned char) ((quantum+MagickULLConstant(8421504))/
00122     MagickULLConstant(16843009)));
00123 #else
00124   if (quantum <= 0.0)
00125     return(0);
00126   if ((quantum/16843009.0) >= 255.0)
00127     return(255);
00128   return((unsigned char) (quantum/16843009.0+0.5));
00129 #endif
00130 }
00131 #elif (MAGICKCORE_QUANTUM_DEPTH == 64)
00132 static inline unsigned char ScaleQuantumToChar(const Quantum quantum)
00133 {
00134 #if !defined(MAGICKCORE_HDRI_SUPPORT)
00135   return((unsigned char) ((quantum+2155839615.0)/71777214294589695.0));
00136 #else
00137   return((unsigned char) (quantum/71777214294589695.0+0.5));
00138 #endif
00139 }
00140 #endif
00141 
00142 extern MagickExport MagickBooleanType
00143   SetQuantumDepth(const Image *,QuantumInfo *,const unsigned long),
00144   SetQuantumFormat(const Image *,QuantumInfo *,const QuantumFormatType),
00145   SetQuantumPad(const Image *,QuantumInfo *,const unsigned long);
00146 
00147 extern MagickExport QuantumInfo
00148   *AcquireQuantumInfo(const ImageInfo *,Image *),
00149   *DestroyQuantumInfo(QuantumInfo *);
00150 
00151 extern MagickExport QuantumType
00152   GetQuantumType(Image *,ExceptionInfo *);
00153 
00154 extern MagickExport size_t
00155   ExportQuantumPixels(const Image *,const ViewInfo *,const QuantumInfo *,
00156     const QuantumType,unsigned char *,ExceptionInfo *),
00157   GetQuantumExtent(const Image *,const QuantumInfo *,const QuantumType),
00158   ImportQuantumPixels(Image *,ViewInfo *,const QuantumInfo *,const QuantumType,
00159     const unsigned char *,ExceptionInfo *);
00160 
00161 extern MagickExport unsigned char
00162   *GetQuantumPixels(const QuantumInfo *);
00163 
00164 extern MagickExport void
00165   GetQuantumInfo(const ImageInfo *,QuantumInfo *),
00166   SetQuantumAlphaType(QuantumInfo *,const QuantumAlphaType),
00167   SetQuantumImageType(Image *,const QuantumType),
00168   SetQuantumMinIsWhite(QuantumInfo *,const MagickBooleanType),
00169   SetQuantumPack(QuantumInfo *,const MagickBooleanType),
00170   SetQuantumQuantum(QuantumInfo *,const unsigned long),
00171   SetQuantumScale(QuantumInfo *,const double);
00172 
00173 #if defined(__cplusplus) || defined(c_plusplus)
00174 }
00175 #endif
00176 
00177 #endif

Generated on Tue Dec 30 16:17:45 2008 for MagickCore by  doxygen 1.5.7.1