How to add an image into multiple lv_table cells


I like to add lttle images (24x24) into cells of a lv_table

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


What LVGL version are you using?


What do you want to achieve?

In want to load an image once and draw it into several cells without
creating an new object for each image.

What have you tried so far?

Create an image object for each cell but this is memory intensive.

in draw_part_event_cb() (registered func. for LV_EVENT_DRAW_PART_END)

I check if the image needs to be filled into the cell.
If yes, then I do this:

Code to reproduce

draw_part_event_cb (...) {
  lv_obj_t * icon[icnr] = lv_img_create(lv_scr_act(), NULL);
  lv_img_set_src(icon[icnr], &my_icon_dsc);
  lv_obj_align(icon[icnr], LV_ALIGN_OUT_TOP_LEFT, x, y);
  icnr++; /* for each cell with this image a new entry in the icon[] table is created */

Any advice how I can achieve this efficienty? usually I would just copy the image map from my lv_img_dsc_t to the screen over the cell in the callback func. as I know the area where to draw the image to inside draw_part_event_cb().

Sorry, I’m quite new to lvgl. Thanks for any help!

Hi @tobiw
Had you ever encounter the error “_lv_inv_area: detected modifying dirty areas in render” when you add images to cells by calling icon[icnr]?