lv_draw_buf.h
API reference for lv_draw_buf.h
See Also: Private HeaderThis header has a companion private implementation with internal data structures.lv_draw_buf_private.h
Functions
draw/lv_draw_buf.h:334function
lv_draw_buf_set_flag
Set a flag to a draw buffer.
static void lv_draw_buf_set_flag(lv_draw_buf_t *draw_buf, lv_image_flags_t flag)| Name | Type | Description |
|---|---|---|
draw_buf | lv_draw_buf_t * | pointer to a draw buffer |
flag | lv_image_flags_t | the flag to set |
draw/lv_draw_buf.h:368function
lv_draw_buf_set_palette
Set the palette color of an indexed image. Valid only for LV_COLOR_FORMAT_I1/2/4/8
void lv_draw_buf_set_palette(lv_draw_buf_t *draw_buf, uint8_t index, lv_color32_t color)| Name | Type | Description |
|---|---|---|
draw_buf | lv_draw_buf_t * | pointer to an image descriptor |
index | uint8_t | the palette color to set: - for LV_COLOR_FORMAT_I1: 0..1- for LV_COLOR_FORMAT_I2: 0..3- for LV_COLOR_FORMAT_I4: 0..15- for LV_COLOR_FORMAT_I8: 0..255 |
color | lv_color32_t | the color to set in lv_color32_t format |
draw/lv_draw_buf.h:373function
lv_image_buf_set_palette
> Deprecated: Use lv_draw_buf_set_palette instead.
void lv_image_buf_set_palette(lv_image_dsc_t *dsc, uint8_t id, lv_color32_t c)| Name | Type |
|---|---|
dsc | lv_image_dsc_t * |
id | uint8_t |
c | lv_color32_t |
Structs
struct
_lv_draw_buf_t
| Member | Type | Description |
|---|---|---|
header | lv_image_header_t | |
data_size | uint32_t | Total buf size in bytes |
data | uint8_t * | |
unaligned_data | void * | Unaligned address of data, used internally by lvgl |
handlers | const lv_draw_buf_handlers_t * | draw buffer alloc/free ops. |
Typedefs
draw/lv_draw_buf.h:78typedef
lv_draw_buf_malloc_cb_t
typedef void *(* lv_draw_buf_malloc_cb_t) (size_t size, lv_color_format_t color_format)Used by 1 function
lv_draw_buf_handlers_init— parambuf_malloc_cb
draw/lv_draw_buf.h:80typedef
lv_draw_buf_free_cb_t
typedef void(* lv_draw_buf_free_cb_t) (void *draw_buf)Used by 1 function
lv_draw_buf_handlers_init— parambuf_free_cb
draw/lv_draw_buf.h:82typedef
lv_draw_buf_copy_cb_t
typedef void(* lv_draw_buf_copy_cb_t) (lv_draw_buf_t *dest, const lv_area_t *dest_area, const lv_draw_buf_t *src, const lv_area_t *src_area)Used by 1 function
lv_draw_buf_handlers_init— parambuf_copy_cb
draw/lv_draw_buf.h:85typedef
lv_draw_buf_align_cb_t
typedef void *(* lv_draw_buf_align_cb_t) (void *buf, lv_color_format_t color_format)Used by 1 function
lv_draw_buf_handlers_init— paramalign_pointer_cb
draw/lv_draw_buf.h:87typedef
lv_draw_buf_cache_operation_cb_t
typedef void(* lv_draw_buf_cache_operation_cb_t) (const lv_draw_buf_t *draw_buf, const lv_area_t *area)Used by 2 functions
lv_draw_buf_handlers_init— paraminvalidate_cache_cblv_draw_buf_handlers_init— paramflush_cache_cb
draw/lv_draw_buf.h:89typedef
lv_draw_buf_width_to_stride_cb_t
typedef uint32_t(* lv_draw_buf_width_to_stride_cb_t) (uint32_t w, lv_color_format_t color_format)Used by 1 function
lv_draw_buf_handlers_init— paramwidth_to_stride_cb
Macros
LV_STRIDE_AUTO
#define LV_STRIDE_AUTO 0Use this value to let LVGL calculate stride automatically
LV_DRAW_BUF_STRIDE
#define LV_DRAW_BUF_STRIDE(w, cf) \
LV_ROUND_UP(((w) * LV_COLOR_FORMAT_GET_BPP(cf) + 7) / 8, LV_DRAW_BUF_STRIDE_ALIGN)Stride alignment for draw buffers. It may vary between different color formats and hardware. Refine it to suit your needs.
LV_DRAW_BUF_SIZE
#define LV_DRAW_BUF_SIZE(w, h, cf) \
(LV_DRAW_BUF_STRIDE(w, cf) * (h) + LV_DRAW_BUF_ALIGN + \
LV_COLOR_INDEXED_PALETTE_SIZE(cf) * sizeof(lv_color32_t))Allocate a slightly larger buffer, so we can adjust the start address to meet alignment
LV_DRAW_BUF_DEFINE_STATIC
#define LV_DRAW_BUF_DEFINE_STATIC(name, _w, _h, _cf) \
static LV_ATTRIBUTE_MEM_ALIGN uint8_t buf_##name[LV_DRAW_BUF_SIZE(_w, _h, _cf)]; \
static lv_draw_buf_t name = { \
.header = { \
.magic = LV_IMAGE_HEADER_MAGIC, \
.cf = (_cf), \
.flags = LV_IMAGE_FLAGS_MODIFIABLE, \
.w = (_w), \
.h = (_h), \
.stride = LV_DRAW_BUF_STRIDE(_w, _cf), \
.reserved_2 = 0, \
}, \
.data_size = sizeof(buf_##name), \
.data = buf_##name, \
.unaligned_data = buf_##name, \
}Define a static draw buffer with the given width, height, and color format. Stride alignment is set to LV_DRAW_BUF_STRIDE_ALIGN.
For platform that needs special buffer alignment, call LV_DRAW_BUF_INIT_STATIC.
LV_DRAW_BUF_INIT_STATIC
#define LV_DRAW_BUF_INIT_STATIC(name) \
do { \
lv_image_header_t * header = &name.header; \
lv_draw_buf_init(&name, header->w, header->h, (lv_color_format_t)header->cf, header->stride, buf_##name, sizeof(buf_##name)); \
lv_draw_buf_set_flag(&name, LV_IMAGE_FLAGS_MODIFIABLE); \
} while(0)Dependencies
How is this guide?
Last updated on