Display jpg array on Arduino Giga display

Apologies if my question really makes clear that I have insufficient understanding about LVGL. Despite this, I do hope someone is willing to Gove me some help beyond “read the documentation”.

I use the Arduino IDE and try to display a JPG on the Arduino Giga Display using the Arduino R1.

I also browsed the Arduino forum and asked some questions, but apparently it appears to be complex.

I have an array which contains JPG data const uint8_t panda[]. You can find this panda as part of the TJpg_Decoder : GitHub - Bodmer/TJpg_Decoder: Jpeg decoder library based on Tiny JPEG Decompressor

The link to the panda array can be found here : https://github.com/Bodmer/TJpg_Decoder/tree/master/examples/SD%20Card/SD_Jpg/data

In this link Tiny JPEG Decompressor (TJpgDec) — LVGL documentation

I found that If enabled in lv_conf.h by LV_USE_TJPGD LVGL will register a new image decoder automatically so JPEG files can be used directly as image sources.

So in my lv_conf.h file which resides within the lvgl folder I have the following statement

/* JPG + split JPG decoder library.

  • Split JPG is a custom format optimized for embedded systems. */

#define LV_USE_TJPGD 1

In this link : Images — LVGL documentation

It says :

You can store images in a Raw format to indicate that it’s not encoded with one of the built-in color formats and an external Image decoder needs to be used to decode the image.

So I created a struct :

lv_img_dsc_t Panda_dsc_struct;

And filled it as follows :

Panda_dsc_struct.header.cf = LV_IMG_CF_RAW; //LV_IMG_CF_TRUE_COLOR;

Panda_dsc_struct.header.always_zero = 0;

Panda_dsc_struct.header.reserved = 0;

Panda_dsc_struct.header.w = 480; //200;

Panda_dsc_struct.header.h = 320; //150;

Panda_dsc_struct.data_size = 15000; //30000 * LV_COLOR_SIZE / 8;

Panda_dsc_struct.data = panda; //file_buffer;

Where panda is the data array containing the JPG data.

Then I use Arduino code to try to displat this panda jpg. This code has been tested with another c-array containing an Arduino logo and it works.

Please find include the Arduino code i am using. I left out the panda array because that one is very large.

And again, maybe I have no idea what I am doing, but nothing is being displayed.

Could someone help out how to display a JPG data array?

Many thanks,

My Code :

// according to this link Tiny JPEG Decompressor (TJpgDec) — LVGL documentation

// If enabled in lv_conf.h by LV_USE_TJPGD LVGL will register a new image decoder automatically so JPEG files can be used directly as image sources.

// according to this link : Images — LVGL documentation

// LV_COLOR_FORMAT_RAW: Indicates a basic raw image (e.g. a PNG or JPG image).

#include “Arduino.h”

#include “Arduino_H7_Video.h”

#include “lvgl.h”

#include <TJpg_Decoder.h> // I am not sure why to include this one

Arduino_H7_Video Display(800, 480, GigaDisplayShield);

const unsigned int max_File_size=62000;

uint8_t file_buffer[max_File_size];

const uint8_t panda[] // i have omitted the data here

lv_img_dsc_t Panda_dsc_struct;

void setup() {

Serial.begin( 115200 );

while (!Serial && millis() < 5000);

delay(500);

Serial.print("LV_COLOR_DEPTH : ");

Serial.println(LV_COLOR_DEPTH);

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[] = { 500, LV_GRID_TEMPLATE_LAST};

static lv_coord_t row_dsc[] = { 400, 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;

Panda_dsc_struct.header.cf = LV_IMG_CF_RAW; //LV_IMG_CF_TRUE_COLOR;

Panda_dsc_struct.header.always_zero = 0;

Panda_dsc_struct.header.reserved = 0;

Panda_dsc_struct.header.w = 480; //200;

Panda_dsc_struct.header.h = 320; //150;

Panda_dsc_struct.data_size = 15000; //30000 * LV_COLOR_SIZE / 8;

Panda_dsc_struct.data = panda; //file_buffer;

lv_obj_t * img2;

img2 = lv_img_create(obj);

lv_img_set_src(img2, &Panda_dsc_struct);

lv_obj_align(img2, LV_ALIGN_CENTER, 100, 100);

lv_obj_set_size(img2, 400, 300);

lv_refr_now(lv_disp_get_default());

Serial.println(“Image ready”);

}

void loop() {

// put your main code here, to run repeatedly:

}