1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
/** \file
* \brief Image Conversion
*
* See Copyright Notice in im_lib.h
*/
#ifndef __IM_CONVERT_H
#define __IM_CONVERT_H
#include "im_image.h"
#if defined(__cplusplus)
extern "C" {
#endif
/** \defgroup convert Image Conversion
* \par
* Converts one type of image into another. Can convert between color modes
* and between data types.
* \par
* See \ref im_convert.h
* \ingroup imgclass */
/** Complex to real conversions
* \ingroup convert */
enum imComplex2Real
{
IM_CPX_REAL,
IM_CPX_IMAG,
IM_CPX_MAG,
IM_CPX_PHASE
};
/** Predefined Gamma factors. Gamma can be any real number.
* When gamma<0 use logarithmic, when gamma>0 use exponential.
* gamma(x,g) = ((e^(g*x))-1)/(exp(g)-1)
* gamma(x,g) = (log((g*x)+1))/(log(g+1))
* \ingroup convert */
enum imGammaFactor
{
IM_GAMMA_LINEAR = 0,
IM_GAMMA_LOGLITE = -10,
IM_GAMMA_LOGHEAVY = -1000,
IM_GAMMA_EXPLITE = 2,
IM_GAMMA_EXPHEAVY = 7
};
/** Predefined Cast Modes
* \ingroup convert */
enum imCastMode
{
IM_CAST_MINMAX, /**< scan for min and max values */
IM_CAST_FIXED, /**< use predefied 0-max values, see \ref color Color Manipulation. */
IM_CAST_DIRECT /**< direct type cast the value. Only byte and ushort will be cropped. */
};
/** Changes the image data type, using a complex2real conversion,
* a gamma factor, and an abssolute mode (modulus). \n
* When demoting the data type the function will scan for min/max values or use fixed values (cast_mode)
* to scale the result according to the destiny range. \n
* Except complex to real that will use only the complex2real conversion. \n
* Images must be of the same size and color mode. \n
* Returns IM_ERR_NONE, IM_ERR_DATA or IM_ERR_COUNTER, see also \ref imErrorCodes.
* See also \ref imComplex2Real, \ref imGammaFactor and \ref imCastMode.
*
* \verbatim im.ConvertDataType(src_image: imImage, dst_image: imImage, cpx2real: number, gamma: number, abssolute: boolean, cast_mode: number) -> error: number [in Lua 5] \endverbatim
* \ingroup convert */
int imConvertDataType(const imImage* src_image, imImage* dst_image, int cpx2real, float gamma, int abssolute, int cast_mode);
/** Converts one color space to another. Images must be of the same size and data type. \n
* CMYK can be converted to RGB only, and it is a very simple conversion. \n
* All colors can be converted to Binary, the non zero gray values are converted to 1. \n
* RGB to Map uses the median cut implementation from the free IJG JPEG software, copyright Thomas G. Lane. \n
* All other color space conversions assume sRGB and CIE definitions. \n
* Returns IM_ERR_NONE, IM_ERR_DATA or IM_ERR_COUNTER, see also \ref imErrorCodes.
*
* \verbatim im.ConvertColorSpace(src_image: imImage, dst_image: imImage) -> error: number [in Lua 5] \endverbatim
* \ingroup convert */
int imConvertColorSpace(const imImage* src_image, imImage* dst_image);
/** Converts the image to its bitmap equivalent,
* uses \ref imConvertColorSpace and \ref imConvertDataType. \n
* Returns IM_ERR_NONE, IM_ERR_DATA or IM_ERR_COUNTER, see also \ref imErrorCodes.
* See also \ref imComplex2Real, \ref imGammaFactor and \ref imCastMode.
*
* \verbatim im.ConvertToBitmap(src_image: imImage, dst_image: imImage, cpx2real: number, gamma: number, abssolute: boolean, cast_mode: number) -> error: number [in Lua 5] \endverbatim
* \ingroup convert */
int imConvertToBitmap(const imImage* src_image, imImage* dst_image, int cpx2real, float gamma, int abssolute, int cast_mode);
/** Returns an OpenGL compatible data buffer. Also returns the correspondant pixel format. \n
* The memory allocated is stored in the attribute "GLDATA" with BYTE type. And it will exists while the image exists. \n
* It can also be cleared setting the attribute to NULL. \n
* MAP images are converted to RGB, and BINARY images are converted to GRAY.
* Alpha channel is considered and Transparency* attributes are converted to alpha channel.
* So calculate depth from glformat, not from image depth.
*
* \verbatim image:GetOpenGLData() -> gldata: userdata, glformat: number [in Lua 5] \endverbatim
* \ingroup convert */
void* imImageGetOpenGLData(const imImage* image, int *glformat);
/** \defgroup cnvutil Raw Data Conversion Utilities
* \par
* Utilities for raw data buffers.
* \par
* See \ref im_convert.h
* \ingroup imagerep */
/** Changes the packing of the data buffer. Both must have the same depth.
* \ingroup cnvutil */
void imConvertPacking(const void* src_data, void* dst_data, int width, int height, int depth, int data_type, int src_is_packed);
/** Changes in-place a MAP data into a RGB data. The data must have room for the RGB image. \n
* depth can be 3 or 4. count=width*height. \n
* \ingroup cnvutil */
void imConvertMapToRGB(unsigned char* data, int count, int depth, int packed, long* palette, int palette_count);
/* Converts a RGB bitmap into a map bitmap using the median cut algorithm.
* Used only "im_convertcolor.cpp" implemented in "im_rgb2map.cpp".
* Internal function kept here because of the compatibility module.
* Will not be at the documentation. */
int imConvertRGB2Map(int width, int height,
unsigned char *red, unsigned char *green, unsigned char *blue,
unsigned char *map, long *palette, int *palette_count);
#if defined(__cplusplus)
}
#endif
#endif
|