lv_color.h
API reference for lv_color.h
Functions
lv_color_format_get_bpp
Get the pixel size of a color format in bits, bpp
uint8_t lv_color_format_get_bpp(lv_color_format_t cf)| Name | Type | Description |
|---|---|---|
cf | lv_color_format_t | a color format (LV_COLOR_FORMAT_...) |
Returns: uint8_t — the pixel size in bits
See also: LV_COLOR_FORMAT_GET_BPP
lv_color_format_get_size
Get the pixel size of a color format in bytes
uint8_t lv_color_format_get_size(lv_color_format_t cf)| Name | Type | Description |
|---|---|---|
cf | lv_color_format_t | a color format (LV_COLOR_FORMAT_...) |
Returns: uint8_t — the pixel size in bytes
See also: LV_COLOR_FORMAT_GET_SIZE
lv_color_format_has_alpha
Check if a color format has alpha channel or not
bool lv_color_format_has_alpha(lv_color_format_t src_cf)| Name | Type | Description |
|---|---|---|
src_cf | lv_color_format_t | a color format (LV_COLOR_FORMAT_...) |
Returns: bool — true: has alpha channel; false: doesn't have alpha channel
lv_color_to_32
Create an ARGB8888 color from RGB888 + alpha
lv_color32_t lv_color_to_32(lv_color_t color, lv_opa_t opa)| Name | Type | Description |
|---|---|---|
color | lv_color_t | an RGB888 color |
opa | lv_opa_t | the alpha value |
Returns: lv_color32_t — the ARGB8888 color
lv_color_to_int
Convert an RGB888 color to an integer
uint32_t lv_color_to_int(lv_color_t c)| Name | Type | Description |
|---|---|---|
c | lv_color_t | an RGB888 color |
Returns: uint32_t — c as an integer
lv_color_eq
Check if two RGB888 color are equal
bool lv_color_eq(lv_color_t c1, lv_color_t c2)| Name | Type | Description |
|---|---|---|
c1 | lv_color_t | the first color |
c2 | lv_color_t | the second color |
Returns: bool — true: equal
lv_color32_eq
Check if two ARGB8888 color are equal
bool lv_color32_eq(lv_color32_t c1, lv_color32_t c2)| Name | Type | Description |
|---|---|---|
c1 | lv_color32_t | the first color |
c2 | lv_color32_t | the second color |
Returns: bool — true: equal
lv_color_hex
Create a color from 0x000000..0xffffff input
lv_color_t lv_color_hex(uint32_t c)| Name | Type | Description |
|---|---|---|
c | uint32_t | the hex input |
Returns: lv_color_t — the color
lv_color_make
Create an RGB888 color
lv_color_t lv_color_make(uint8_t r, uint8_t g, uint8_t b)| Name | Type | Description |
|---|---|---|
r | uint8_t | the red channel (0..255) |
g | uint8_t | the green channel (0..255) |
b | uint8_t | the blue channel (0..255) |
Returns: lv_color_t — the color
lv_color32_make
Create an ARGB8888 color
lv_color32_t lv_color32_make(uint8_t r, uint8_t g, uint8_t b, uint8_t a)| Name | Type | Description |
|---|---|---|
r | uint8_t | the red channel (0..255) |
g | uint8_t | the green channel (0..255) |
b | uint8_t | the blue channel (0..255) |
a | uint8_t | the alpha channel (0..255) |
Returns: lv_color32_t — the color
lv_color_hex3
Create a color from 0x000..0xfff input
lv_color_t lv_color_hex3(uint32_t c)| Name | Type | Description |
|---|---|---|
c | uint32_t | the hex input (e.g. 0x123 will be 0x112233) |
Returns: lv_color_t — the color
lv_color_is_in_range
Check if a color with an RGB888 color is within the color range defined by l_color and h_color.
static bool lv_color_is_in_range(lv_color_t color, lv_color_t l_color, lv_color_t h_color)| Name | Type | Description |
|---|---|---|
color | lv_color_t | the color to check |
l_color | lv_color_t | the lower bound color |
h_color | lv_color_t | the upper bound color |
Returns: bool — true: pixel is within the color range
lv_color16_to_color
Convert a RGB565 color to RGB888
static lv_color_t lv_color16_to_color(lv_color16_t c)| Name | Type | Description |
|---|---|---|
c | lv_color16_t | a RGB565 color on lv_color16_t |
Returns: lv_color_t — the color
lv_color_to_u16
Convert am RGB888 color to RGB565 stored in uint16_t
uint16_t lv_color_to_u16(lv_color_t color)| Name | Type | Description |
|---|---|---|
color | lv_color_t | and RGB888 color |
Returns: uint16_t — color as RGB565 on uin16_t
lv_color_to_u32
Convert am RGB888 color to XRGB8888 stored in uint32_t
uint32_t lv_color_to_u32(lv_color_t color)| Name | Type | Description |
|---|---|---|
color | lv_color_t | and RGB888 color |
Returns: uint32_t — color as XRGB8888 on uin32_t (the alpha channel is always set to 0xFF)
lv_color_16_16_mix
Mix two RGB565 colors
uint16_t lv_color_16_16_mix(uint16_t c1, uint16_t c2, uint8_t mix)| Name | Type | Description |
|---|---|---|
c1 | uint16_t | the first color (typically the foreground color) |
c2 | uint16_t | the second color (typically the background color) |
mix | uint8_t | 0..255, or LV_OPA_0/10/20... |
Returns: uint16_t — mix == 0: c2 mix == 255: c1 mix == 128: 0.5 x c1 + 0.5 x c2
lv_color_lighten
Mix white to a color
lv_color_t lv_color_lighten(lv_color_t c, lv_opa_t lvl)| Name | Type | Description |
|---|---|---|
c | lv_color_t | the base color |
lvl | lv_opa_t | the intensity of white (0: no change, 255: fully white) |
Returns: lv_color_t — the mixed color
lv_color_darken
Mix black to a color
lv_color_t lv_color_darken(lv_color_t c, lv_opa_t lvl)| Name | Type | Description |
|---|---|---|
c | lv_color_t | the base color |
lvl | lv_opa_t | the intensity of black (0: no change, 255: fully black) |
Returns: lv_color_t — the mixed color
lv_color_hsv_to_rgb
Convert a HSV color to RGB
lv_color_t lv_color_hsv_to_rgb(uint16_t h, uint8_t s, uint8_t v)| Name | Type | Description |
|---|---|---|
h | uint16_t | hue [0..359] |
s | uint8_t | saturation [0..100] |
v | uint8_t | value [0..100] |
Returns: lv_color_t — the given RGB color in RGB (with LV_COLOR_DEPTH depth)
lv_color_rgb_to_hsv
Convert a 32-bit RGB color to HSV
lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r8, uint8_t g8, uint8_t b8)| Name | Type | Description |
|---|---|---|
r8 | uint8_t | 8-bit red |
g8 | uint8_t | 8-bit green |
b8 | uint8_t | 8-bit blue |
Returns: lv_color_hsv_t — the given RGB color in HSV
lv_color_to_hsv
Convert a color to HSV
lv_color_hsv_t lv_color_to_hsv(lv_color_t color)| Name | Type | Description |
|---|---|---|
color | lv_color_t | color |
Returns: lv_color_hsv_t — the given color in HSV
lv_color_white
A helper for white color
lv_color_t lv_color_white(void)Returns: lv_color_t — a white color
lv_color_black
A helper for black color
lv_color_t lv_color_black(void)Returns: lv_color_t — a black color
lv_color_premultiply
void lv_color_premultiply(lv_color32_t *c)| Name | Type |
|---|---|
c | lv_color32_t * |
lv_color16_premultiply
void lv_color16_premultiply(lv_color16_t *c, lv_opa_t a)| Name | Type |
|---|---|
c | lv_color16_t * |
a | lv_opa_t |
lv_color_luminance
Get the luminance of a color: luminance = 0.3 R + 0.59 G + 0.11 B
uint8_t lv_color_luminance(lv_color_t c)| Name | Type | Description |
|---|---|---|
c | lv_color_t | a color |
Returns: uint8_t — the brightness [0..255]
lv_color16_luminance
Get the luminance of a color16: luminance = 0.3 R + 0.59 G + 0.11 B
uint8_t lv_color16_luminance(const lv_color16_t c)| Name | Type | Description |
|---|---|---|
c | const lv_color16_t | a color |
Returns: uint8_t — the brightness [0..255]
lv_color24_luminance
Get the luminance of a color24: luminance = 0.3 R + 0.59 G + 0.11 B
uint8_t lv_color24_luminance(const uint8_t *c)| Name | Type | Description |
|---|---|---|
c | const uint8_t * | a color |
Returns: uint8_t — the brightness [0..255]
lv_color32_luminance
Get the luminance of a color32: luminance = 0.3 R + 0.59 G + 0.11 B
uint8_t lv_color32_luminance(lv_color32_t c)| Name | Type | Description |
|---|---|---|
c | lv_color32_t | a color |
Returns: uint8_t — the brightness [0..255]
lv_color_swap_16
Swap the endianness of an rgb565 color
static uint16_t lv_color_swap_16(uint16_t c)| Name | Type | Description |
|---|---|---|
c | uint16_t | a color |
Returns: uint16_t — the swapped color
Enums
_lv_opacity_level_t
Opacity percentages.
| Name | Value |
|---|---|
LV_OPA_TRANSP | 0 |
LV_OPA_0 | 0 |
LV_OPA_10 | 25 |
LV_OPA_20 | 51 |
LV_OPA_30 | 76 |
LV_OPA_40 | 102 |
LV_OPA_50 | 127 |
LV_OPA_60 | 153 |
LV_OPA_70 | 178 |
LV_OPA_80 | 204 |
LV_OPA_90 | 229 |
LV_OPA_100 | 255 |
LV_OPA_COVER | 255 |
lv_color_format_t
| Name | Value | Description |
|---|---|---|
LV_COLOR_FORMAT_UNKNOWN | 0 | |
LV_COLOR_FORMAT_RAW | 0x01 | |
LV_COLOR_FORMAT_RAW_ALPHA | 0x02 | |
LV_COLOR_FORMAT_L8 | 0x06 | |
LV_COLOR_FORMAT_I1 | 0x07 | |
LV_COLOR_FORMAT_I2 | 0x08 | |
LV_COLOR_FORMAT_I4 | 0x09 | |
LV_COLOR_FORMAT_I8 | 0x0A | |
LV_COLOR_FORMAT_A8 | 0x0E | |
LV_COLOR_FORMAT_RGB565 | 0x12 | |
LV_COLOR_FORMAT_ARGB8565 | 0x13 | Not supported by sw renderer yet. |
LV_COLOR_FORMAT_RGB565A8 | 0x14 | Color array followed by Alpha array |
LV_COLOR_FORMAT_AL88 | 0x15 | L8 with alpha > |
LV_COLOR_FORMAT_RGB565_SWAPPED | 0x1B | |
LV_COLOR_FORMAT_RGB888 | 0x0F | |
LV_COLOR_FORMAT_ARGB8888 | 0x10 | |
LV_COLOR_FORMAT_XRGB8888 | 0x11 | |
LV_COLOR_FORMAT_ARGB8888_PREMULTIPLIED | 0x1A | |
LV_COLOR_FORMAT_A1 | 0x0B | |
LV_COLOR_FORMAT_A2 | 0x0C | |
LV_COLOR_FORMAT_A4 | 0x0D | |
LV_COLOR_FORMAT_ARGB1555 | 0x16 | |
LV_COLOR_FORMAT_ARGB4444 | 0x17 | |
LV_COLOR_FORMAT_ARGB2222 | 0X18 | |
LV_COLOR_FORMAT_YUV_START | 0x20 | |
LV_COLOR_FORMAT_I420 | LV_COLOR_FORMAT_YUV_START | |
LV_COLOR_FORMAT_I422 | 0x21 | |
LV_COLOR_FORMAT_I444 | 0x22 | |
LV_COLOR_FORMAT_I400 | 0x23 | |
LV_COLOR_FORMAT_NV21 | 0x24 | |
LV_COLOR_FORMAT_NV12 | 0x25 | |
LV_COLOR_FORMAT_YUY2 | 0x26 | |
LV_COLOR_FORMAT_UYVY | 0x27 | |
LV_COLOR_FORMAT_YUV_END | LV_COLOR_FORMAT_UYVY | |
LV_COLOR_FORMAT_PROPRIETARY_START | 0x30 | |
LV_COLOR_FORMAT_NEMA_TSC_START | LV_COLOR_FORMAT_PROPRIETARY_START | |
LV_COLOR_FORMAT_NEMA_TSC4 | LV_COLOR_FORMAT_NEMA_TSC_START | |
LV_COLOR_FORMAT_NEMA_TSC6 | 0x31 | |
LV_COLOR_FORMAT_NEMA_TSC6A | 0x32 | |
LV_COLOR_FORMAT_NEMA_TSC6AP | 0x33 | |
LV_COLOR_FORMAT_NEMA_TSC12 | 0x34 | |
LV_COLOR_FORMAT_NEMA_TSC12A | 0x35 | |
LV_COLOR_FORMAT_NEMA_TSC_END | LV_COLOR_FORMAT_NEMA_TSC12A |
Used by 51 functions
lv_display_set_color_format— paramcolor_formatlv_color_format_get_bpp— paramcflv_color_format_get_size— paramcflv_color_format_has_alpha— paramsrc_cflv_draw_layer_create— paramcolor_formatlv_draw_layer_init— paramcolor_formatlv_draw_buf_align— paramcolor_formatlv_draw_buf_align_ex— paramcolor_formatlv_draw_buf_width_to_stride— paramcolor_formatlv_draw_buf_width_to_stride_ex— paramcolor_formatlv_draw_buf_create— paramcflv_draw_buf_create_ex— paramcflv_draw_buf_init— paramcflv_draw_buf_reshape— paramcflv_draw_rotate— paramcolor_formatlv_snapshot_take— paramcflv_snapshot_create_draw_buf— paramcflv_snapshot_take_to_draw_buf— paramcflv_snapshot_take_to_buf— paramcflv_canvas_set_buffer— paramcflv_gif_set_color_format— paramcolor_formatlv_draw_dma2d_cf_to_dma2d_output_cf— paramcfppa_src_cf_supported— paramcfppa_dest_cf_supported— paramcflv_color_format_to_ppa_fill— paramlv_fmtlv_color_format_to_ppa_blend— paramlv_fmtlv_ppa_pic_w— paramcflv_color_format_to_ppa_srm— paramlv_fmtlv_nanovg_reshape_global_image— paramcflv_nemagfx_is_cf_supported— paramcflv_nemagfx_cf_to_nema— paramcflv_draw_pxp_rotate— paramcfpxp_get_out_px_format— paramcfpxp_get_as_px_format— paramcfpxp_get_ps_px_format— paramcflv_draw_dave2d_transform— paramcflv_draw_dave2d_lv_colour_fmt_to_d2_fmt— paramcolour_formatlv_draw_dave2d_is_dest_cf_supported— paramcflv_draw_sw_image_helium— paramsrc_cflv_draw_sw_image_recolor_rgb888— paramsrc_cflv_draw_sw_transform— paramsrc_cflv_draw_sw_unregister_blend_handler— paramdest_cflv_draw_sw_get_blend_handler— paramdest_cflv_vg_lite_is_dest_cf_supported— paramcflv_vg_lite_is_src_cf_supported— paramcflv_vg_lite_vg_fmt— paramcflv_opengles_render_texture_cf— paramcflv_opengles_gl_format_from_color_format— paramcflv_opengles_color_format_is_rb_swap— paramcflv_opengles_color_format_is_premultiplied— paramcflv_opengles_texture_upload_buf— paramcf
Structs
lv_color_t
| Member | Type | Description |
|---|---|---|
blue | uint8_t | |
green | uint8_t | |
red | uint8_t |
Used by 68 functions
lv_obj_set_style_bg_color— paramvaluelv_obj_set_style_bg_grad_color— paramvaluelv_obj_set_style_bg_image_recolor— paramvaluelv_obj_set_style_border_color— paramvaluelv_obj_set_style_outline_color— paramvaluelv_obj_set_style_shadow_color— paramvaluelv_obj_set_style_image_recolor— paramvaluelv_obj_set_style_line_color— paramvaluelv_obj_set_style_arc_color— paramvaluelv_obj_set_style_text_color— paramvaluelv_obj_set_style_text_outline_stroke_color— paramvaluelv_obj_set_style_drop_shadow_color— paramvaluelv_obj_set_style_recolor— paramvaluelv_subject_init_color— paramcolorlv_subject_set_color— paramcolorlv_style_set_bg_color— paramvaluelv_style_set_bg_grad_color— paramvaluelv_style_set_bg_image_recolor— paramvaluelv_style_set_border_color— paramvaluelv_style_set_outline_color— paramvaluelv_style_set_shadow_color— paramvaluelv_style_set_image_recolor— paramvaluelv_style_set_line_color— paramvaluelv_style_set_arc_color— paramvaluelv_style_set_text_color— paramvaluelv_style_set_text_outline_stroke_color— paramvaluelv_style_set_drop_shadow_color— paramvaluelv_style_set_recolor— paramvaluelv_color_to_32— paramcolorlv_color_to_int— paramclv_color_eq— paramc1lv_color_eq— paramc2lv_color_is_in_range— paramcolorlv_color_is_in_range— paraml_colorlv_color_is_in_range— paramh_colorlv_color_to_u16— paramcolorlv_color_to_u32— paramcolorlv_color_lighten— paramclv_color_darken— paramclv_color_to_hsv— paramcolorlv_color_luminance— paramclv_color_mix— paramc1lv_color_mix— paramc2lv_color_brightness— paramclv_draw_vector_dsc_set_fill_color— paramcolorlv_draw_vector_dsc_set_stroke_color— paramcolorlv_grad_init_stops— paramcolorslv_opengles_render_fill— paramcolorlv_theme_default_init— paramcolor_primarylv_theme_default_init— paramcolor_secondarylv_barcode_set_dark_color— paramcolorlv_barcode_set_light_color— paramcolorlv_canvas_set_px— paramcolorlv_canvas_fill_bg— paramcolorlv_chart_add_series— paramcolorlv_chart_set_series_color— paramcolorlv_chart_add_cursor— paramcolorlv_led_set_color— paramcolorlv_qrcode_set_dark_color— paramcolorlv_qrcode_set_light_color— paramcolorlv_draw_dma2d_color_to_dma2d_color— paramcolorlv_eve_color— paramcolorlv_nanovg_color_convert— paramcolorlv_draw_dave2d_lv_colour_to_d2_colour— paramcolorlv_draw_sw_image_recolor_rgb565— paramcolorlv_draw_sw_image_recolor_rgb888— paramcolorlv_draw_sw_grad_color_calculate— paramcolor_outlv_vg_lite_color— paramcolor
lv_color16_t
| Member | Type | Description |
|---|---|---|
blue | uint16_t | |
green | uint16_t | |
red | uint16_t |
Used by 3 functions
lv_color16_to_color— paramclv_color16_premultiply— paramclv_color16_luminance— paramc
lv_color32_t
| Member | Type | Description |
|---|---|---|
blue | uint8_t | |
green | uint8_t | |
red | uint8_t | |
alpha | uint8_t |
Used by 22 functions
lv_obj_style_apply_recolor— paramcolorlv_color32_eq— paramc1lv_color32_eq— paramc2lv_color_premultiply— paramclv_color32_luminance— paramclv_color_mix32— paramfglv_color_mix32— parambglv_color_mix32_premultiplied— paramfglv_color_mix32_premultiplied— parambglv_color_over32— paramfglv_color_over32— parambglv_draw_buf_set_palette— paramcolorlv_image_buf_set_palette— paramclv_draw_vector_dsc_set_fill_color32— paramcolorlv_draw_vector_dsc_set_stroke_color32— paramcolorlv_canvas_set_palette— paramcolorlv_color32_unpremultiply— paramclv_color32_lumi_of— paramclv_color_mix32_inlined— paramfglv_color_mix32_inlined— parambglv_color_mix32_premultiplied_inlined— paramfglv_color_mix32_premultiplied_inlined— parambg
lv_color_hsv_t
| Member | Type | Description |
|---|---|---|
h | uint16_t | |
s | uint8_t | |
v | uint8_t |
lv_color16a_t
| Member | Type | Description |
|---|---|---|
lumi | uint8_t | |
alpha | uint8_t |
Macros
LV_COLOR_NATIVE_WITH_ALPHA_SIZE
#define LV_COLOR_NATIVE_WITH_ALPHA_SIZE 3LV_OPA_MIN
#define LV_OPA_MIN 2Fully transparent if opa <= LV_OPA_MIN
LV_OPA_MAX
#define LV_OPA_MAX 253Fully cover if opa >= LV_OPA_MAX
LV_COLOR_FORMAT_GET_BPP
#define LV_COLOR_FORMAT_GET_BPP(cf)Get the pixel size of a color format in bits, bpp
Parameters| Name | Description |
|---|---|
cf | a color format (LV_COLOR_FORMAT_...) |
Returns: the pixel size in bits
See also: lv_color_format_get_bpp
LV_COLOR_FORMAT_GET_SIZE
#define LV_COLOR_FORMAT_GET_SIZE(cf) \
((LV_COLOR_FORMAT_GET_BPP(cf) + 7) >> 3)Get the pixel size of a color format in bytes
Parameters| Name | Description |
|---|---|
cf | a color format (LV_COLOR_FORMAT_...) |
Returns: the pixel size in bytes
See also: lv_color_format_get_size
LV_COLOR_FORMAT_IS_ALPHA_ONLY
#define LV_COLOR_FORMAT_IS_ALPHA_ONLY(cf) \
((cf) >= LV_COLOR_FORMAT_A1 && (cf) <= LV_COLOR_FORMAT_A8)LV_COLOR_FORMAT_IS_INDEXED
#define LV_COLOR_FORMAT_IS_INDEXED(cf) \
((cf) >= LV_COLOR_FORMAT_I1 && (cf) <= LV_COLOR_FORMAT_I8)LV_COLOR_FORMAT_IS_YUV
#define LV_COLOR_FORMAT_IS_YUV(cf) \
((cf) >= LV_COLOR_FORMAT_YUV_START && (cf) <= LV_COLOR_FORMAT_YUV_END)LV_COLOR_INDEXED_PALETTE_SIZE
#define LV_COLOR_INDEXED_PALETTE_SIZE(cf) \
((cf) == LV_COLOR_FORMAT_I1 ? 2 : \
(cf) == LV_COLOR_FORMAT_I2 ? 4 : \
(cf) == LV_COLOR_FORMAT_I4 ? 16 : \
(cf) == LV_COLOR_FORMAT_I8 ? 256 : 0)LV_COLOR_MAKE
#define LV_COLOR_MAKE(r8, g8, b8) \
{b8, g8, r8}LV_OPA_MIX2
#define LV_OPA_MIX2(a1, a2) \
((lv_opa_t)(((int32_t)(a1) * (a2)) >> 8))LV_OPA_MIX3
#define LV_OPA_MIX3(a1, a2, a3) \
((lv_opa_t)(((int32_t)(a1) * (a2) * (a3)) >> 16))Variables
lv_color_filter_shade
const lv_color_filter_dsc_t lv_color_filter_shadeDependencies
Last updated on