root / hw / pixel_ops.h @ 3b1fd90e
History | View | Annotate | Download (1.7 kB)
1 | ece096bb | blueswir1 | static inline unsigned int rgb_to_pixel8(unsigned int r, unsigned int g, |
---|---|---|---|
2 | ece096bb | blueswir1 | unsigned int b) |
3 | ece096bb | blueswir1 | { |
4 | ece096bb | blueswir1 | return ((r >> 5) << 5) | ((g >> 5) << 2) | (b >> 6); |
5 | ece096bb | blueswir1 | } |
6 | ece096bb | blueswir1 | |
7 | ece096bb | blueswir1 | static inline unsigned int rgb_to_pixel15(unsigned int r, unsigned int g, |
8 | ece096bb | blueswir1 | unsigned int b) |
9 | ece096bb | blueswir1 | { |
10 | ece096bb | blueswir1 | return ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3); |
11 | ece096bb | blueswir1 | } |
12 | ece096bb | blueswir1 | |
13 | ece096bb | blueswir1 | static inline unsigned int rgb_to_pixel15bgr(unsigned int r, unsigned int g, |
14 | ece096bb | blueswir1 | unsigned int b) |
15 | ece096bb | blueswir1 | { |
16 | ece096bb | blueswir1 | return ((b >> 3) << 10) | ((g >> 3) << 5) | (r >> 3); |
17 | ece096bb | blueswir1 | } |
18 | ece096bb | blueswir1 | |
19 | ece096bb | blueswir1 | static inline unsigned int rgb_to_pixel16(unsigned int r, unsigned int g, |
20 | ece096bb | blueswir1 | unsigned int b) |
21 | ece096bb | blueswir1 | { |
22 | ece096bb | blueswir1 | return ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3); |
23 | ece096bb | blueswir1 | } |
24 | ece096bb | blueswir1 | |
25 | ece096bb | blueswir1 | static inline unsigned int rgb_to_pixel16bgr(unsigned int r, unsigned int g, |
26 | ece096bb | blueswir1 | unsigned int b) |
27 | ece096bb | blueswir1 | { |
28 | ece096bb | blueswir1 | return ((b >> 3) << 11) | ((g >> 2) << 5) | (r >> 3); |
29 | ece096bb | blueswir1 | } |
30 | ece096bb | blueswir1 | |
31 | e27f01ef | balrog | static inline unsigned int rgb_to_pixel24(unsigned int r, unsigned int g, |
32 | e27f01ef | balrog | unsigned int b) |
33 | e27f01ef | balrog | { |
34 | e27f01ef | balrog | return (r << 16) | (g << 8) | b; |
35 | e27f01ef | balrog | } |
36 | e27f01ef | balrog | |
37 | e27f01ef | balrog | static inline unsigned int rgb_to_pixel24bgr(unsigned int r, unsigned int g, |
38 | e27f01ef | balrog | unsigned int b) |
39 | e27f01ef | balrog | { |
40 | e27f01ef | balrog | return (b << 16) | (g << 8) | r; |
41 | e27f01ef | balrog | } |
42 | e27f01ef | balrog | |
43 | ece096bb | blueswir1 | static inline unsigned int rgb_to_pixel32(unsigned int r, unsigned int g, |
44 | ece096bb | blueswir1 | unsigned int b) |
45 | ece096bb | blueswir1 | { |
46 | ece096bb | blueswir1 | return (r << 16) | (g << 8) | b; |
47 | ece096bb | blueswir1 | } |
48 | ece096bb | blueswir1 | |
49 | ece096bb | blueswir1 | static inline unsigned int rgb_to_pixel32bgr(unsigned int r, unsigned int g, |
50 | ece096bb | blueswir1 | unsigned int b) |
51 | ece096bb | blueswir1 | { |
52 | ece096bb | blueswir1 | return (b << 16) | (g << 8) | r; |
53 | ece096bb | blueswir1 | } |