summaryrefslogtreecommitdiff
path: root/im/include/im_palette.h
blob: c7ed88c6ce2e3333fbff60367c239481e1c006b9 (plain)
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/** \file
 * \brief Palette Generators
 *
 * See Copyright Notice in im_lib.h
 */

#ifndef __IM_PALETTE_H
#define __IM_PALETTE_H

#if	defined(__cplusplus)
extern "C" {
#endif


/** \defgroup palette Palette Generators
 * \par
 * Creates several standard palettes. The palette is just an array of encoded color values.
 * See also \ref colorutl.
 * \par
 * In Lua, to create a palette you can call im.PaletteCreate.
 * \verbatim im.PaletteCreate([count: number]) -> pal: imPalette [in Lua 5] \endverbatim
 * Default count is 256.
 * IMLua and CDLua palettes are 100% compatible. The IM palette metatable name is "imPalette". \n
 * When converted to a string will return "imPalete(%p)" where %p is replaced by the userdata address.
 * If the palette is already destroyed by im.PaletteDestroy, then it will return also the suffix "-destroyed".
 * \par
 * In Lua, to destroy a palette you can call im.PaletteDestroy.
 * If this function is not called, the palette is destroyed by the garbage collector.
 * \verbatim im.PaletteDestroy(pal: imPalette) [in Lua 5] \endverbatim
 * \par
 * In Lua, array access is enabled so you can do:.
 * \verbatim color = pal[index] \endverbatim
 * \verbatim pal[index] = color \endverbatim
 * \verbatim count = #pal \endverbatim
 * \par
 * See \ref im_palette.h
 * \ingroup util */


/** Searches for the nearest color on the table and returns the color index if successful. 
 * It looks in all palette entries and finds the minimum euclidian square distance. 
 * If the color matches the given color it returns immediately.
 * See also \ref colorutl.
 *
 * \verbatim im.PaletteFindNearest(pal: imPalette, color: lightuserdata) -> index: number [in Lua 5] \endverbatim
 * \ingroup palette */
int imPaletteFindNearest(const long *palette, int palette_count, long color);

/** Searches for the color on the table and returns the color index if successful. 
 * If the tolerance is 0 search for the exact match in the palette else search for the 
 * first color that fits in the tolerance range.
 * See also \ref colorutl.
 *
 * \verbatim im.PaletteFindColor(pal: imPalette, color: lightuserdata, tol: number) -> index: number [in Lua 5] \endverbatim
 * \ingroup palette */
int imPaletteFindColor(const long *palette, int palette_count, long color, unsigned char tol);

/** Creates a palette of gray scale values.
 * The colors are arranged from black to white.
 *
 * \verbatim im.PaletteGray() -> pal: imPalette [in Lua 5] \endverbatim
 * \ingroup palette */
long* imPaletteGray(void);

/** Creates a palette of a gradient of red colors.
 * The colors are arranged from black to pure red.
 *
 * \verbatim im.PaletteRed() -> pal: imPalette [in Lua 5] \endverbatim
 * \ingroup palette */
long* imPaletteRed(void);

/** Creates a palette of a gradient of green colors.
 * The colors are arranged from black to pure green.
 *
 * \verbatim im.PaletteGreen() -> pal: imPalette [in Lua 5] \endverbatim
 * \ingroup palette */
long* imPaletteGreen(void);

/** Creates a palette of a gradient of blue colors.
 * The colors are arranged from black to pure blue.
 *
 * \verbatim im.PaletteBlue() -> pal: imPalette [in Lua 5] \endverbatim
 * \ingroup palette */
long* imPaletteBlue(void);

/** Creates a palette of a gradient of yellow colors.
 * The colors are arranged from black to pure yellow.
 *
 * \verbatim im.PaletteYellow() -> pal: imPalette [in Lua 5] \endverbatim
 * \ingroup palette */
long* imPaletteYellow(void);

/** Creates a palette of a gradient of magenta colors.
 * The colors are arranged from black to pure magenta.
 *
 * \verbatim im.PaletteMagenta() -> pal: imPalette [in Lua 5] \endverbatim
 * \ingroup palette */
long* imPaletteMagenta(void);

/** Creates a palette of a gradient of cian colors.
 * The colors are arranged from black to pure cian.
 *
 * \verbatim im.PaletteCian() -> pal: imPalette [in Lua 5] \endverbatim
 * \ingroup palette */
long* imPaletteCian(void);

/** Creates a palette of rainbow colors.
 * The colors are arranged in the light wave length spectrum order (starting from purple).
 *
 * \verbatim im.PaletteRainbow() -> pal: imPalette [in Lua 5] \endverbatim
 * \ingroup palette */
long* imPaletteRainbow(void);

/** Creates a palette of hues with maximum saturation.
 *
 * \verbatim im.PaletteHues() -> pal: imPalette [in Lua 5] \endverbatim
 * \ingroup palette */
long* imPaletteHues(void);

/** Creates a palette of a gradient of blue colors.
 * The colors are arranged from pure blue to white.
 *
 * \verbatim im.PaletteBlueIce() -> pal: imPalette [in Lua 5] \endverbatim
 * \ingroup palette */
long* imPaletteBlueIce(void);

/** Creates a palette of a gradient from black to white passing trough red and orange.
 *
 * \verbatim im.PaletteHotIron() -> pal: imPalette [in Lua 5] \endverbatim
 * \ingroup palette */
long* imPaletteHotIron(void);

/** Creates a palette of a gradient from black to white passing trough red and yellow.
 *
 * \verbatim im.PaletteBlackBody() -> pal: imPalette [in Lua 5] \endverbatim
 * \ingroup palette */
long* imPaletteBlackBody(void);

/** Creates a palette with high contrast colors.
 *
 * \verbatim im.PaletteHighContrast() -> pal: imPalette [in Lua 5] \endverbatim
 * \ingroup palette */
long* imPaletteHighContrast(void);

/** Creates a palette of an uniform range of colors from black to white.
 *  This is a 2^(2.6) bits per pixel palette.
 *
 * \verbatim im.PaletteUniform() -> pal: imPalette [in Lua 5] \endverbatim
 * \ingroup palette */
long* imPaletteUniform(void);

/** Returns the index of the correspondent RGB color of an uniform palette.
 *
 * \verbatim im.PaletteUniformIndex(color: lightuserdata) -> index: number [in Lua 5] \endverbatim
 * \ingroup palette */
int imPaletteUniformIndex(long color);

/** Returns the index of the correspondent RGB color of an uniform palette.
 * Uses an 8x8 ordered dither to lookup the index in a halftone matrix.
 * The spatial position used by the halftone method.
 *
 * \verbatim im.PaletteUniformIndexHalftoned(color: lightuserdata, x: number, y: number) -> index: number [in Lua 5] \endverbatim
 * \ingroup palette */
int imPaletteUniformIndexHalftoned(long color, int x, int y);


#if defined(__cplusplus)
}
#endif

#endif