Runtime PNG Load

Description

I am trying to set the PNG image from the downloaded at runtime bytes, but the display only shows “PNG” label.

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

esp32 with 4MB flash

What LVGL version are you using?

8.3.4

What do you want to achieve?

Load PNG at runtime

What have you tried so far?

Load it through the lv_img_set_src(ui_avatar, startPtr) where startPtr is a pointer to the bytes array.

Code to reproduce

void ui_try_load_avatar(String avatarUrl) {
  const char* startPtr;
  size_t size;
  Serial.println("Attempting to download avatar from " + avatarUrl);
  auto status = download_file(avatarUrl, startPtr, size);
  if (status) {
    Serial.println("Successfully downloaded avatar!");
    lv_img_set_src(ui_avatar, startPtr);
  }
  else {
    Serial.println("Failed to download avatar!");
  }
}

UPD:
I also tried this way

void ui_try_load_avatar(String avatarUrl) {
  const char* startPtr;
  size_t size;
  Serial.println("Attempting to download avatar from " + avatarUrl);
  auto status = download_file(avatarUrl, startPtr, size);
  if (status) {
    Serial.println("Successfully downloaded avatar!");
    lv_img_dsc_t png_dsc;
    png_dsc.data = (const uint8_t*)startPtr;
    png_dsc.data_size = size;
    png_dsc.header.always_zero = 0;
    png_dsc.header.cf = LV_IMG_CF_RGBA8888;
    png_dsc.header.w = 200;
    png_dsc.header.h = 200;
    lv_img_set_src(ui_avatar, &png_dsc);
  }
  else {
    Serial.println("Failed to download avatar!");
  }
}

Screenshot and/or video

where is

lv_obj_t* ui_avatar;
and where is
ui_avatar=lv_img_create(lv_scr_act());
??
u need to make base object. then u need to convert it to image and place it on layer by lv_img_create
then u can set source of image.

ui_avatar = lv_img_create(ui_main_screen);
lv_obj_set_width(ui_avatar, LV_SIZE_CONTENT);
lv_obj_set_height(ui_avatar, LV_SIZE_CONTENT);
lv_obj_set_align(ui_avatar, LV_ALIGN_CENTER);
lv_img_set_pivot(ui_avatar, 512, 512);
lv_img_set_zoom(ui_avatar, 60);

ok then i would try to use lvgl image converter to temporary add png converted image and use it to determine what causes a problem ( adding png runtime or this is problem with image object in lvgl)

so u need to separate those operations.
but looks like problem is with png loading.
also u can try to write method that prints binary hex data to terminal and compare this data with actual data of png

Hey! Thanks for your response. I tried it and now it says that:
_lv_img_cache_open: Image draw cannot open the image resource (in lv_img_cache.c line #125)