Load PNG from SDCARD

Description

I want to load Image from SD-Card.

What MCU/Processor/Board and compiler are you using?

Espressif ESP32 WROVER

What LVGL version are you using?

v7.11

What do you want to achieve?

What have you tried so far?

Code to reproduce

lv_init();
lv_png_init();
lv_fs_if_fatfs_init();
lvgl_driver_init();
.
.
.
 lv_obj_t* img = lv_img_create(lv_scr_act(),NULL);
lv_img_set_src(img, S:hello.bmp);

Screenshot and/or video

Nothing happend, full white screen.

Seems to be, that you didn’t tell lvlg where to put the image in (e.g. position)

The doc example shows this:

    lv_obj_t * img1 = lv_img_create (lv_scr_act(), NULL);
    lv_img_set_src (img1, &img_cogwheel_argb);
    lv_obj_align (img1, NULL, LV_ALIGN_CENTER, 0, -20);
1 Like

Good idea, but still white screen.

Hmm,
I had assigned a style to the image with the opacity set to 100.
Don’t know, maybe this helps?

  lv_style_t gtSplashStyleDef; 


  lv_style_init                  (&gtSplashStyleDef);
  lv_style_set_bg_color          (&gtSplashStyleDef,      lv_color_make (255, 255, 255));
  lv_style_set_radius            (&gtSplashStyleDef,      0);
  lv_style_set_border_width      (&gtSplashStyleDef,      0);
  lv_style_set_bg_opa            (&gtSplashStyleDef,      LV_OPA_100);

 Your image creating code etc. here

  lv_obj_add_style (img,                               // Assign the new style to the status bar
                    &gtSplashStyleDef,
                    LV_PART_MAIN);

Unfortunately, that didn’t help either.

Log:
Trace: image create started (lv_img.c #62 lv_img_create())
Trace: Object create started (lv_obj.c #305 lv_obj_create())
Info: Object create ready (lv_obj.c #461 lv_obj_create())
Info: image created (lv_img.c #127 lv_img_create())

and nothing happend, full white screen.