mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
Add inline functions to replace LV_COLOR_MAKE
This commit is contained in:
parent
2be9e67697
commit
5e41a28dcf
@ -369,16 +369,51 @@ static inline uint8_t lv_color_brightness(lv_color_t color)
|
|||||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||||
#if LV_COLOR_DEPTH == 1
|
#if LV_COLOR_DEPTH == 1
|
||||||
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){(b8 >> 7 | g8 >> 7 | r8 >> 7)})
|
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){(b8 >> 7 | g8 >> 7 | r8 >> 7)})
|
||||||
|
static inline lv_color_t lv_color_make(int r8, int g8, int b8){
|
||||||
|
lv_color_t color;
|
||||||
|
color.full = (b8 >> 7 | g8 >> 7 | r8 >> 7);
|
||||||
|
return color;
|
||||||
|
}
|
||||||
#elif LV_COLOR_DEPTH == 8
|
#elif LV_COLOR_DEPTH == 8
|
||||||
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8 >> 6, g8 >> 5, r8 >> 5}})
|
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8 >> 6, g8 >> 5, r8 >> 5}})
|
||||||
|
static inline lv_color_t lv_color_make(uint8_t r8, int g8, int b8){
|
||||||
|
lv_color_t color;
|
||||||
|
color.blue = b8 >> 6;
|
||||||
|
color.green = g8 >> 5;
|
||||||
|
color.red = r8 >> 5;
|
||||||
|
return color;
|
||||||
|
}
|
||||||
#elif LV_COLOR_DEPTH == 16
|
#elif LV_COLOR_DEPTH == 16
|
||||||
# if LV_COLOR_16_SWAP == 0
|
# if LV_COLOR_16_SWAP == 0
|
||||||
# define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8 >> 3, g8 >> 2, r8 >> 3}})
|
# define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8 >> 3, g8 >> 2, r8 >> 3}})
|
||||||
|
static inline lv_color_t lv_color_make(uint8_t r8, uint8_t g8, uint8_t b8){
|
||||||
|
lv_color_t color;
|
||||||
|
color.blue = (uint16_t)(b8 >> 3);
|
||||||
|
color.green = (uint16_t)(g8 >> 2);
|
||||||
|
color.red = (uint16_t)(r8 >> 3);
|
||||||
|
return color;
|
||||||
|
}
|
||||||
# else
|
# else
|
||||||
# define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{g8 >> 5, r8 >> 3, b8 >> 3, (g8 >> 2) & 0x7}})
|
# define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{g8 >> 5, r8 >> 3, b8 >> 3, (g8 >> 2) & 0x7}})
|
||||||
|
static inline lv_color_t lv_color_make(uint8_t r8, uint8_t g8, uint8_t b8){
|
||||||
|
lv_color_t color;
|
||||||
|
color.green_h = (uint16_t)(g8 >> 5);
|
||||||
|
color.red = (uint16_t)(r8 >> 3);
|
||||||
|
color.blue = (uint16_t)(b8 >> 3);
|
||||||
|
color.green_l = (uint16_t)((g8 >> 2) & 0x7);
|
||||||
|
return color;
|
||||||
|
}
|
||||||
# endif
|
# endif
|
||||||
#elif LV_COLOR_DEPTH == 32
|
#elif LV_COLOR_DEPTH == 32
|
||||||
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8, g8, r8, 0xff}}) /*Fix 0xff alpha*/
|
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8, g8, r8, 0xff}}) /*Fix 0xff alpha*/
|
||||||
|
static inline lv_color_t lv_color_make(uint8_t r8, uint8_t g8, uint8_t b8){
|
||||||
|
lv_color_t color;
|
||||||
|
color.blue = b8;
|
||||||
|
color.green = g8;
|
||||||
|
color.red = r8;
|
||||||
|
color.alpha = 0xff;
|
||||||
|
return color;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#if LV_COLOR_DEPTH == 1
|
#if LV_COLOR_DEPTH == 1
|
||||||
@ -402,12 +437,16 @@ static inline uint8_t lv_color_brightness(lv_color_t color)
|
|||||||
(uint8_t) ((uint32_t)(c & 0xF0) | ((c & 0xF0) >> 4)), \
|
(uint8_t) ((uint32_t)(c & 0xF0) | ((c & 0xF0) >> 4)), \
|
||||||
(uint8_t) ((uint32_t)(c & 0xF) | ((c & 0xF) << 4)))
|
(uint8_t) ((uint32_t)(c & 0xF) | ((c & 0xF) << 4)))
|
||||||
|
|
||||||
static inline lv_color_t lv_color_hex(uint32_t c){
|
static inline lv_color_t lv_color_hex(uint32_t c) {
|
||||||
return LV_COLOR_HEX(c);
|
return lv_color_make((uint8_t) ((c >> 16) & 0xFF),
|
||||||
|
(uint8_t) ((c >> 8) & 0xFF),
|
||||||
|
(uint8_t) (c & 0xFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline lv_color_t lv_color_hex3(uint32_t c){
|
static inline lv_color_t lv_color_hex3(uint32_t c) {
|
||||||
return LV_COLOR_HEX3(c);
|
return lv_color_make((uint8_t) (((c >> 4) & 0xF0) | ((c >> 8) & 0xF)),
|
||||||
|
(uint8_t) ((c & 0xF0) | ((c & 0xF0) >> 4)),
|
||||||
|
(uint8_t) ((c & 0xF) | ((c & 0xF) << 4)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user