How to load PNG file from sd card to lv_img's object?

Image source. How to set up FS FS

It compulsory need to add source file of image to my main project?

Whenever i try to load image from external flash as a SD card, it shows undefine reference to ‘my_image’. i declared LV_IMG_DECLARE(my_image) then also it gives error.

this only needs to be done for c array. To open an image from an SDCard, first connect lv_fs then check if reading works with a simple example (write a file on the SDCard for example test.txt, put information into it and try to read it using LVGL, example FS Test). Then connect the PNG decoder lv_lib_png
P.S. Note that you need enough RAM for this. Personally, on an STM32 with 64 kb, I did not manage to normally use images using LVGL tools. Had to draw without LVGL

lv_img_set_src() from this function it goes to memory management fault.
i am trying to open images .c file from SD card. any hint?

attach your code and where the error is

#if LV_USE_IMG
LV_IMG_DECLARE(_clc_alpha_20x20_map);

static void my_lvgl_test(void)
{
lv_obj_t * img1 = lv_img_create(lv_scr_act(), NULL);

/*From file*/
lv_img_set_src(img1,"S:/img/_clc_alpha_20x20.c");

}
int main(void)
{
/* Init board hardware. /
/
Set the eLCDIF read_qos priority high, to make sure eLCDIF
* can fetch data in time when PXP is used.
*/
((volatile uint32_t) 0x41044100) = 5;

int i = 0;
FRESULT error;

BOARD_ConfigMPU();
BOARD_InitPins();
//BOARD_InitI2C1Pins();
//BOARD_InitSemcPins();
BOARD_BootClockRUN();
BOARD_InitDebugConsole();

PRINTF("littlevgl bare metal widgets demo\r\n");

lv_init();
lv_port_pre_init();
lv_port_disp_init();        // Display initialization

// lv_port_indev_init(); // Input device initialization

// APP_InitDisplay();
if (0 != MOUNT_SDCard()) {
PRINTF(“SD card mount error. Demo stopped!”);
return -1;
}

lv_port_fs_init();          // File system device initialization

my_lvgl_test();

}

this code not working, is this right format?

This is not needed if you are downloading from an SDCard.

LV_IMG_DECLARE(_clc_alpha_20x20_map);

Here you have to download the * .png file itself from the SDCard

/*From file*/
lv_img_set_src(img1,"S:/img/_clc_alpha_20x20.png");

A png decoder is also needed. It is not in the code lv_lib_png.
then you can go under debug into the function lv_img_set_src and make sure that the decoder and fatfs are working by looking at the filling of the fields

...
    img->src_type = src_type;
    img->w        = header.w;
    img->h        = header.h;
    img->cf       = header.cf;
    img->pivot.x = header.w / 2;
    img->pivot.y = header.h / 2;
...

If the parameters of your image correspond to the fields, then move on

okay, but i am trying to display image from .c array file which is stored in SD card, because not enough memory available to include .c files into main project.
in this format no error coming but not display image on LCD.

GUI guider only gives .c files, not possible to convert into .png files therefore this issues arrives.

As far as i know the * .c file cannot be displayed with sdcard. Let me be corrected if I’m wrong. Theoretically, you can infect a * .c file as an array by allocating memory through the same maloc. You will also have to describe lv_img_dsc_t. This is a tricky method

https://lvgl.io/tools/imageconverter

here given that we can use it from sd card

For external binary files (e.g. SD card)

  1. Set up a new driver. To learn more read the Documentation.
  2. Set the image for an lv_img object: lv_img_set_src(img1, “S:/path/to/image”);

If you want decoded file you need to convert to * .bin (BinaryRGBxxx) and not * .c and download it from sdcard exactly the same lv_img_set_src(img1,“S:/img/_clc_alpha_20x20.bin”);

it displays only white background

Is there an inscription “no data”? If not, check if the file header (width, height, for example) was read correctly as described above

Hi, is this problem resolved. i am also trying to read .c array files which is generated from the gui guider from the SDcard don’t know how to proceed. could you please help me with this?

Hello sir, could you provide the updated link for that blog, the link you provided is not opening.