-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcolourmap.h
58 lines (37 loc) · 1.19 KB
/
colourmap.h
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
/** @file colourmap.h
@author M. P. Hayes, UCECE
@date 3 July 2007
@brief
*/
#ifndef COLOURMAP_H
#define COLOURMAP_H
#ifdef __cplusplus
extern "C" {
#endif
#include "config.h"
/* The only constraints on the colourmap is that the first entry is
for black and the last entry is white. We could pack the colourmap
entries to save memory by changing the definition of
COLOURMAP_ENTRY. With 5 bits per colour a colourmap entry could be
packed into 16 bits rather than the current 24 bits. */
/* COLOURMAP_SCALE needs to be defined by the user. */
#ifndef COLOURMAP_R_WEIGHT
#define COLOURMAP_R_WEIGHT 1.0
#endif
#ifndef COLOURMAP_G_WEIGHT
#define COLOURMAP_G_WEIGHT 1.0
#endif
#ifndef COLOURMAP_B_WEIGHT
#define COLOURMAP_B_WEIGHT 1.0
#endif
#define COLOURMAP_R(X) ((X) * COLOURMAP_R_WEIGHT * COLOURMAP_SCALE + 0.5)
#define COLOURMAP_G(X) ((X) * COLOURMAP_G_WEIGHT * COLOURMAP_SCALE + 0.5)
#define COLOURMAP_B(X) ((X) * COLOURMAP_B_WEIGHT * COLOURMAP_SCALE + 0.5)
#define COLOURMAP_ENTRY(R, G, B) \
{COLOURMAP_R(R), COLOURMAP_G(G), COLOURMAP_B(B)},
typedef uint8_t colourmap_elt_t;
typedef colourmap_elt_t colourmap_t[3];
#ifdef __cplusplus
}
#endif
#endif