Problems with lv_img component

Hi everyone!

I would like to congratulate the developers for this amazing tool!
So, I am working in a project that uses a monochrome 128*64 display. In this project, my board receives a picture formated in a C array (created by the online tool converter).
The problem occurs as, when I print the picture, although it is perfectly shown on screen, it will never get off the screen. It seems to me that the buffer is always being filled with the image, no matter what I try to show next (other picture, text label, etc.)
The code below is where I show the picture:

void showImage(){
    lv_obj_t * scr = lv_disp_get_scr_act(disp);              /*Get the current screen*/
    lv_obj_t * img_var = lv_img_create(scr, NULL);      /*Crate an image object*/
    lv_img_set_src(img_var, &logo_bradesco);            /*Set the created file as image*/
    lv_obj_set_pos(img_var, 0, 0);                                /*Set the positions*/
    lv_obj_set_drag(img_var, true);


I base my project on this exemple:

So, am I doing something wrong? Could this be a problem on LVGL? I am using the 6.0 version of the library.

LittlevGL is an object-oriented graphics library. Every time you are calling showImage, it creates a new image object and puts it on the screen. It sounds like you are never deleting the image object (with lv_obj_del).

In fact, I have never used (neither seen) the lv_obj_del function.

Does using this function requires all my objects to be globally declared? Or is there some way to retrieve the object information to be deleted from within my showImage function?

You have to find some way of retaining the lv_obj_t * value returned by lv_obj_create. How you do that is up to you.

Oh, I see. I will work on that and post the solution later. Thanks for your help so far!!

If you haven’t already, I strongly suggest reading the documentation that is relevant to what you are trying to do (i.e. objects overview).

Hi !
Can you share me how to receive a picture formated in C array by lvgl img tool. I am recently working on a project to get an image via websocket, the image is base64 encoded and I’m trying to put it on the screen during runtime. But i have no solution to decode it to C array like online tool converter to display, so can you tell me how you receive you picture and display it on screen please <3

Thank you so much!!!