lv_color.h

Defines

LV_COLOR_NATIVE_WITH_ALPHA_SIZE
LV_OPA_MIN

Opacities below this will be transparent

LV_OPA_MAX

Opacities above this will fully cover

LV_COLOR_FORMAT_GET_BPP(cf)

Get the pixel size of a color format in bits, bpp

Parameters:
  • cf – a color format (LV_COLOR_FORMAT_...)

Returns:

the pixel size in bits

LV_COLOR_FORMAT_GET_SIZE(cf)

Get the pixel size of a color format in bytes

Parameters:
  • cf – a color format (LV_COLOR_FORMAT_...)

Returns:

the pixel size in bytes

LV_COLOR_FORMAT_IS_ALPHA_ONLY(cf)
LV_COLOR_FORMAT_IS_INDEXED(cf)
LV_COLOR_FORMAT_IS_YUV(cf)
LV_COLOR_INDEXED_PALETTE_SIZE(cf)
LV_COLOR_MAKE(r8, g8, b8)
LV_OPA_MIX2(a1, a2)
LV_OPA_MIX3(a1, a2, a3)

Enums

enum [anonymous]

Opacity percentages.

Values:

enumerator LV_OPA_TRANSP
enumerator LV_OPA_0
enumerator LV_OPA_10
enumerator LV_OPA_20
enumerator LV_OPA_30
enumerator LV_OPA_40
enumerator LV_OPA_50
enumerator LV_OPA_60
enumerator LV_OPA_70
enumerator LV_OPA_80
enumerator LV_OPA_90
enumerator LV_OPA_100
enumerator LV_OPA_COVER
enum lv_color_format_t

Values:

enumerator LV_COLOR_FORMAT_UNKNOWN
enumerator LV_COLOR_FORMAT_RAW
enumerator LV_COLOR_FORMAT_RAW_ALPHA
enumerator LV_COLOR_FORMAT_L8
enumerator LV_COLOR_FORMAT_I1
enumerator LV_COLOR_FORMAT_I2
enumerator LV_COLOR_FORMAT_I4
enumerator LV_COLOR_FORMAT_I8
enumerator LV_COLOR_FORMAT_A8
enumerator LV_COLOR_FORMAT_RGB565
enumerator LV_COLOR_FORMAT_ARGB8565

Not supported by sw renderer yet.

enumerator LV_COLOR_FORMAT_RGB565A8

Color array followed by Alpha array

enumerator LV_COLOR_FORMAT_AL88

L8 with alpha >

enumerator LV_COLOR_FORMAT_RGB888
enumerator LV_COLOR_FORMAT_ARGB8888
enumerator LV_COLOR_FORMAT_XRGB8888
enumerator LV_COLOR_FORMAT_A1
enumerator LV_COLOR_FORMAT_A2
enumerator LV_COLOR_FORMAT_A4
enumerator LV_COLOR_FORMAT_ARGB1555
enumerator LV_COLOR_FORMAT_ARGB4444
enumerator LV_COLOR_FORMAT_ARGB2222
enumerator LV_COLOR_FORMAT_YUV_START
enumerator LV_COLOR_FORMAT_I420
enumerator LV_COLOR_FORMAT_I422
enumerator LV_COLOR_FORMAT_I444
enumerator LV_COLOR_FORMAT_I400
enumerator LV_COLOR_FORMAT_NV21
enumerator LV_COLOR_FORMAT_NV12
enumerator LV_COLOR_FORMAT_YUY2
enumerator LV_COLOR_FORMAT_UYVY
enumerator LV_COLOR_FORMAT_YUV_END
enumerator LV_COLOR_FORMAT_PROPRIETARY_START
enumerator LV_COLOR_FORMAT_NEMA_TSC_START
enumerator LV_COLOR_FORMAT_NEMA_TSC4
enumerator LV_COLOR_FORMAT_NEMA_TSC6
enumerator LV_COLOR_FORMAT_NEMA_TSC6A
enumerator LV_COLOR_FORMAT_NEMA_TSC6AP
enumerator LV_COLOR_FORMAT_NEMA_TSC12
enumerator LV_COLOR_FORMAT_NEMA_TSC12A
enumerator LV_COLOR_FORMAT_NEMA_TSC_END
enumerator LV_COLOR_FORMAT_NATIVE
enumerator LV_COLOR_FORMAT_NATIVE_WITH_ALPHA

Functions

uint8_t lv_color_format_get_bpp(lv_color_format_t cf)

Get the pixel size of a color format in bits, bpp

Parameters:

cf – a color format (LV_COLOR_FORMAT_...)

Returns:

the pixel size in bits

uint8_t lv_color_format_get_size(lv_color_format_t cf)

Get the pixel size of a color format in bytes

Parameters:

cf – a color format (LV_COLOR_FORMAT_...)

Returns:

the pixel size in bytes

bool lv_color_format_has_alpha(lv_color_format_t src_cf)

Check if a color format has alpha channel or not

Parameters:

src_cf – a color format (LV_COLOR_FORMAT_...)

Returns:

true: has alpha channel; false: doesn't have alpha channel

lv_color32_t lv_color_to_32(lv_color_t color, lv_opa_t opa)

Create an ARGB8888 color from RGB888 + alpha

Parameters:
  • color – an RGB888 color

  • opa – the alpha value

Returns:

the ARGB8888 color

