创建带色度键控的透明画布
#define CANVAS_WIDTH 800
#define CANVAS_HEIGHT 480
void lvgl_canvas_demo(void)
{
lv_btn_create(lv_scr_act());
static lv_color_t cbuf[LV_CANVAS_BUF_SIZE_INDEXED_1BIT(CANVAS_WIDTH, CANVAS_HEIGHT)];
lv_obj_t * canvas = lv_canvas_create(lv_scr_act());
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_IMG_CF_INDEXED_1BIT);
lv_canvas_set_palette(canvas, 0, LV_COLOR_CHROMA_KEY);
lv_canvas_set_palette(canvas, 1, lv_palette_main(LV_PALETTE_RED));
lv_color_t c0;
lv_color_t c1;
c0.full = 0;
c1.full = 1;
lv_canvas_fill_bg(canvas, c1, LV_OPA_COVER);
uint32_t x;
uint32_t y;
for( y = 100; y < 300; y++)
{
for( x = 50; x < 200; x++)
{
lv_canvas_set_px_color(canvas, x, y, c0);
}
}
}
效果图