What is the correct method to use Monochrome icons with transparency


Hello, more informations to come bellow.

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


What LVGL version are you using?

LvGL 8.3.9

What do you want to achieve?

To save memory I want to use monochrome icon, but colore them in the application, and ofc color only one color and keep the background invisible.

What have you tried so far?

So my image are in png format, only with black and white (1 color depth)
I m using the Online Image Converter to use them as C file.
If I use the CF_1BIT_ALPHA it don’t work at all, I just have a black square
If I use the CF_INDEXED_1BIT it work, but not possible to colore it. The background is colored too.
If I use CF_TRUE_COLOR_ALPHA same result.
Have tried to change the LV_COLOR_CHROMA_KEY value to full white and full black, same result.
If I don’t use the OPA fonction, the color change not working.

Code to reproduce

    /*Create icon*/
    lv_obj_t *img = lv_img_create(Button_icon);
    lv_img_set_src(img, &temperature35x35);
    //lv_img_set_zoom(img,200);                         // Not working for this image type
    lv_obj_align(img, LV_ALIGN_TOP_LEFT , 0, -10);
    lv_obj_set_size(img, Size_icon, Size_icon);
    lv_obj_set_style_img_recolor_opa(img, 50, 0);
    lv_obj_set_style_img_recolor(img, color, 0);

Ok have found my problem.
First the good mode to use is CF_ALPHA_1_BIT, but my original file was not use the transparency mode. After the correction on the original file, no more problem.