Description
img lose when touch the button several times and console reports
[Error] (161.411, +81) lv_mem_alloc: couldn’t allocate memory (4140 bytes) (in lv_mem.c line #135)
What MCU/Processor/Board and compiler are you using?
F1C100S LicheePiNano with gcc
What LVGL version are you using?
v8.1.0-dev
What do you want to achieve?
keep the img background
What have you tried so far?
try to increase LV_MEM_SIZE, problem still exsit ,is any one can help me to solve this problem?
tks
Code to reproduce
Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.
char bgbuf[32];
void test_btn_on_img(void)
{
static lv_style_t style;
lv_scr_load(lv_scr_act());
lv_style_init(&style);
// lv_style_set_bg_color(&style, lv_palette_main(LV_PALETTE_YELLOW));
lv_style_set_bg_opa(&style, LV_OPA_COVER);
lv_style_set_width(&style, LV_HOR_RES);//480
lv_style_set_height(&style, LV_VER_RES);//272
lv_style_set_x(&style,0);
lv_style_set_x(&style,0);
// lv_style_set_img_recolor_opa(&style, LV_OPA_COVER);
// lv_style_set_img_recolor(&style, lv_color_black());
lv_obj_t* img = lv_img_create(lv_scr_act());
lv_obj_remove_style_all(img);
lv_obj_add_style(img, &style, 0);
sprintf(bgbuf,"S:pic/1.bin"); //1.bin stored in fat system of SPI flash
lv_img_set_src(img,bgbuf);
lv_obj_set_size(img,480,272);
static lv_style_t bt_style;
lv_style_init(&bt_style);
lv_style_set_bg_color(&bt_style, lv_palette_main(LV_PALETTE_YELLOW));
lv_style_set_bg_opa(&bt_style, LV_OPA_COVER);
lv_obj_t* btn = lv_btn_create(img);
lv_obj_set_pos(btn, 100, 30);
lv_obj_set_size(btn, 150, 100);
// lv_obj_center(img);
}
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.