Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lv_lib_png showing white rectangle #7

Open
matinrn opened this issue Jan 21, 2021 · 11 comments
Open

Lv_lib_png showing white rectangle #7

matinrn opened this issue Jan 21, 2021 · 11 comments

Comments

@matinrn
Copy link

matinrn commented Jan 21, 2021

Hello
I'm using esp32(arduino framework) + lvgl + lv_lib_lodepng.
when I try to show a png image it doesn’t work. it only shows a white rectangle with a “No data” text on the top left corner. I tried to Use PNG images from flash and file as instructed in the README file of the library and none of them works. the problem is only with png files because when i use a true color image it works fine.
I also Enabled the log module on LV_LOG_LEVEL_WARN level and the following lines are printed in the console:
.pio\libdeps\esp32dev\lvgl\src\lv_draw\lv_img_cache.c@131->fnn: _lv_img_cache_open ->Image draw cannot open the image resource .pio\libdeps\esp32dev\lvgl\src\lv_draw\lv_draw_img.c@87->fnn: lv_draw_img ->Image draw error
also the same code works in vs simulator and the problem only occurs when I’m using esp32.
Code to reproduce
void setup() { display_init(); touch_init(); lv_fs_if_init(); LV_IMG_DECLARE(png_decoder_test); lv_obj_t *img = lv_img_create(lv_scr_act(), NULL); lv_img_set_src(img, &png_decoder_test); } void loop() { lv_task_handler(); delay(5); }
the lv_png_init() is inside the display_init() function.
Screenshot and/or video
2f7e7d4ebaea75d69a2f2a12e2ebfcc70f1ad4bb

@embeddedt
Copy link
Member

My educated guess would be that you are running out of heap space.

@matinrn
Copy link
Author

matinrn commented Jan 30, 2021

My educated guess would be that you are running out of heap space.

I don't think that's the case here, because esp32 has 294k free heap before trying to show the image while the image size is only 20k.

@kisvegabor
Copy link
Member

What is the resolution of the image?

It needs minimum hor. res. x ver. res. x 4 bytes

@matinrn
Copy link
Author

matinrn commented Feb 2, 2021

What is the resolution of the image?

It needs minimum hor. res. x ver. res. x 4 bytes

I'm using the image that came with the library (png_decoder_test.c) which is 200 x 150 and it needs 200 x 150 x 4=120kB which is about 1/3 of esp's free heap (294kB) in this project.

@kisvegabor
Copy link
Member

Do you see anything suspicious if you enable logging in lv_conf.h?

@matinrn
Copy link
Author

matinrn commented Feb 4, 2021

Do you see anything suspicious if you enable logging in lv_conf.h?

I can't figure out the problem from the logs so I just post them here.

there's no log on LV_LOG_LEVEL_ERROR.
here's the log on LV_LOG_LEVEL_WARN:
.pio\libdeps\esp32dev\lvgl\src\lv_draw\lv_img_cache.c@135->fnn: _lv_img_cache_open ->Image draw cannot open the image resource .pio\libdeps\esp32dev\lvgl\src\lv_draw\lv_draw_img.c@88->fnn: lv_draw_img ->Image draw error .pio\libdeps\esp32dev\lvgl\src\lv_draw\lv_img_cache.c@135->fnn: _lv_img_cache_open ->Image draw cannot open the image resource .pio\libdeps\esp32dev\lvgl\src\lv_draw\lv_draw_img.c@88->fnn: lv_draw_img ->Image draw error .pio\libdeps\esp32dev\lvgl\src\lv_draw\lv_img_cache.c@135->fnn: _lv_img_cache_open ->Image draw cannot open the image resource .pio\libdeps\esp32dev\lvgl\src\lv_draw\lv_draw_img.c@88->fnn: lv_draw_img ->Image draw error .pio\libdeps\esp32dev\lvgl\src\lv_draw\lv_img_cache.c@135->fnn: _lv_img_cache_open ->Image draw cannot open the image resource .pio\libdeps\esp32dev\lvgl\src\lv_draw\lv_draw_img.c@88->fnn: lv_draw_img ->Image draw error

and here's the pastebin link for the log on LV_LOG_LEVEL_INFO.

@kisvegabor
Copy link
Member

Have you called lv_png_init()?

@matinrn
Copy link
Author

matinrn commented Feb 10, 2021

Have you called lv_png_init()?

Yes, I've called it right after calling lv_init().

@kisvegabor
Copy link
Member

I've tested it on PC and worked well for me.

I suggest debugging the devoder_open() function to see why it can't open the imaga.

@matinrn
Copy link
Author

matinrn commented Feb 11, 2021

I suggest debugging the devoder_open() function to see why it can't open the imaga.

I did it and function lodepng_decode32() which is called inside decoder_open() returns error 83 which means "memory allocation failed".
I used smaller pictures and it worked fine with a 150x100 png c array, but fails with a 200x100 one.
It's still confusing since esp32 has about 300kB free ram available and a 200x100 png c array needs only ~80kB of ram.

@kisvegabor
Copy link
Member

It's more than 80kB because the one decoder uses some internal working buffers too, but it shouldn't be an extra 220 kB.

Maybe it's somehow specific to ESP32 memory manager.

You can try to change lodepng's malloc/free to lv_mem_alloc/realloc/free and give areally large LV_MEM_SIZE to LVGL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants