forked from kexecboot/kexecboot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rgb.h
65 lines (52 loc) · 1.56 KB
/
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* kexecboot - A kexec based bootloader
*
* Copyright (c) 2008-2011 Yuri Bushmelev <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#ifndef _HAVE_RGB_H
#define _HAVE_RGB_H
#include "config.h"
#ifdef USE_FBMENU
#include "util.h"
/* RGB ordering */
enum RGBMode {
BGR,
RGB,
GENERIC
};
/* Color packed into uint32_t (RGBA) */
typedef uint32_t kx_rgba;
/* Color component */
typedef uint8_t kx_ccomp;
/* Pack color components into uint32_t */
#define comp2rgba(r,g,b,a) \
((kx_rgba)(r)<<24|(kx_rgba)(g)<<16|(kx_rgba)(b)<<8|(kx_rgba)(a))
/* Get alpha-channel from rgba color */
#define rgba2a(rgba) \
((kx_rgba)(rgba) & (kx_rgba)0x000000FF)
/* Named color structure */
typedef struct {
char *name;
kx_rgba rgba;
} kx_named_color;
/* Convert RGBA uint32 to red/green/blue/alpha components */
inline void
rgba2comp(kx_rgba rgba, kx_ccomp *red, kx_ccomp *green,
kx_ccomp *blue, kx_ccomp *alpha);
/* Convert hex rgb color to rgba color */
kx_rgba hex2rgba(char *hex);
/* Convert color name to rgba color */
kx_rgba cname2rgba(char *cname);
#endif /* USE_FBMENU */
#endif /* HAVE_RGB_H */