JPEG decoder not working on converted JPEG to C array using CF_RAW

Description

Using lv_img_dsc_t JPEG .c file is not working for displaying the image using jpeg decoder

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

RP2040

What LVGL version are you using?

8.3.6

What do you want to achieve?

My main goal is to use a jpeg in uint8_t format to create a lv_img_dsc_t, then display it using LVGL.

What have you tried so far?

I’ve tried manually create the image using a jpeg in uint8_t format, and tried to use a C array file in CF_RAW of the jpeg, but it only shows NO DATA

Code to reproduce

#include "../ui.h"
// Define a global label object for updating the text
lv_obj_t *ui_label;
lv_obj_t *img;
lv_img_dsc_t my_img_dsc;
// Callback function to update label text with Bluetooth data
void callback_to_ui_screen(const char *data)
{
    // Update the label text with the received Bluetooth data
    // lv_obj_t *ui_label1;
    lv_label_set_text(ui_label, data);
}
//Callback function to update image displayed with Bluetooth data
void processReceivedImage(const uint8_t *decodedImageData) {
  
  // Create an image descriptor
  lv_img_dsc_t my_img_dsc = {
    .header.always_zero = 0,
    .header.reserved = 0,
    .header.w = 240,
    .header.h = 240,
    .data_size = 11416, // Value extracted from the file i am testing, i will turn it dynamic after 
    .header.cf = LV_IMG_CF_RAW_CHROMA_KEYED, // Tried to use LV_IMG_CF_RAW, didn't work either
    .data = decodedImageData,
  };
  lv_img_set_src(ui_Image2, &testjpg);
}

void ui_Screen1_screen_init(void)
{

    ui_Screen1 = lv_obj_create(NULL);
    lv_obj_clear_flag(ui_Screen1, LV_OBJ_FLAG_SCROLLABLE);
    lv_obj_t *img;
    ui_Image2 = lv_img_create(ui_Screen1);
    lv_img_set_src(ui_Image2, &egi);
    lv_obj_set_width(ui_Image2, LV_SIZE_CONTENT);
    lv_obj_set_height(ui_Image2, LV_SIZE_CONTENT);
    lv_obj_set_align(ui_Image2, LV_ALIGN_CENTER);
}

I’m forgetting to include something to make it work?

If enabled in lv_conf.h by LV_USE_SJPG

I already did it “#define LV_USE_SJPG 1”, just correcting one thing that i said, it doesn’t show NO DATA, it just displays a blank white screen, if anyone knows what i’m doing wrong please help me

You did it in actual lv_conf.h ?
Your testjpg have SJPG header ?
And i dont understand your func processReceivedImage
my_img_dsc vs testjpg pointers?? LVGL example is

void lv_example_sjpg_1(void)
{
    lv_obj_t * wp;

    wp = lv_img_create(lv_scr_act());
    /* Assuming a File system is attached to letter 'A'
     * E.g. set LV_USE_FS_STDIO 'A' in lv_conf.h */
    lv_img_set_src(wp, "A:lvgl/examples/libs/sjpg/small_image.sjpg");
}

I did it in lv_conf.h.

testjpg is a JPG file in c array (testjpg.h), that i converted using the online image converter (CF_RAW color format)

The processReceivedImage is a function that i’m testing the jpeg decoder, both my_img_dsc and testjpg are the same, but one i’m creating based on bluetooth data, that is the JPEG uint8_t, and the testjpg is the file i converted online that was declared ( LV_IMG_DECLARE(testjpg) ), they are getting the same result, just a white blank screen.

The thing is, i think it should be work because in the documentation says File read from file and c-array are implemented.

I’m gonna try with SJPG to see if it’s gonna work but i don’t know if is gonna be it

No way, it was it! Probably the MCU doesn’t have enough RAM to decode JPEG?
Now i’m gonna need to make a script to transform JPG to SJPG, but i have an idea of how to do it.

Thanks for the help!

GitHub - lvgl/lv_lib_split_jpg: JPG decoder for LVGL