uint32_t lv_color_to_int(lv_color_t c)

Convert an RGB888 color to an integer

Parameters:

c – an RGB888 color

Returns:

c as an integer

bool lv_color_eq(lv_color_t c1, lv_color_t c2)

Check if two RGB888 color are equal

Parameters:
  • c1 – the first color

  • c2 – the second color

Returns:

true: equal

bool lv_color32_eq(lv_color32_t c1, lv_color32_t c2)

Check if two ARGB8888 color are equal

Parameters:
  • c1 – the first color

  • c2 – the second color

Returns:

true: equal

lv_color_t lv_color_hex(uint32_t c)

Create a color from 0x000000..0xffffff input

Parameters:

c – the hex input

Returns:

the color

lv_color_t lv_color_make(uint8_t r, uint8_t g, uint8_t b)

Create an RGB888 color

Parameters:
  • r – the red channel (0..255)

  • g – the green channel (0..255)

  • b – the blue channel (0..255)

Returns:

the color

lv_color32_t lv_color32_make(uint8_t r, uint8_t g, uint8_t b, uint8_t a)

Create an ARGB8888 color

Parameters:
  • r – the red channel (0..255)

  • g – the green channel (0..255)

  • b – the blue channel (0..255)

  • a – the alpha channel (0..255)

Returns:

the color

lv_color_t lv_color_hex3(uint32_t c)

Create a color from 0x000..0xfff input

Parameters:

c – the hex input (e.g. 0x123 will be 0x112233)

Returns:

the color

uint16_t lv_color_to_u16(lv_color_t color)

Convert am RGB888 color to RGB565 stored in uint16_t

Parameters:

color – and RGB888 color

Returns:

color as RGB565 on uin16_t

uint32_t lv_color_to_u32(lv_color_t color)

Convert am RGB888 color to XRGB8888 stored in uint32_t

Parameters:

color – and RGB888 color

Returns:

color as XRGB8888 on uin32_t (the alpha channel is always set to 0xFF)

uint16_t lv_color_16_16_mix(uint16_t c1, uint16_t c2, uint8_t mix)

Mix two RGB565 colors

Parameters:
  • c1 – the first color (typically the foreground color)

  • c2 – the second color (typically the background color)

  • mix – 0..255, or LV_OPA_0/10/20...

Returns:

mix == 0: c2 mix == 255: c1 mix == 128: 0.5 x c1 + 0.5 x c2

lv_color_t lv_color_lighten(lv_color_t c, lv_opa_t lvl)

Mix white to a color

Parameters:
  • c – the base color

  • lvl – the intensity of white (0: no change, 255: fully white)

Returns:

the mixed color

lv_color_t lv_color_darken(lv_color_t c, lv_opa_t lvl)

Mix black to a color

Parameters:
  • c – the base color

  • lvl – the intensity of black (0: no change, 255: fully black)

Returns:

the mixed color

lv_color_t lv_color_hsv_to_rgb(uint16_t h, uint8_t s, uint8_t v)

Convert a HSV color to RGB

Parameters:
  • h – hue [0..359]

  • s – saturation [0..100]

  • v – value [0..100]

Returns:

the given RGB color in RGB (with LV_COLOR_DEPTH depth)

lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r8, uint8_t g8, uint8_t b8)

Convert a 32-bit RGB color to HSV

Parameters:
  • r8 – 8-bit red

  • g8 – 8-bit green

  • b8 – 8-bit blue

Returns:

the given RGB color in HSV

lv_color_hsv_t lv_color_to_hsv(lv_color_t color)

Convert a color to HSV

Parameters:

color – color

Returns:

the given color in HSV

lv_color_t lv_color_white(void)

A helper for white color

Returns:

a white color

lv_color_t lv_color_black(void)

A helper for black color

Returns:

a black color

void lv_color_premultiply(lv_color32_t *c)
void lv_color16_premultiply(lv_color16_t *c, lv_opa_t a)
uint8_t lv_color_luminance(lv_color_t c)

Get the luminance of a color: luminance = 0.3 R + 0.59 G + 0.11 B

Parameters:

c – a color

Returns:

the brightness [0..255]

uint8_t lv_color16_luminance(const lv_color16_t c)

Get the luminance of a color16: luminance = 0.3 R + 0.59 G + 0.11 B

Parameters:

c – a color

Returns:

the brightness [0..255]

uint8_t lv_color24_luminance(const uint8_t *c)

Get the luminance of a color24: luminance = 0.3 R + 0.59 G + 0.11 B

Parameters:

c – a color

Returns:

the brightness [0..255]

uint8_t lv_color32_luminance(lv_color32_t c)

Get the luminance of a color32: luminance = 0.3 R + 0.59 G + 0.11 B

Parameters:

c – a color

Returns:

the brightness [0..255]

Variables

const lv_color_filter_dsc_t lv_color_filter_shade
struct lv_color_t

Public Members

uint8_t blue
uint8_t green
uint8_t red
struct lv_color16_t

Public Members

uint16_t blue
uint16_t green
uint16_t red
struct lv_color32_t

Public Members

uint8_t blue
uint8_t green
uint8_t red
uint8_t alpha
struct lv_color_hsv_t

Public Members

uint16_t h
uint8_t s
uint8_t v
struct lv_color16a_t

Public Members

uint8_t lumi
uint8_t alpha