Developer World
Spresense SDK Library v3.2.0-ebc0364
rgbcolors.h
1/****************************************************************************
2 * include/nuttx/video/rgbcolors.h
3 * User-friendly RGB color definitions
4 *
5 * Licensed to the Apache Software Foundation (ASF) under one or more
6 * contributor license agreements. See the NOTICE file distributed with
7 * this work for additional information regarding copyright ownership. The
8 * ASF licenses this file to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance with the
10 * License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17 * License for the specific language governing permissions and limitations
18 * under the License.
19 *
20 ****************************************************************************/
21
22#ifndef __INCLUDE_NUTTX_VIDEO_RGBCOLOR_H
23#define __INCLUDE_NUTTX_VIDEO_RGBCOLOR_H
24
25/****************************************************************************
26 * Included Files
27 ****************************************************************************/
28
29/****************************************************************************
30 * Pre-processor Definitions
31 ****************************************************************************/
32
33/* Color Creation and Conversion Macros *************************************/
34
35/* This macro creates RGB24 from 8:8:8 RGB */
36
37#define RGBTO24(r,g,b) \
38 ((uint32_t)((r) & 0xff) << 16 | (uint32_t)((g) & 0xff) << 8 | (uint32_t)((b) & 0xff))
39
40/* And these macros perform the inverse transformation */
41
42#define RGB24RED(rgb) (((rgb) >> 16) & 0xff)
43#define RGB24GREEN(rgb) (((rgb) >> 8) & 0xff)
44#define RGB24BLUE(rgb) ( (rgb) & 0xff)
45
46/* This macro creates RGB16 (5:6:5) from 8:8:8 RGB:
47 *
48 * R[7:3] -> RGB[15:11]
49 * G[7:2] -> RGB[10:5]
50 * B[7:3] -> RGB[4:0]
51 */
52
53#define RGBTO16(r,g,b) \
54 ((((uint16_t)(r) << 8) & 0xf800) | (((uint16_t)(g) << 3) & 0x07e0) | (((uint16_t)(b) >> 3) & 0x001f))
55
56/* And these macros perform the inverse transformation */
57
58#define RGB16RED(rgb) (((rgb) >> 8) & 0xf8)
59#define RGB16GREEN(rgb) (((rgb) >> 3) & 0xfc)
60#define RGB16BLUE(rgb) (((rgb) << 3) & 0xf8)
61
62/* This macro creates RGB8 (3:3:2) from 8:8:8 RGB */
63
64#define RGBTO8(r,g,b) \
65 ((((uint8_t)(r) << 5) & 0xe0) | (((uint8_t)(g) << 2) & 0x1c) | ((uint8_t)(b) & 0x03))
66
67/* And these macros perform the inverse transformation */
68
69#define RGB8RED(rgb) ( (rgb) & 0xe0)
70#define RGB8GREEN(rgb) (((rgb) << 3) & 0xe0)
71#define RGB8BLUE(rgb) (((rgb) << 6) & 0xc0)
72
73/* This macro converts RGB24 (8:8:8) to RGB16 (5:6:5):
74 *
75 * 00000000 RRRRRRRR BBBBBBBB GGGGGGGG -> RRRRRBBB BBBGGGGG
76 */
77
78#define RGB24TO16(rgb24) \
79 (((rgb24 >> 8) & 0xf800) | ((rgb24 >> 5) & 0x07e0) | ((rgb24 >> 3) & 0x001f))
80
81/* This macro converts RGB16 (5:6:5) to RGB24 (8:8:8):
82 *
83 * RRRRRBBB BBBGGGGG -> 00000000 RRRRRRRR BBBBBBBB GGGGGGGG
84 */
85
86#define RGB16TO24(rgb16) \
87 (((rgb16 & 0xf800) << 8) | ((rgb16 & 0x07e0) << 5) | ((rgb16 & 0x001f) << 3))
88
89/* Standard Color Definitions ***********************************************/
90
91/* RGB24-888: 00000000 RRRRRRRR GGGGGGGG BBBBBBBB */
92
93#define RGB24_BLACK 0x00000000
94#define RGB24_WHITE 0x00ffffff
95
96#define RGB24_BLUE 0x000000ff
97#define RGB24_GREEN 0x0000ff00
98#define RGB24_RED 0x00ff0000
99
100#define RGB24_NAVY 0x00000080
101#define RGB24_DARKBLUE 0x0000008b
102#define RGB24_DARKGREEN 0x00006400
103#define RGB24_DARKCYAN 0x00008b8b
104#define RGB24_CYAN 0x0000ffff
105#define RGB24_TURQUOISE 0x0040e0d0
106#define RGB24_INDIGO 0x004b0082
107#define RGB24_DARKRED 0x00800000
108#define RGB24_OLIVE 0x00808000
109#define RGB24_GRAY 0x00808080
110#define RGB24_SKYBLUE 0x0087ceeb
111#define RGB24_BLUEVIOLET 0x008a2be2
112#define RGB24_LIGHTGREEN 0x0090ee90
113#define RGB24_DARKVIOLET 0x009400d3
114#define RGB24_YELLOWGREEN 0x009acd32
115#define RGB24_BROWN 0x00a52a2a
116#define RGB24_DARKGRAY 0x00a9a9a9
117#define RGB24_SIENNA 0x00a0522d
118#define RGB24_LIGHTBLUE 0x00add8e6
119#define RGB24_GREENYELLOW 0x00adff2f
120#define RGB24_SILVER 0x00c0c0c0
121#define RGB24_LIGHTGREY 0x00d3d3d3
122#define RGB24_LIGHTCYAN 0x00e0ffff
123#define RGB24_VIOLET 0x00ee82ee
124#define RGB24_AZUR 0x00f0ffff
125#define RGB24_BEIGE 0x00f5f5dc
126#define RGB24_MAGENTA 0x00ff00ff
127#define RGB24_TOMATO 0x00ff6347
128#define RGB24_GOLD 0x00ffd700
129#define RGB24_ORANGE 0x00ffa500
130#define RGB24_SNOW 0x00fffafa
131#define RGB24_YELLOW 0x00ffff00
132
133/* RGB16-565: RRRRRGGG GGGBBBBB */
134
135#define RGB16_BLACK 0x0000
136#define RGB16_WHITE 0xffff
137
138#define RGB16_BLUE 0x001f
139#define RGB16_GREEN 0x07e0
140#define RGB16_RED 0xf800
141
142#define RGB16_NAVY 0x0010
143#define RGB16_DARKBLUE 0x0011
144#define RGB16_DARKGREEN 0x0320
145#define RGB16_DARKCYAN 0x0451
146#define RGB16_CYAN 0x07ff
147#define RGB16_TURQUOISE 0x471a
148#define RGB16_INDIGO 0x4810
149#define RGB16_DARKRED 0x8000
150#define RGB16_OLIVE 0x8400
151#define RGB16_GRAY 0x8410
152#define RGB16_SKYBLUE 0x867d
153#define RGB16_BLUEVIOLET 0x895c
154#define RGB16_LIGHTGREEN 0x9772
155#define RGB16_DARKVIOLET 0x901a
156#define RGB16_YELLOWGREEN 0x9e66
157#define RGB16_BROWN 0xa145
158#define RGB16_DARKGRAY 0xad55
159#define RGB16_SIENNA 0xa285
160#define RGB16_LIGHTBLUE 0xaedc
161#define RGB16_GREENYELLOW 0xafe5
162#define RGB16_SILVER 0xc618
163#define RGB16_LIGHTGREY 0xd69a
164#define RGB16_LIGHTCYAN 0xe7ff
165#define RGB16_VIOLET 0xec1d
166#define RGB16_AZUR 0xf7ff
167#define RGB16_BEIGE 0xf7bb
168#define RGB16_MAGENTA 0xf81f
169#define RGB16_TOMATO 0xfb08
170#define RGB16_GOLD 0xfea0
171#define RGB16_ORANGE 0xfd20
172#define RGB16_SNOW 0xffdf
173#define RGB16_YELLOW 0xffe0
174
175/* RGB12-444: RRRR GGGGBBBB */
176
177#define RGB12_BLACK 0x0000
178#define RGB12_WHITE 0x0fff
179
180#define RGB12_BLUE 0x000f
181#define RGB12_GREEN 0x00f0
182#define RGB12_RED 0x0f00
183
184#define RGB12_NAVY 0x0008
185#define RGB12_DARKBLUE 0x0009
186#define RGB12_DARKGREEN 0x0060
187#define RGB12_DARKCYAN 0x0099
188#define RGB12_CYAN 0x00ff
189#define RGB12_TURQUOISE 0x04ed
190#define RGB12_INDIGO 0x0508
191#define RGB12_DARKRED 0x0800
192#define RGB12_OLIVE 0x0880
193#define RGB12_GRAY 0x0888
194#define RGB12_SKYBLUE 0x08df
195#define RGB12_BLUEVIOLET 0x093e
196#define RGB12_LIGHTGREEN 0x09f9
197#define RGB12_DARKVIOLET 0x090d
198#define RGB12_YELLOWGREEN 0x0ad3
199#define RGB12_BROWN 0x0a33
200#define RGB12_DARKGRAY 0x0bbb
201#define RGB12_SIENNA 0x0a53
202#define RGB12_LIGHTBLUE 0x0bee
203#define RGB12_GREENYELLOW 0x0bf3
204#define RGB12_SILVER 0x0ccc
205#define RGB12_LIGHTGREY 0x0ddd
206#define RGB12_LIGHTCYAN 0x0eff
207#define RGB12_VIOLET 0x0f8f
208#define RGB12_AZUR 0x0fff
209#define RGB12_BEIGE 0x0ffe
210#define RGB12_MAGENTA 0x0f0f
211#define RGB12_TOMATO 0x0f64
212#define RGB12_GOLD 0x0fd0
213#define RGB12_ORANGE 0x0fa0
214#define RGB12_SNOW 0x0fff
215#define RGB12_YELLOW 0x0ff0
216
217/* RGB8-332: RRRGGGBB
218 * (really not enough color resolution for the following)
219 */
220
221#define RGB8_BLACK 0x00
222#define RGB8_WHITE 0xff
223
224#define RGB8_BLUE 0x03
225#define RGB8_GREEN 0x1c
226#define RGB8_RED 0xe0
227#define RGB8_NAVY 0x02
228#define RGB8_DARKBLUE 0x02
229#define RGB8_DARKGREEN 0x0c
230#define RGB8_DARKCYAN 0x16
231#define RGB8_CYAN 0x1f
232#define RGB8_TURQUOISE 0x5f
233#define RGB8_INDIGO 0x62
234#define RGB8_DARKRED 0x80
235#define RGB8_OLIVE 0x90
236#define RGB8_GRAY 0x92
237#define RGB8_SKYBLUE 0x9f
238#define RGB8_BLUEVIOLET 0xab
239#define RGB8_LIGHTGREEN 0xbe
240#define RGB8_DARKVIOLET 0x93
241#define RGB8_YELLOWGREEN 0x9d
242#define RGB8_BROWN 0xa9
243#define RGB8_DARKGRAY 0xdb
244#define RGB8_SIENNA 0xa9
245#define RGB8_LIGHTBLUE 0xdf
246#define RGB8_GREENYELLOW 0xdd
247#define RGB8_SILVER 0xd9
248#define RGB8_LIGHTGREY 0xd9
249#define RGB8_LIGHTCYAN 0xff
250#define RGB8_VIOLET 0xf3
251#define RGB8_AZUR 0xff
252#define RGB8_BEIGE 0xff
253#define RGB8_MAGENTA 0xed
254#define RGB8_TOMATO 0xfc
255#define RGB8_GOLD 0xfc
256#define RGB8_ORANGE 0xf8
257#define RGB8_SNOW 0xff
258#define RGB8_YELLOW 0xfc
259
260/****************************************************************************
261 * Public Types
262 ****************************************************************************/
263
264#ifndef __ASSEMBLY__
265
266/* This is a generic representation of an RGB color */
267
269{
270 uint8_t r; /* Red value */
271 uint8_t b; /* Blue value */
272 uint8_t g; /* Green value */
273};
274
275/* This is a generic representation of an RGB color with ALPHA */
276
278{
279 uint8_t a; /* Alpha value (transparency) */
280 uint8_t r; /* Red value */
281 uint8_t b; /* Blue value */
282 uint8_t g; /* Green value */
283};
284
285/****************************************************************************
286 * Public Data
287 ****************************************************************************/
288
289#ifdef __cplusplus
290#define EXTERN extern "C"
291extern "C"
292{
293#else
294#define EXTERN extern
295#endif
296
297/****************************************************************************
298 * Public Function Prototypes
299 ****************************************************************************/
300
301#undef EXTERN
302#ifdef __cplusplus
303}
304#endif
305
306#endif /* __ASSEMBLY__ */
307#endif /* __INCLUDE_NUTTX_VIDEO_RGBCOLOR_H */
Definition: rgbcolors.h:278
Definition: rgbcolors.h:269