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.3 2005/12/10 00:54:39 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
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.
00064  *
00065  * \verbatim im.ConvertDataType(src_image: imImage, dst_image: imImage, cpx2real: number, gamma: number, abssolute: number, cast_mode: number) -> error: number [in Lua 5] \endverbatim
00066  * \ingroup convert */
00067 int imConvertDataType(const imImage* src_image, imImage* dst_image, int cpx2real, float gamma, int abssolute, int cast_mode);
00068 
00069 /** Converts one color space to another. Images must be of the same size and data type. \n
00070  * CMYK can be converted to RGB only, and it is a very simple conversion. \n
00071  * All colors can be converted to Binary, the non zero gray values are converted to 1. \n
00072  * RGB to Map uses the median cut implementation from the free IJG JPEG software, copyright Thomas G. Lane. \n
00073  * All other color space conversions assume sRGB and CIE definitions. \n
00074  * Returns IM_ERR_NONE, IM_ERR_DATA or IM_ERR_COUNTER.
00075  *
00076  * \verbatim im.ConvertColorSpace(src_image: imImage, dst_image: imImage) -> error: number [in Lua 5] \endverbatim
00077  * \ingroup convert */
00078 int imConvertColorSpace(const imImage* src_image, imImage* dst_image);
00079 
00080 /** Converts the image to its bitmap equivalent, 
00081  * uses \ref imConvertColorSpace and \ref imConvertDataType. \n
00082  * Returns IM_ERR_NONE, IM_ERR_DATA or IM_ERR_COUNTER.
00083  *
00084  * \verbatim im.ConvertToBitmap(src_image: imImage, dst_image: imImage, cpx2real: number, gamma: number, abssolute: number, cast_mode: number) -> error: number [in Lua 5] \endverbatim
00085  * \ingroup convert */
00086 int imConvertToBitmap(const imImage* src_image, imImage* dst_image, int cpx2real, float gamma, int abssolute, int cast_mode);
00087 
00088 
00089 
00090 /** \defgroup cnvutil Raw Data Conversion Utilities
00091  * \par
00092  * Utilities for raw data buffers.
00093  * \par
00094  * See \ref im_convert.h
00095  * \ingroup imagerep */
00096 
00097 
00098 /** Changes the packing of the data buffer.
00099  * \ingroup cnvutil */
00100 void imConvertPacking(const void* src_data, void* dst_data, int width, int height, int depth, int data_type, int src_is_packed);
00101 
00102 /** Changes in-place a MAP data into a RGB data. The data must have room for the RGB image. \n
00103  * depth can be 3 or 4. count=width*height. \n
00104  * Very usefull for OpenGL applications. 
00105  * \ingroup cnvutil */
00106 void imConvertMapToRGB(unsigned char* data, int count, int depth, int packed, long* palette, int palette_count);
00107                        
00108 
00109 
00110 /* Converts a RGB bitmap into a map bitmap using the median cut algorithm.
00111  * Used only "im_convertcolor.cpp" implemented in "im_rgb2map.cpp". 
00112  * Internal function kept here because of the compatibility module. 
00113  * Will not be at the documentation. */
00114 int imConvertRGB2Map(int width, int height, 
00115               unsigned char *red, unsigned char *green, unsigned char *blue, 
00116               unsigned char *map, long *palette, int *palette_count);
00117 
00118 
00119 #if defined(__cplusplus)
00120 }
00121 #endif
00122 
00123 #endif