How to set a img as the background image

Description

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

STM32f407

What LVGL version are you using?

7.7.0

What do you want to achieve?

Set a img as the background image, and put other widgets on the background image.

What have you tried so far?

Code to reproduce

/You code here/

    lv_img_set_src(img, &bgimg);
    lv_obj_set_pos(img,10,50); 

## Screenshot and/or video
If possible, add screenshots and/or videos about the current state.

Just simply add img first on the screen, and then any other widget can be added after it to screen, or just a child of img.
Visible LVGL “screen” can be built as tree-hierarchy from the objects (just like HTML DOM), so you add also child LVGL objects to img.

For example (MicroPython code):

screen = lv.obj()

# Set background image
background_image = lv.img(screen)
background_image.center()

# Add child button to parent screen, it will be shown in front of background image
button1 = lv.btn(screen)
button1.set_pos(x, y)

# Add child button to image parent, it will be also shown in front of background image
button2 = lv.btn(background_image)
button2.set_pos(x, y)

# Show screen
lv.scr_load(screen)

That’s perfect! Thanks a lot!

Sorry @wushili , does it really work for an image which is sourced from a file as a binary file and it does not give an effect to another object?

I have tried it, since I used an lcd touchscreen, it works but gives a slow response when touching it, and the MCU often restarts by itself.

The MCU I use is ESP32