IM: im_convert.h Source File
From IM - An Imaging Tool
im_convert.h
Go to the documentation of this file.00001 /** \file 00002 * \brief Image Conversion 00003 * 00004 * See Copyright Notice in im_lib.h 00005 */ 00006 00007 #ifndef __IM_CONVERT_H 00008 #define __IM_CONVERT_H 00009 00010 #include "im_image.h" 00011 00012 #if defined(__cplusplus) 00013 extern "C" { 00014 #endif 00015 00016 00017 /** \defgroup convert Image Conversion 00018 * \par 00019 * Converts one type of image into another. Can convert between color modes 00020 * and between data types. 00021 * \par 00022 * See \ref im_convert.h 00023 * \ingroup imgclass */ 00024 00025 00026 /** Complex to real conversions 00027 * \ingroup convert */ 00028 enum imComplex2Real 00029 { 00030 IM_CPX_REAL, 00031 IM_CPX_IMAG, 00032 IM_CPX_MAG, 00033 IM_CPX_PHASE 00034 }; 00035 00036 /** Predefined Gamma factors. Gamma can be any real number. 00037 * When gamma<0 use logarithmic, when gamma>0 use exponential. 00038 * gamma(x,g) = ((e^(g*x))-1)/(exp(g)-1) 00039 * gamma(x,g) = (log((g*x)+1))/(log(g+1)) 00040 * \ingroup convert */ 00041 enum imGammaFactor 00042 { 00043 IM_GAMMA_LINEAR = 0, 00044 IM_GAMMA_LOGLITE = -10, 00045 IM_GAMMA_LOGHEAVY = -1000, 00046 IM_GAMMA_EXPLITE = 2, 00047 IM_GAMMA_EXPHEAVY = 7 00048 }; 00049 00050 /** Predefined Cast Modes 00051 * \ingroup convert */ 00052 enum imCastMode 00053 { 00054 IM_CAST_MINMAX, /**< scan for min and max values */ 00055 IM_CAST_FIXED, /**< use predefied 0-max values, see \ref color Color Manipulation. */ 00056 IM_CAST_DIRECT /**< direct type cast the value. Only byte and ushort will be cropped. */ 00057 }; 00058 00059 /** Changes the image data type, using a complex2real conversion, 00060 * a gamma factor, and an abssolute mode (modulus). \n 00061 * When demoting the data type the function will scan for min/max values or use fixed values (cast_mode) 00062 * to scale the result according to the destiny range. \n 00063 * Except complex to real that will use only the complex2real conversion. \n 00064 * Images must be of the same size and color mode. \n 00065 * Returns IM_ERR_NONE, IM_ERR_DATA or IM_ERR_COUNTER, see also \ref imErrorCodes. 00066 * See also \ref imComplex2Real, \ref imGammaFactor and \ref imCastMode. 00067 * 00068 * \verbatim im.ConvertDataType(src_image: imImage, dst_image: imImage, cpx2real: number, gamma: number, abssolute: bool, cast_mode: number) -> error: number [in Lua 5] \endverbatim 00069 * \ingroup convert */ 00070 int imConvertDataType(const imImage* src_image, imImage* dst_image, int cpx2real, float gamma, int abssolute, int cast_mode); 00071 00072 /** Converts one color space to another. Images must be of the same size and data type. \n 00073 * CMYK can be converted to RGB only, and it is a very simple conversion. \n 00074 * All colors can be converted to Binary, the non zero gray values are converted to 1. \n 00075 * RGB to Map uses the median cut implementation from the free IJG JPEG software, copyright Thomas G. Lane. \n 00076 * All other color space conversions assume sRGB and CIE definitions. \n 00077 * Returns IM_ERR_NONE, IM_ERR_DATA or IM_ERR_COUNTER, see also \ref imErrorCodes. 00078 * 00079 * \verbatim im.ConvertColorSpace(src_image: imImage, dst_image: imImage) -> error: number [in Lua 5] \endverbatim 00080 * \ingroup convert */ 00081 int imConvertColorSpace(const imImage* src_image, imImage* dst_image); 00082 00083 /** Converts the image to its bitmap equivalent, 00084 * uses \ref imConvertColorSpace and \ref imConvertDataType. \n 00085 * Returns IM_ERR_NONE, IM_ERR_DATA or IM_ERR_COUNTER, see also \ref imErrorCodes. 00086 * See also \ref imComplex2Real, \ref imGammaFactor and \ref imCastMode. 00087 * 00088 * \verbatim im.ConvertToBitmap(src_image: imImage, dst_image: imImage, cpx2real: number, gamma: number, abssolute: bool, cast_mode: number) -> error: number [in Lua 5] \endverbatim 00089 * \ingroup convert */ 00090 int imConvertToBitmap(const imImage* src_image, imImage* dst_image, int cpx2real, float gamma, int abssolute, int cast_mode); 00091 00092 00093 00094 /** \defgroup cnvutil Raw Data Conversion Utilities 00095 * \par 00096 * Utilities for raw data buffers. 00097 * \par 00098 * See \ref im_convert.h 00099 * \ingroup imagerep */ 00100 00101 00102 /** Changes the packing of the data buffer. 00103 * \ingroup cnvutil */ 00104 void imConvertPacking(const void* src_data, void* dst_data, int width, int height, int depth, int data_type, int src_is_packed); 00105 00106 /** Changes in-place a MAP data into a RGB data. The data must have room for the RGB image. \n 00107 * depth can be 3 or 4. count=width*height. \n 00108 * Very usefull for OpenGL applications. 00109 * \ingroup cnvutil */ 00110 void imConvertMapToRGB(unsigned char* data, int count, int depth, int packed, long* palette, int palette_count); 00111 00112 00113 00114 /* Converts a RGB bitmap into a map bitmap using the median cut algorithm. 00115 * Used only "im_convertcolor.cpp" implemented in "im_rgb2map.cpp". 00116 * Internal function kept here because of the compatibility module. 00117 * Will not be at the documentation. */ 00118 int imConvertRGB2Map(int width, int height, 00119 unsigned char *red, unsigned char *green, unsigned char *blue, 00120 unsigned char *map, long *palette, int *palette_count); 00121 00122 00123 #if defined(__cplusplus) 00124 } 00125 #endif 00126 00127 #endif