IM: im_convert.h Source File

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