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!");
}
}