-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrgb.h
50 lines (42 loc) · 781 Bytes
/
rgb.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
/*
* Rgb.h
*
* Created on: 29.11.2010
*
* author: rofl0r
*
* License: LGPL 2.1+ with static linking exception
*
*/
#ifndef RGB_H_
#define RGB_H_
#include <stdint.h>
#include "endianness.h"
typedef union {
struct {
#ifdef IS_LITTLE_ENDIAN
unsigned char a;
unsigned char b;
unsigned char g;
unsigned char r;
#else
unsigned char r;
unsigned char g;
unsigned char b;
unsigned char a;
#endif
};
uint32_t asInt;
} rgb_t;
typedef struct {
rgb_t bgcolor;
rgb_t fgcolor;
} rgb_tuple;
#ifdef IS_LITTLE_ENDIAN
#define RGB(x,y,z) ((rgb_t) {{0, z, y, x}})
#else
#define RGB(x,y,z) ((rgb_t) {{x, y, z, 0}})
#endif
#define RGB_INIT(R,G,B) {.r = R, .g = G, .b = B, .a = 0}
#define RGBA_INIT(R,G,B,A) {.r = R, .g = G, .b = B, .a = A}
#endif /* RGB_H_ */