lvgl / lv_binding_micropython

LVGL binding for MicroPython
MIT License
237 stars 156 forks source link

Can't show Image with jpg format. #285

Open HonestQiao opened 1 year ago

HonestQiao commented 1 year ago

My device: ESP32-S3-Box-Lite (N16R8V) + Display: ST7789 MycroPython: MicroPython v1.20.0-698-g3f25a765d on 2023-06-28; ESP32S3 Box Lite (spiram octal) with ESP32S3

My code:

import lvgl as lv
import lv_utils
import fs_driver

lv.init()
fs_drv = lv.fs_drv_t()
fs_driver.fs_register(fs_drv, 'S')

/* config for display */

scr = lv.scr_act()
cover_img = lv.img(scr)
cover_img.set_src("S:/images/zt_cover.png")
cover_img.set_size(180, 240)
cover_img.align(lv.ALIGN.TOP_LEFT, 0, 0)

If I use "S:/images/zt_cover.png" for cover_img.set_src(), the image will be displayed. zt_cover.png

If I use "S:/images/zt_cover.jpg" for cover_img.set_src(), the image wont be displayed. No error, only empty. zt_cover.jpg is convert from zt_cover.png. zt_cover.jpg

I tried to use ./lib/lv_bindings/lvgl/scripts/jpg_to_sjpg.py to convert zt_cover.jpg to zt_cover.sjpg, but zt_cover.sjpg can't be displayed either.

In ./lib/lv_bindings/lv_conf.h, LV_USE_SJPG is open:

/*PNG decoder library*/
#define LV_USE_PNG 1

/*BMP decoder library*/
#define LV_USE_BMP 1

/* JPG + split JPG decoder library.
 * Split JPG is a custom format optimized for embedded systems. */
#define LV_USE_SJPG 1

/*GIF decoder library*/
#define LV_USE_GIF 1

What is the problem?

amirgon commented 11 months ago

I'm not sure it's related but ESP32S3 is not officially supported by lv_micropython. Did you try to reproduce this problem in C? It's not clear to me if it's Micropython bindings issue of LVGL issue

PGNetHun commented 10 months ago

Hello! There is a bug in LVGL lv_sjpg.c file, the problem is the color format: https://github.com/lvgl/lvgl/issues/4407#issuecomment-1655861234

PGNetHun commented 10 months ago

@amirgon , The JPEG color format issue will be fixed by PR https://github.com/lvgl/lvgl/pull/4473 But please do not update LVGL library in binding yet, as there is another bug in JPEG rendering: https://github.com/lvgl/lvgl/issues/4407#issuecomment-1685254748

the call to JPEG decoder is removed in the parallel rendering architecture commit: https://github.com/lvgl/lvgl/commit/f753265a799bdd910881238cb36f8d731f6d8727#diff-90f14ebcd1b2e071c69ef3ad4020cb675f2484b26db670b0e455b1aec6cabdb0L78