Caching indexed images


I’m using the mosaic feature with indexed images for the background of my screen to get a smooth gradient. Doing this I obtain the desired effect, but the refreshing of the whole screen is quite slow, maybe because the large number of images to draw. I tried caching the image to improve the process, setting img_data in the open function of the decoder (this pointer is NULL in the built-in function for indexed images). The position of each image seems to be right, but I cannot see the whole image drawed.

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

MK22FN1M0A (ARM cortex m4)

What LVGL version are you using?


What do you want to achieve?

Caching the indexed image to improve the refresing of the screen.

What have you tried so far?

I have set img_data pointer to decoded data of the image, so it can be drawed directly in lv_img_draw_core function.

Code to reproduce

I modified lv_img_decoder_built_in_open, adding the next code just for testing

        if (dsc-> == LV_IMG_CF_INDEXED_4BIT) {
          uint8_t  * buf = _lv_mem_buf_get(dsc->header.w * LV_IMG_PX_SIZE_ALPHA_BYTE);  

          for (uint8_t row = 0; row < dsc->header.h; row++) {
            uint16_t counter = row * dsc->header.w;
            lv_img_decoder_built_in_line_indexed(dsc, 0, row, dsc->header.w, buf);
            for (uint8_t i = 0; i < dsc->header.w; i++) {
              decodedData[counter + i] = buf[i];
          dsc->img_data = decodedData;

Any ideas to deal with this problem? Suggestions to improve the refreshing without caching the images of the mosaic are also welcome