lv_draw_buf.h

API reference for lv_draw_buf.h

Report on GitHub
See Also: Private HeaderThis header has a companion private implementation with internal data structures.lv_draw_buf_private.h

Functions

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)
Parameters
NameTypeDescription
draw_buflv_draw_buf_t *pointer to a draw buffer
flaglv_image_flags_tthe flag to set

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)
Parameters
NameTypeDescription
draw_buflv_draw_buf_t *pointer to an image descriptor
indexuint8_tthe 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
colorlv_color32_tthe color to set in lv_color32_t format

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)
Parameters

Structs

struct

_lv_draw_buf_t

MemberTypeDescription
headerlv_image_header_t
data_sizeuint32_tTotal buf size in bytes
datauint8_t *
unaligned_datavoid *Unaligned address of data, used internally by lvgl
handlersconst lv_draw_buf_handlers_t *draw buffer alloc/free ops.

Typedefs

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 — param buf_malloc_cb

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 — param buf_free_cb

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 — param buf_copy_cb

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 — param align_pointer_cb

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 — param invalidate_cache_cb
  • lv_draw_buf_handlers_init — param flush_cache_cb

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 — param width_to_stride_cb

Macros

LV_STRIDE_AUTO

 
#define LV_STRIDE_AUTO 0

Use 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

On this page