Hi,
I am using LVGL (version 8.4) on esp32 and want to read images loaded on an external nand flash (I used the spi_nand_flash library).
I enabled in the menuconfig of esp-idf the library for PNG images.
But when I call the function lv_img_set_src(img, “/flash/IMG_2550.PNG”);
the screen remains blank.
Surely I have omitted some configuration, I ask for your help. Can you help me with the initial configuration?
A common problem when using png images is running out of allocated memory
Hi @glory-man ,
I went ahead with debugging, inserting the FF library now with the lv_fs_
functions I can retrieve the filenames, but when I open them I get this error back: assert failed: block_locate_free tlsf.c:566 (block_size(block) >= size)
.
I increased LV_MEM_BUF_MAX_NUM to 128, beyond that I can’t go, maybe I should stay at 64.
I have increased LV_FS_FATFS_CACHE_SIZE but this seems to have no effect on how the image reading works?
I have 148kb images, should I reduce them in size? or change image format?
I will add a specification I am using an esp32-s3
the main problem is the amount of memory available to lvgl in general. so if you have an image with a resolution of 1024x768 lvgl will require 1024x768x4 = 3,145,728 bytes = 3,072 KB + the size of the png file itself
On esp-idf where do I configure how much memory to give to LVGL?
My image is 262x393 resolution, has size 144.3 KB, and I want to put it at full-screen on a 272x480 display. If I understand correctly, the problem is that I don’t have enough memory for 144.3KiB?
So in your case 262x393x4 = 402 KB need to allocate to store unpacked image, but during unpacking you need buffer to store unpacked png-file, so +144 KB = ~547 KB. After unpacking the required memory size may be reduced because the image is then brought into line with the lvgl color depth (for example, for 16bit depth = 262x393x2 = 201KB), but during upacking you need at least ~547 KB.
Unfortunately I am not familiar with esp-idf and can not help with the settings of this environment. but the amount of memory allocated for lvgl is set in the file lv_conf.h using LV_MEM_SIZE
@glory-man
I am trying to display image of LVGL’s PNG example (5KB), but still the same error comes back. Maybe I need to configure something in code, on the buffer. Here is the code I am using to retrieve image:
LV_IMG_DECLARE(img_wink_png);
lv_obj_t * img;
img = lv_img_create(lv_scr_act());
lv_img_set_src(img, "A:wink.png");
lv_obj_align(img, LV_ALIGN_RIGHT_MID, 0, 0);
I think it should work if you will use
lv_img_set_src(img, &img_wink_png);
but in this case your image will be inserted in application binary file as preconverted by ImageConverter