How to fix image rendering issue in LVGL v9.2

Hi,

I have recently ported my project into LVGL v9.2. I am facing an issue while trying to draw an image or icon, which is common for all my icons. I have converted the PNG icon into the BIN format with RGB565 color format and loaded it into the external memory.

When I draw the icon using an absolute path, such as “0:/to/the/path/my_icon.bin,” it renders perfectly. However, when I cache it into PSRAM and then attempt to draw it, I encounter a problem. The icon appears trimmed on the right side, while an extra area is displayed on the left side, as shown in the picture below.

Below is the property I am using to render the cache icon:
const lv_img_dsc_t music_img_ps = {
.header.magic = LV_IMAGE_HEADER_MAGIC,
.header.w = 52,
.header.h = 51,
.header.stride = 52 * 2,
.data_size = 52 * 51 * 2,
.header.cf = LV_COLOR_FORMAT_RGB565,
.header.flags = 0,
.data = (const uint8_t*)PSRAM_MUSIC_ADDR,
};

My function to draw the icon:
void draw_the_icon()
{
lv_obj_t *img_tst = lv_img_create(lv_scr_act());
lv_img_set_src(img_tst, &music_img_ps);
lv_obj_align(img_tst, LV_ALIGN_TOP_MID, 75, 250);
}

I am allocating 5316 bytes of memory for the caching which is the binary file size of the same icon.

Kindly, provide me with some ideas or techniques to overcome the same.

Thanks & regards,
Amaresh Ray

You don’t have to worry about setting most of the image stuff…

Your data size is not right either. The bin file is not RAW RGB565 data, there is header data in there as well. I don’t know if the header data is a fixed size or if it is variable. I did a quick test using an 800 x 600 image converted to RGB565 and there is 12 bytes of header data in that image. If it is a fixed size then this would work for ya.

const lv_img_dsc_t music_img_ps = {
    .data_size = 52 * 51 * 2 + 12,
    .data = (const uint8_t*)PSRAM_MUSIC_ADDR,
};

That is all you would need for the image descriptor as the decoder will be able to determine the type of data.

Also if you are using version 9.2 why are you using the old API names???