version 2.8
gdisp_colors.h
Go to the documentation of this file.
1 /*
2  * This file is subject to the terms of the GFX License. If a copy of
3  * the license was not distributed with this file, you can obtain one at:
4  *
5  * http://ugfx.org/license.html
6  */
7 
8 /**
9  * @file src/gdisp/gdisp_colors.h
10  *
11  * @defgroup Colors Colors
12  * @ingroup GDISP
13  *
14  * @brief Sub-Module for color handling.
15  *
16  * @{
17  */
18 
19 #ifndef _GDISP_COLORS_H
20 #define _GDISP_COLORS_H
21 
22 #include "../../gfx.h"
23 
24 #if GFX_USE_GDISP || defined(__DOXYGEN__)
25 
26 typedef uint16_t colorformat;
27 
28 /**
29  * @name Color system masks
30  *
31  * @details For pixel formats we do some assignment of codes to enable
32  * format auto-calculation. (Undocumented).
33  * 0x2RGB TRUECOLOR RGB format, R = red bits, G = green bits, B = blue bits
34  * 0x3RGB TRUECOLOR BGR format, R = red bits, G = green bits, B = blue bits
35  * 0x40XX GRAYSCALE XX = bits
36  * 0x60XX PALLETTE XX = bits
37  * 0x8XXX CUSTOM format.
38  * @{
39  */
40 #define GDISP_COLORSYSTEM_MASK 0xF000
41 #define GDISP_COLORSYSTEM_RGB 0x2000
42 #define GDISP_COLORSYSTEM_BGR 0x3000
43 /** @} */
44 
45 /**
46  * @name Color Type Constants
47  * @{
48  */
49 #define GDISP_COLORSYSTEM_TRUECOLOR 0x2000
50 #define GDISP_COLORSYSTEM_GRAYSCALE 0x4000
51 #define GDISP_COLORSYSTEM_PALETTE 0x6000
52 /** @} */
53 
54 /**
55  * @name Pixel Format Constants
56  * @{
57  */
58 #define GDISP_PIXELFORMAT_MONO (GDISP_COLORSYSTEM_GRAYSCALE|0x0001)
59 #define GDISP_PIXELFORMAT_GRAY4 (GDISP_COLORSYSTEM_GRAYSCALE|0x0002)
60 #define GDISP_PIXELFORMAT_GRAY16 (GDISP_COLORSYSTEM_GRAYSCALE|0x0004)
61 #define GDISP_PIXELFORMAT_GRAY256 (GDISP_COLORSYSTEM_GRAYSCALE|0x0008)
62 #define GDISP_PIXELFORMAT_RGB565 (GDISP_COLORSYSTEM_RGB|0x0565)
63 #define GDISP_PIXELFORMAT_BGR565 (GDISP_COLORSYSTEM_BGR|0x0565)
64 #define GDISP_PIXELFORMAT_RGB555 (GDISP_COLORSYSTEM_RGB|0x0555)
65 #define GDISP_PIXELFORMAT_BGR555 (GDISP_COLORSYSTEM_BGR|0x0555)
66 #define GDISP_PIXELFORMAT_RGB888 (GDISP_COLORSYSTEM_RGB|0x0888)
67 #define GDISP_PIXELFORMAT_BGR888 (GDISP_COLORSYSTEM_BGR|0x0888)
68 #define GDISP_PIXELFORMAT_RGB444 (GDISP_COLORSYSTEM_RGB|0x0444)
69 #define GDISP_PIXELFORMAT_BGR444 (GDISP_COLORSYSTEM_BGR|0x0444)
70 #define GDISP_PIXELFORMAT_RGB332 (GDISP_COLORSYSTEM_RGB|0x0332)
71 #define GDISP_PIXELFORMAT_BGR332 (GDISP_COLORSYSTEM_BGR|0x0233)
72 #define GDISP_PIXELFORMAT_RGB233 (GDISP_COLORSYSTEM_RGB|0x0233)
73 #define GDISP_PIXELFORMAT_BGR233 (GDISP_COLORSYSTEM_BGR|0x0332)
74 #define GDISP_PIXELFORMAT_RGB666 (GDISP_COLORSYSTEM_RGB|0x0666)
75 #define GDISP_PIXELFORMAT_BGR666 (GDISP_COLORSYSTEM_BGR|0x0666)
76 #define GDISP_PIXELFORMAT_ERROR 0x0000
77 /** @} */
78 
79 /**
80  * @name Some basic colors
81  * @{
82  */
83 #define White HTML2COLOR(0xFFFFFF)
84 #define Black HTML2COLOR(0x000000)
85 #define Gray HTML2COLOR(0x808080)
86 #define Grey Gray
87 #define Blue HTML2COLOR(0x0000FF)
88 #define Red HTML2COLOR(0xFF0000)
89 #define Fuchsia HTML2COLOR(0xFF00FF)
90 #define Magenta Fuchsia
91 #define Green HTML2COLOR(0x008000)
92 #define Yellow HTML2COLOR(0xFFFF00)
93 #define Aqua HTML2COLOR(0x00FFFF)
94 #define Cyan Aqua
95 #define Lime HTML2COLOR(0x00FF00)
96 #define Maroon HTML2COLOR(0x800000)
97 #define Navy HTML2COLOR(0x000080)
98 #define Olive HTML2COLOR(0x808000)
99 #define Purple HTML2COLOR(0x800080)
100 #define Silver HTML2COLOR(0xC0C0C0)
101 #define Teal HTML2COLOR(0x008080)
102 #define Orange HTML2COLOR(0xFFA500)
103 #define Pink HTML2COLOR(0xFFC0CB)
104 #define SkyBlue HTML2COLOR(0x87CEEB)
105 /** @} */
106 
107 #if defined(__DOXYGEN__)
108  /**
109  * @brief The color system (grayscale, palette or truecolor)
110  */
111  #define COLOR_SYSTEM GDISP_COLORSYSTEM_TRUECOLOR
112 
113  /**
114  * @brief The number of bits in a color value
115  */
116  #define COLOR_BITS 16
117 
118  /**
119  * @name Color bits
120  * @brief The number of bits for each of red, green and blue
121  * @{
122  */
123  #define COLOR_BITS_R 5
124  #define COLOR_BITS_G 6
125  #define COLOR_BITS_B 5
126  /** @} */
127 
128  /**
129  * @name Color bit shifts
130  * @brief The number of bits to shift each of red, green and blue to put it in the correct place in the color
131  * @{
132  */
133  #define COLOR_SHIFT_R 11
134  #define COLOR_SHIFT_G 5
135  #define COLOR_SHIFT_B 0
136  /** @} */
137 
138  /**
139  * @brief Does the color need masking to remove invalid bits
140  */
141  #define COLOR_NEEDS_MASK FALSE
142 
143  /**
144  * @brief If the color needs masking to remove invalid bits, this is the mask
145  */
146  #define COLOR_MASK 0xFFFF
147 
148  /**
149  * @brief The color type
150  */
151  #define COLOR_TYPE uint16_t
152 
153  /**
154  * @brief The number of bits in the color type (not necessarily the same as COLOR_BITS).
155  */
156  #define COLOR_TYPE_BITS 16
157 
158  /**
159  * @brief Convert a luminance (0 to 255) into a color value.
160  * @note The word "Luma" is used instead of grey or gray due to the spelling ambiguities of the word grey
161  * @note This is not a weighted luminance conversion in the color tv style.
162  * @note @p LUMA2COLOR() uses a linear conversion (0.33R + 0.33G + 0.33B). Note this is different to color
163  * tv luminance (0.26126R + 0.7152G + 0.0722B), digital tv luminance of (0.299R + 0.587G + 0.114B), or
164  * @p LUMA_OF() which uses (0.25R + 0.5G + 0.25B).
165  */
166  #define LUMA2COLOR(l) ((color_t)((((l) & 0xF8)<<8) | (((l) & 0xFC)<<3) | (((l) & 0xF8)>>3)))
167 
168  /**
169  * @brief Convert red, green, blue (each 0 to 255) into a color value.
170  */
171  #define RGB2COLOR(r,g,b) ((color_t)((((r) & 0xF8)<<8) | (((g) & 0xFC)<<3) | (((b) & 0xF8)>>3)))
172 
173  /**
174  * @brief Convert a 6 digit HTML code (hex) into a color value.
175  */
176  #define HTML2COLOR(h) ((color_t)((((h) & 0xF80000)>>8) | (((h) & 0x00FC00)>>5) | (((h) & 0x0000F8)>>3)))
177 
178  /**
179  * @name Extraction macros (quick)
180  *
181  * @brief Extract the luma/red/green/blue component (0 to 255) of a color value.
182  * @note This uses quick and dirty bit shifting. If you want more exact colors
183  * use @p EXACT_RED_OF() etc which uses multiplies and divides. For constant
184  * colors using @p EXACT_RED_OF() is no more expensive because the compiler
185  * evaluates the arithmetic.
186  * @note @p LUMA_OF() returns a roughly weighted luminance (0.25R + 0.5G + 0.25B). Note this is
187  * different to @p LUMA2COLOR() which uses a linear conversion (0.33R + 0.33G + 0.33B) and
188  * color tv luminance of (0.26126R + 0.7152G + 0.0722B) and digital tv luminance of (0.299R + 0.587G + 0.114B).
189  * @note A 5 bit color component maximum value (0x1F) converts to 0xF8 (slightly off-color)
190  * @{
191  */
192  #define LUMA_OF(c) ((RED_OF(c)+((uint16_t)GREEN_OF(c)<<1)+BLUE_OF(c))>>2)
193  #define RED_OF(c) (((c) & 0xF800)>>8)
194  #define GREEN_OF(c) (((c)&0x007E)>>3)
195  #define BLUE_OF(c) (((c)&0x001F)<<3)
196  /** @} */
197 
198  /**
199  * @name Extraction macros (precise)
200  *
201  * @brief Extract the exact luma/red/green/blue component (0 to 255) of a color value.
202  * @note This uses multiplies and divides rather than bit shifting.
203  * This gives exact equivalent colors at the expense of more cpu intensive
204  * operations. Note for constants this is no more expensive than @p REF_OF()
205  * because the compiler evaluates the arithmetic.
206  * @note @p EXACT_LUMA_OF() returns a roughly weighted luminance (0.25R + 0.5G + 0.25B). Note this is
207  * different to @p LUMA2COLOR() which uses a linear conversion (0.33R + 0.33G + 0.33B) and
208  * color tv luminance of (0.26126R + 0.7152G + 0.0722B) and digital tv luminance of (0.299R + 0.587G + 0.114B).
209  * @note A 5 bit color component maximum value (0x1F) converts to 0xFF (the true equivalent color)
210  * @{
211  */
212  #define EXACT_LUMA_OF(c) ((EXACT_RED_OF(c)+((uint16_t)EXACT_GREEN_OF(c)<<1)+EXACT_BLUE_OF(c))>>2)
213  #define EXACT_RED_OF(c) (((((c)>>11)&0x1F)*255)/31)
214  #define EXACT_GREEN_OF(c) (((((c)>>5)&0x3F)*255)/63)
215  #define EXACT_BLUE_OF(c) (((((c)>>0)&0x1F)*255)/31)
216  /** @} */
217 #endif
218 
219 /*
220  * We use this big mess of macros to calculate all the components
221  * to prevent user errors in the color definitions. It greatly simplifies
222  * the above definitions and ensures a consistent implementation.
223  */
224 
225 //-------------------------
226 // True-Color color system
227 //-------------------------
228 #if GDISP_PIXELFORMAT & GDISP_COLORSYSTEM_TRUECOLOR
229  #define COLOR_SYSTEM GDISP_COLORSYSTEM_TRUECOLOR
230 
231  // Calculate the number of bits
232  #define COLOR_BITS_R ((GDISP_PIXELFORMAT>>8) & 0x0F)
233  #define COLOR_BITS_G ((GDISP_PIXELFORMAT>>4) & 0x0F)
234  #define COLOR_BITS_B ((GDISP_PIXELFORMAT>>0) & 0x0F)
235  #define COLOR_BITS (COLOR_BITS_R + COLOR_BITS_G + COLOR_BITS_B)
236 
237  // From the number of bits determine COLOR_TYPE, COLOR_TYPE_BITS and masking
238  #if COLOR_BITS <= 8
239  #define COLOR_TYPE uint8_t
240  #define COLOR_TYPE_BITS 8
241  #elif COLOR_BITS <= 16
242  #define COLOR_TYPE uint16_t
243  #define COLOR_TYPE_BITS 16
244  #elif COLOR_BITS <= 32
245  #define COLOR_TYPE uint32_t
246  #define COLOR_TYPE_BITS 32
247  #else
248  #error "GDISP: Cannot define color types with more than 32 bits"
249  #endif
250  #if COLOR_TYPE_BITS == COLOR_BITS
251  #define COLOR_NEEDS_MASK FALSE
252  #else
253  #define COLOR_NEEDS_MASK TRUE
254  #endif
255  #define COLOR_MASK() ((1 << COLOR_BITS)-1)
256 
257  // Calculate the component bit shifts
258  #if (GDISP_PIXELFORMAT & GDISP_COLORSYSTEM_MASK) == GDISP_COLORSYSTEM_RGB
259  #define COLOR_SHIFT_R (COLOR_BITS_B+COLOR_BITS_G)
260  #define COLOR_SHIFT_G COLOR_BITS_B
261  #define COLOR_SHIFT_B 0
262  #else
263  #define COLOR_SHIFT_B (COLOR_BITS_R+COLOR_BITS_G)
264  #define COLOR_SHIFT_G COLOR_BITS_R
265  #define COLOR_SHIFT_R 0
266  #endif
267 
268  // Calculate RED_OF, GREEN_OF, BLUE_OF and RGB2COLOR
269  #if COLOR_BITS_R + COLOR_SHIFT_R == 8
270  #define RED_OF(c) ((c) & (((1<<COLOR_BITS_R)-1) << COLOR_SHIFT_R))
271  #define RGB2COLOR_R(r) ((COLOR_TYPE)((r) & (0xFF & ~((1<<(8-COLOR_BITS_R))-1))))
272  #elif COLOR_BITS_R + COLOR_SHIFT_R > 8
273  #define RED_OF(c) (((c) & (((1<<COLOR_BITS_R)-1) << COLOR_SHIFT_R)) >> (COLOR_BITS_R+COLOR_SHIFT_R-8))
274  #define RGB2COLOR_R(r) (((COLOR_TYPE)((r) & (0xFF & ~((1<<(8-COLOR_BITS_R))-1)))) << (COLOR_BITS_R+COLOR_SHIFT_R-8))
275  #else // COLOR_BITS_R + COLOR_SHIFT_R < 8
276  #define RED_OF(c) (((c) & (((1<<COLOR_BITS_R)-1) << COLOR_SHIFT_R)) << (8-(COLOR_BITS_R+COLOR_SHIFT_R)))
277  #define RGB2COLOR_R(r) (((COLOR_TYPE)((r) & (0xFF & ~((1<<(8-COLOR_BITS_R))-1)))) >> (8-(COLOR_BITS_R+COLOR_SHIFT_R)))
278  #endif
279  #if COLOR_BITS_G + COLOR_SHIFT_G == 8
280  #define GREEN_OF(c) ((c) & (((1<<COLOR_BITS_G)-1) << COLOR_SHIFT_G))
281  #define RGB2COLOR_G(g) ((COLOR_TYPE)((g) & (0xFF & ~((1<<(8-COLOR_BITS_G))-1))))
282  #elif COLOR_BITS_G + COLOR_SHIFT_G > 8
283  #define GREEN_OF(c) (((c) & (((1<<COLOR_BITS_G)-1) << COLOR_SHIFT_G)) >> (COLOR_BITS_G+COLOR_SHIFT_G-8))
284  #define RGB2COLOR_G(g) (((COLOR_TYPE)((g) & (0xFF & ~((1<<(8-COLOR_BITS_G))-1)))) << (COLOR_BITS_G+COLOR_SHIFT_G-8))
285  #else // COLOR_BITS_G + COLOR_SHIFT_G < 8
286  #define GREEN_OF(c) (((c) & (((1<<COLOR_BITS_G)-1) << COLOR_SHIFT_G)) << (8-(COLOR_BITS_G+COLOR_SHIFT_G)))
287  #define RGB2COLOR_G(g) (((COLOR_TYPE)((g) & (0xFF & ~((1<<(8-COLOR_BITS_G))-1)))) >> (8-(COLOR_BITS_G+COLOR_SHIFT_G)))
288  #endif
289  #if COLOR_BITS_B + COLOR_SHIFT_B == 8
290  #define BLUE_OF(c) ((c) & (((1<<COLOR_BITS_B)-1) << COLOR_SHIFT_B))
291  #define RGB2COLOR_B(b) ((COLOR_TYPE)((b) & (0xFF & ~((1<<(8-COLOR_BITS_B))-1))))
292  #elif COLOR_BITS_B + COLOR_SHIFT_B > 8
293  #define BLUE_OF(c) (((c) & (((1<<COLOR_BITS_B)-1) << COLOR_SHIFT_B)) >> (COLOR_BITS_B+COLOR_SHIFT_B-8))
294  #define RGB2COLOR_B(b) (((COLOR_TYPE)((b) & (0xFF & ~((1<<(8-COLOR_BITS_B))-1)))) << (COLOR_BITS_B+COLOR_SHIFT_B-8))
295  #else // COLOR_BITS_B + COLOR_SHIFT_B < 8
296  #define BLUE_OF(c) (((c) & (((1<<COLOR_BITS_B)-1) << COLOR_SHIFT_B)) << (8-(COLOR_BITS_B+COLOR_SHIFT_B)))
297  #define RGB2COLOR_B(b) (((COLOR_TYPE)((b) & (0xFF & ~((1<<(8-COLOR_BITS_B))-1)))) >> (8-(COLOR_BITS_B+COLOR_SHIFT_B)))
298  #endif
299  #define LUMA_OF(c) ((RED_OF(c)+((uint16_t)GREEN_OF(c)<<1)+BLUE_OF(c))>>2)
300  #define EXACT_RED_OF(c) (((uint16_t)(((c)>>COLOR_SHIFT_R)&((1<<COLOR_BITS_R)-1))*255)/((1<<COLOR_BITS_R)-1))
301  #define EXACT_GREEN_OF(c) (((uint16_t)(((c)>>COLOR_SHIFT_G)&((1<<COLOR_BITS_G)-1))*255)/((1<<COLOR_BITS_G)-1))
302  #define EXACT_BLUE_OF(c) (((uint16_t)(((c)>>COLOR_SHIFT_B)&((1<<COLOR_BITS_B)-1))*255)/((1<<COLOR_BITS_B)-1))
303  #define EXACT_LUMA_OF(c) ((EXACT_RED_OF(c)+((uint16_t)EXACT_GREEN_OF(c)<<1)+EXACT_BLUE_OF(c))>>2)
304  #define LUMA2COLOR(l) (RGB2COLOR_R(l) | RGB2COLOR_G(l) | RGB2COLOR_B(l))
305  #define RGB2COLOR(r,g,b) (RGB2COLOR_R(r) | RGB2COLOR_G(g) | RGB2COLOR_B(b))
306 
307  // Calculate HTML2COLOR
308  #if COLOR_BITS_R + COLOR_SHIFT_R == 24
309  #define HTML2COLOR_R(h) ((h) & ((0xFFL & ~((1<<(8-COLOR_BITS_R))-1))<<16))
310  #elif COLOR_BITS_R + COLOR_SHIFT_R > 24
311  #define HTML2COLOR_R(h) (((h) & ((0xFFL & ~((1<<(8-COLOR_BITS_R))-1))<<16)) << (COLOR_BITS_R+COLOR_SHIFT_R-24))
312  #else // COLOR_BITS_R + COLOR_SHIFT_R < 24
313  #define HTML2COLOR_R(h) (((h) & ((0xFFL & ~((1<<(8-COLOR_BITS_R))-1))<<16)) >> (24-(COLOR_BITS_R+COLOR_SHIFT_R)))
314  #endif
315  #if COLOR_BITS_G + COLOR_SHIFT_G == 16
316  #define HTML2COLOR_G(h) ((h) & ((0xFFL & ~((1<<(8-COLOR_BITS_G))-1))<<8))
317  #elif COLOR_BITS_G + COLOR_SHIFT_G > 16
318  #define HTML2COLOR_G(h) (((h) & ((0xFFL & ~((1<<(8-COLOR_BITS_G))-1))<<8)) << (COLOR_BITS_G+COLOR_SHIFT_G-16))
319  #else // COLOR_BITS_G + COLOR_SHIFT_G < 16
320  #define HTML2COLOR_G(h) (((h) & ((0xFFL & ~((1<<(8-COLOR_BITS_G))-1))<<8)) >> (16-(COLOR_BITS_G+COLOR_SHIFT_G)))
321  #endif
322  #if COLOR_BITS_B + COLOR_SHIFT_B == 8
323  #define HTML2COLOR_B(h) ((h) & (0xFFL & ~((1<<(8-COLOR_BITS_B))-1)))
324  #elif COLOR_BITS_B + COLOR_SHIFT_B > 8
325  #define HTML2COLOR_B(h) (((h) & (0xFFL & ~((1<<(8-COLOR_BITS_B))-1))) << (COLOR_BITS_B+COLOR_SHIFT_B-8))
326  #else // COLOR_BITS_B + COLOR_SHIFT_B < 8
327  #define HTML2COLOR_B(h) (((h) & (0xFFL & ~((1<<(8-COLOR_BITS_B))-1))) >> (8-(COLOR_BITS_B+COLOR_SHIFT_B)))
328  #endif
329  #define HTML2COLOR(h) ((COLOR_TYPE)(HTML2COLOR_R(h) | HTML2COLOR_G(h) | HTML2COLOR_B(h)))
330 
331  // Special hack to allow alpha on RGB888
332  #if GDISP_PIXELFORMAT == GDISP_PIXELFORMAT_RGB888
333  #define COLOR_BITS_A 8
334  #define COLOR_SHIFT_A 24
335  #define ALPHA_OF(c) (((c)>>24) ^ 0xFF)
336  #define EXACT_ALPHA_OF(c) ALPHA_OF((c))
337  #define AHTML2COLOR(h) ((h) ^ 0xFF000000)
338  #define RGB2COLOR_A(a) (((COLOR_TYPE)(((a) ^ 0xFF) & 0xFF)) << 24)
339  #define ARGB2COLOR(a,r,g,b) (RGB2COLOR_A(a) | RGB2COLOR_R(r) | RGB2COLOR_G(g) | RGB2COLOR_B(b))
340  #define GFXTRANSPARENT (0xFF000000)
341  #endif
342 
343 //-------------------------
344 // Gray-scale color system
345 //-------------------------
346 #elif (GDISP_PIXELFORMAT & GDISP_COLORSYSTEM_MASK) == GDISP_COLORSYSTEM_GRAYSCALE
347  #define COLOR_SYSTEM GDISP_COLORSYSTEM_GRAYSCALE
348 
349  // Calculate the number of bits and shifts
350  #define COLOR_BITS (GDISP_PIXELFORMAT & 0xFF)
351  #define COLOR_BITS_R COLOR_BITS
352  #define COLOR_BITS_G COLOR_BITS
353  #define COLOR_BITS_B COLOR_BITS
354  #define COLOR_SHIFT_R 0
355  #define COLOR_SHIFT_G 0
356  #define COLOR_SHIFT_B 0
357 
358  // From the number of bits determine COLOR_TYPE, COLOR_TYPE_BITS and masking
359  #if COLOR_BITS <= 8
360  #define COLOR_TYPE uint8_t
361  #define COLOR_TYPE_BITS 8
362  #else
363  #error "GDISP: Cannot define gray-scale color types with more than 8 bits"
364  #endif
365  #if COLOR_TYPE_BITS == COLOR_BITS
366  #define COLOR_NEEDS_MASK FALSE
367  #else
368  #define COLOR_NEEDS_MASK TRUE
369  #endif
370  #define COLOR_MASK() ((1 << COLOR_BITS)-1)
371 
372  #if COLOR_BITS == 1
373  #define RGB2COLOR(r,g,b) (((r)|(g)|(b)) ? 1 : 0)
374  #define LUMA2COLOR(l) ((l) ? 1 : 0)
375  #define HTML2COLOR(h) ((h) ? 1 : 0)
376  #define LUMA_OF(c) ((c) ? 255 : 0)
377  #define EXACT_LUMA_OF(c) LUMA_OF(c)
378  #else
379  // They eye is more sensitive to green
380  #define RGB2COLOR(r,g,b) ((COLOR_TYPE)(((uint16_t)(r)+(g)+(g)+(b)) >> (10-COLOR_BITS)))
381  #define LUMA2COLOR(l) ((COLOR_TYPE)((l)>>(8-COLOR_BITS)))
382  #define HTML2COLOR(h) ((COLOR_TYPE)(((((h)&0xFF0000)>>16)+(((h)&0x00FF00)>>7)+((h)&0x0000FF)) >> (10-COLOR_BITS)))
383  #define LUMA_OF(c) (((c) & ((1<<COLOR_BITS)-1)) << (8-COLOR_BITS))
384  #define EXACT_LUMA_OF(c) ((((uint16_t)(c) & ((1<<COLOR_BITS)-1))*255)/((1<<COLOR_BITS)-1))
385  #endif
386 
387  #define RED_OF(c) LUMA_OF(c)
388  #define GREEN_OF(c) LUMA_OF(c)
389  #define BLUE_OF(c) LUMA_OF(c)
390  #define EXACT_RED_OF(c) EXACT_LUMA_OF(c)
391  #define EXACT_GREEN_OF(c) EXACT_LUMA_OF(c)
392  #define EXACT_BLUE_OF(c) EXACT_LUMA_OF(c)
393 
394 //-------------------------
395 // Palette color system
396 //-------------------------
397 #elif (GDISP_PIXELFORMAT & GDISP_COLORSYSTEM_MASK) == GDISP_COLORSYSTEM_PALETTE
398  #define COLOR_SYSTEM GDISP_COLORSYSTEM_PALETTE
399 
400  #error "GDISP: A palette color system is not currently supported"
401 
402 //-------------------------
403 // Some other color system
404 //-------------------------
405 #else
406  #error "GDISP: Unsupported color system"
407 #endif
408 
409 /**
410  * @brief The color type definition
411  */
413 
414 #endif /* GFX_USE_GDISP */
415 
416 #endif /* _GDISP_COLORS_H */
417 /** @} */
#define COLOR_TYPE
The color type.
Definition: gdisp_colors.h:151
COLOR_TYPE color_t
The color type definition.
Definition: gdisp_colors.h:412