LVGL8.3 RGB565 interface gradient color Display effect color gradation obvious? Is there any solution?

Please advise the RGB565 interface, with LVGL8.3.11 gradient color code to generate a gradient color background or directly display a gradient color image but are too obvious color gradient, grain color gradient can be seen at a glance, what software can eliminate the next? The image is directly converted into a C file with the official image conversion tool, and then how to change the color gradient changes are very obvious!

what is the size of your screen?

you need to run the gradient through a dithering algorithm.

This takes an image that is RGB888 and converts it into RGB565 and it dithers it.

so render your gradient to a buffer and feed that buffer through this function and pass the buffer to an lv_image widget.

uint8_t RED_THRESH[] = {
    1, 7, 3, 5, 0, 8, 2, 6,
    7, 1, 5, 3, 8, 0, 6, 2,
    3, 5, 0, 8, 2, 6, 1, 7,
    5, 3, 8, 0, 6, 2, 7, 1,
    0, 8, 2, 6, 1, 7, 3, 5,
    8, 0, 6, 2, 7, 1, 5, 3,
    2, 6, 1, 7, 3, 5, 0, 8,
    6, 2, 7, 1, 5, 3, 8, 0
};

uint8_t GREEN_THRESH[] = {
    1, 3, 2, 2, 3, 1, 2, 2,
    2, 2, 0, 4, 2, 2, 4, 0,
    3, 1, 2, 2, 1, 3, 2, 2,
    2, 2, 4, 0, 2, 2, 0, 4,
    1, 3, 2, 2, 3, 1, 2, 2,
    2, 2, 0, 4, 2, 2, 4, 0,
    3, 1, 2, 2, 1, 3, 2, 2,
    2, 2, 4, 0, 2, 2, 0, 4
};

uint8_t BLUE_THRESH[] = {
    5, 3, 8, 0, 6, 2, 7, 1,
    3, 5, 0, 8, 2, 6, 1, 7,
    8, 0, 6, 2, 7, 1, 5, 3,
    0, 8, 2, 6, 1, 7, 3, 5,
    6, 2, 7, 1, 5, 3, 8, 0,
    2, 6, 1, 7, 3, 5, 0, 8,
    7, 1, 5, 3, 8, 0, 6, 2,
    1, 7, 3, 5, 0, 8, 2, 6
};

void lv_rgb565_dither(uint8_t *buf, uint16_t width, uint16_t height) {
    lv_color_t *color;
    uint8_t *p;
    uint8_t threshold_id;

    for (uint16_t y=0; y < height; y++) {
        for (uint16_t x=0; x < width; x++) {
            p = &buf[height * y + x];
            color = (lv_color_t *)p;
           
            threshold_id = (uint8_t)(((y & 7) << 3) + (x & 7));

            color->red = (color->red + RED_THRESH[threshold_id]) & 0xF8;
            color->green = (color->green + GREEN_THRESH[threshold_id]) & 0xFC;
            color->blue = (color->blue + BLUE_THRESH[threshold_id]) & 0xF8;
        }
    }
}

RGB565 gradient.
310791053-b91c0a18-07d4-469e-800d-a0f7220b5ec3

and the same gradient that has been dithered.
310791104-19744421-1d51-488a-a75d-1ce1284f30f7

as you can see the banding is about 98% gone.

Thank you, I’ll give it a try