Display Custom Image with LVGL

I can display a custom image with the following example code (from the Arduino examples):

#include "Arduino_H7_Video.h"
#include "ArduinoGraphics.h"

#define INCBIN_PREFIX
#include "incbin.h"
INCBIN(test, "/home/reza/Arduino/custom_image/GIGADisplayShieldBack.bin");

Arduino_H7_Video Display(800, 480, GigaDisplayShield);
Image img_arduinologo(ENCODING_RGB16, (uint8_t *) testData, 643, 482);

void setup() {
Display.begin();
Display.beginDraw();
Display.image(img_arduinologo, (Display.width() - img_arduinologo.width())/2, (Display.height() - img_arduinologo.height())/2);
Display.endDraw();
}

void loop() { }

However when I try the same exercise using LVGL code (again from Arduino examples), the screen does not display the custom image:

#include "Arduino_H7_Video.h"
#include "lvgl.h"

Arduino_H7_Video Display(800, 480, GigaDisplayShield);

void setup() {
  Display.begin();
  lv_obj_t * screen = lv_obj_create(lv_scr_act());
  lv_obj_set_size(screen, Display.width(), Display.height());
  static lv_coord_t col_dsc[] = { 642, LV_GRID_TEMPLATE_LAST};
  static lv_coord_t row_dsc[] = { 483, LV_GRID_TEMPLATE_LAST};
  lv_obj_t * grid = lv_obj_create(lv_scr_act());
  lv_obj_set_grid_dsc_array(grid, col_dsc, row_dsc);
  lv_obj_set_size(grid, Display.width(), Display.height());
  lv_obj_center(grid);
  lv_obj_t * obj;
  lv_obj_t * img1;
  obj = lv_obj_create(grid);
  lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_STRETCH, 0, 1,
                        LV_GRID_ALIGN_STRETCH, 0, 1);
  LV_IMG_DECLARE(custom_image);
  img1 = lv_img_create(obj);
  lv_img_set_src(img1, "/home/reza/Arduino/custom_image_lvgl/GIGADisplayShieldBack.bin");
  lv_obj_align(img1, LV_ALIGN_CENTER, 0, 0);
  lv_obj_set_size(img1, 642, 483);
}

void loop() {
  lv_timer_handler();
}

The call to lv_img_set_src does not return any error (i.e. custom image file was read). The custom image resolution is 642x483 but no partial image is displayed let alone the full image that gets rendered when using the ArduinoGraphics library. I've also checked and found that the variable img1 is not NULL.

Suggestions on any workaround are welcome. Thanks.

Regards.

Hello!
What source is the initial code snippet from so I can test it too? The image_lvgl example included in the GigaDisplay library seems to be run a little differently hence the question.
Please note that even if lv_img_set_src fails to read the image at that location this will still run with no error.

Hi @psousalima, I encountered below issue when I want to use a custom image. Could you please help me? thanks in advance!

WARNING: library ArduinoGraphics claims to run on samd architecture(s) and may be incompatible with your current board which runs on mbed_giga architecture(s).
In file included from C:\Users\shakhizat\Documents\Arduino\ArduinoLogo\ArduinoLogo.ino:16:0:
C:\Users\shakhizat\Documents\Arduino\ArduinoLogo\incbin.h:363:13: error: incomplete universal character name \U
             ".text\n" \
             ^
C:\Users\shakhizat\Documents\Arduino\ArduinoLogo\incbin.h:363:13: note: in definition of macro 'INCBIN'
             ".text\n" \
             ^~~~~~~~~

exit status 1

Compilation error: incomplete universal character name \U```