Load a jpg picture from file and show it on screen

Description

I am developing an application for a Raspberri Pi that, among many other things, takes a picture and shows it on the screen.

The picture is acquired by a PiCamera, and stored in the local SD card as an jpg file.

I would like to show this picture on the screen.

So far all the examples I have found are old, the links to the code ar broken, or do not explain the procedure well enough.

Also, I cannot use the online converter, as this is too cumbersome when I am taking new pictures.

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

Raspberry Pi 3

What LVGL version are you using?

Latest, I believe, 9.2

What do you want to achieve?

I would like to show this picture on the screen. I am currently trying with a file of known size, named “490x300.jpg”.

I’d be very grateful for a code snippet that works for the latest version, please.

I have seen many posts asking for somthing similar - most of these posts go nowhere. So such a code snippet might help many users.

What have you tried so far?

    std::string source = "photos\\490x300.jpg";
    std::cout << "Showing last file: " << source << std::endl;  // Debug
    lv_img_set_src(img,(const void*)source.c_str());
    lv_obj_set_width(img, 490);
    lv_obj_set_height(img, 300);
    lv_obj_center(img);

It shows nothing on the screen.

Seems you dont like murphy laws read docu libjpeg-turbo decoder — LVGL documentation