How to set a image as background image?

Important: unclear posts may not receive useful answers.

Before posting

  • Get familiar with Markdown to format and structure your post
  • Be sure to update lvgl from the latest version from the master branch.
  • Be sure you have checked the FAQ and read the relevant part of the documentation.
  • If applicable use the Simulator to eliminate hardware related issues.

Delete this section if you read and applied the mentioned points.

Description

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

STM32L4

What LVGL version are you using?

v8.3

What do you want to achieve?

I want to set my dog image as a LCD background image. How can i ??

What have you tried so far?

I’m trying to use lv_img. But I don’t know how use this API.

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

/*You code here*/

void Display_init(void)
{
// draw buffer
static lv_disp_draw_buf_t disp_buf;

static lv_color_t buf_1[SSD1327_LCDWIDTH * 10];
static lv_color_t buf_2[SSD1327_LCDWIDTH * 10];

lv_disp_draw_buf_init(&disp_buf, buf_1, buf_2, SSD1327_LCDWIDTH * 10);

// Driver

lv_disp_drv_init(&disp_drv);

disp_drv.draw_buf = &disp_buf;
disp_drv.flush_cb = my_flush_cb;
disp_drv.hor_res = SSD1327_LCDWIDTH;
disp_drv.ver_res = SSD1327_LCDHEIGHT;

lv_disp_t *disp = lv_disp_drv_register(&disp_drv);

lv_disp_set_bg_image(disp, &cat_image);

}
This is my code. Am i wrong??

Screenshot and/or video

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

You can just create an lv_img widget and set an image source for it.
See the documentation and the examples here: Image (lv_img) — LVGL documentation

You can also set a background image for a screen like:

lv_obj_set_bg_img_src(lv_scr_act(), &my_img, 0);

I’m using a monochrome LCD (SSD1327) and I don’t know how to size the image (width, height, color_depthetc…) when I use the online image converter tool.

I’m not using lv_obj but can i use that function?? lv_obj_set_bg_img_src function.

What are you using then? How do you create widgets or any content on the screen?

 lv_obj_t * obj;
	obj = lv_obj_create(lv_scr_act());
	lv_obj_set_size(obj, 150, 100);
//	lv_obj_add_event_cb(obj, drag_event_handler, LV_EVENT_PRESSING, NULL);

	lv_obj_t * label = lv_label_create(obj);
	lv_label_set_text(label, "Drag me");
	lv_obj_center(label);

I’m displaying using the code above, but the letters are broken and printed.

Let’s start with the simple things. What’s the problem with the letters? Please send a screen shot.