Imported images (assets) don't work at runtime (v1.6.3)

Hello

I think there is an issue with the image imports (assets) of SquareLine Studio version 1.6.3, because I hadn’t that problem with a previous version of SqaureLine Studio with the same project.

I imported a 32bit + transparency PNG image file and I got this descriptor for it:

const lv_image_dsc_t ui_img_logo_e_t_a___2_png = {
.header.cf = LV_COLOR_FORMAT_I8,
.header.magic = LV_IMAGE_HEADER_MAGIC,
.header.w = 421,
.header.h = 141,
.data_size = 60385,
.data = ui_img_logo_e_t_a___2_png_map,
};

The output file size is 356KB.

Problem?

The image doesn’t show up at runtime on my ESP32-P4, although it’s shown on Squareline Studio.
The same happen with a second image. All the others are ok.
I compared the .c file of the same image I have created with a previous version of SqaureLine Studio.
The descriptor is surprisingly different:

const lv_image_dsc_t ui_img_logo_e_t_a___2_png = {
.header.w = 421,
.header.h = 141,
.data_size = sizeof(ui_img_logo_e_t_a___2_png_data),
.header.cf = LV_COLOR_FORMAT_NATIVE_WITH_ALPHA,
.header.magic = LV_IMAGE_HEADER_MAGIC,
.data = ui_img_logo_e_t_a___2_png_data
};

The output file size is 880KB.

And this one work!

So, I don’t know where the bug actually is. I don’t know why it happens to some images and others not. But it’s very annoying.

What do you want to achieve?

Display an image from my assets.

What have you tried so far?

I have tried to re-import the image file, but it still doesn’t show up on my ESP32-P4.

Screenshot or video

Others

  • SquareLine Studio version: 1.6.3 + lvgl v9.6
  • Operating system: Windows 11
  • Target hardware: ESP32-P4 (v3.2) + 10.1 inch LCD

The source image must have <=256 colors in the target hardware format. You can tell SquareLine to skip this optimization under project-settings, but you likely are missing color format support to render LVGL I8 → display-color on your device. Are you using the P4 PPA or software LVGL rendering?

image

EDIT: I’m not from SquareLine, just familiar with image conversion

Hi Digitix,

Thanks for the detailed report, and thanks Richard for pointing in the right direction.

Your image data is fine. The “Optimize image formats in C source export” option (Project Settings) picks the smallest lossless format for each image. It’s switched on for older projects when you open them in 1.6.3. Your logo has no more than 256 colors, so it was exported as LV_COLOR_FORMAT_I8, which is why the file got smaller.

LVGL’s software renderer can’t draw I8 images directly. With LV_BIN_DECODER_RAM_LOAD 1, it converts the whole image to ARGB8888 in RAM: about 232 KB for 421×141. If LVGL’s heap is smaller (the default LV_MEM_SIZE is 64 KB), the image isn’t drawn, and the log shows No memory for indexed image. The old RGB565A8 export was drawn straight from flash and needed no RAM.

How to fix it:

Uncheck “Optimize image formats in C source export” and export again. You’ll get the same output as with the previous version.
Or keep I8 and set LV_BIN_DECODER_RAM_LOAD 0, so images are converted line by line while drawing.
Or give LVGL more heap, e.g. LV_USE_STDLIB_MALLOC LV_STDLIB_CLIB with PSRAM enabled for malloc.

If none of these helps, please post your lv_conf.h (or sdkconfig) and the LVGL log.

Hello

Indeed this option was checked.

Everything works now.

Thank you very much.

1 Like