Board: Huangshan Series, Function: Obtain JPEG image data online and display it via LVGL.
Currently, I’m able to successfully receive JPEG file data sent from a mobile phone. The data starts with the header FF D8 and ends with FF D9.
Initially, I intended to enable CONFIG_LV_USE_TJPGD and simply call lv_image_set_src(img_obj, data) to display the image.
However, when attempting to directly display the image using LVGL’s TJPGD decoding library, it didn’t work. After troubleshooting, I found that lv_image_set_src determines the input data type among three options: LV_IMAGE_SRC_FILE, LV_IMAGE_SRC_VARIABLE, and LV_IMAGE_SRC_SYMBOL.
LV_IMAGE_SRC_FILE: Reads from the file system. Since my JPEG data resides in memory rather than in a physical file, this option is invalid.LV_IMAGE_SRC_VARIABLE: Requires data structured aslv_img_dsc_t, which holds decoded raw pixel data (e.g., RGB565). This is typically used for images embedded directly in code. Since my input is compressed JPEG data in memory, it cannot be used directly.LV_IMAGE_SRC_SYMBOL: Refers to built-in LVGL symbol icons, which clearly doesn’t apply here.
Therefore, I’ve considered the following possible solutions:
-
Use an external JPEG decoder library to decode the JPEG data into RGB565 format, construct a proper
lv_img_dsc_t, and then pass it tolv_image_set_src. However, I couldn’t find any relevant decoding examples or supported libraries in the SDK (LB52). -
Save the JPEG data into the file system using
lv_fs, then load it vialv_image_set_srcas a file. I tried this approach, but it quickly leads to memory exhaustion. Example memory status:total memory: 337188 used memory : 146272 maximum allocated memory: 152216Besides, I’d prefer to avoid this method due to inefficiency—writing to and reading from storage just for temporary image display impacts performance.
Could you please advise if there is a better way to achieve this functionality? Any guidance or suggestions would be greatly appreciated. Thank you!