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