Hello Gabor,
Thank you for your interest in my problem.
I looked at lv_ex_img_1() and, yes, I use another configuration :
- My image is stored in a file in png format and I use the lib lodepng to decode it.
- In my callback function decoder_info, I set the color format flag of header image to LV_IMG_CF_RAW_ALPHA as I’m using an image with alpha channel.
- I’m configured with LV_COLOR_DEPTH = 16
My problem is reproducible both on my development board (LPCXpresso546xx) and with the Visual Studio simulator and is independent of using png_decoder or not.
I saw that, when the image is decoded, alpha channel values are put in mask_buf used by _lv_blend_map() (lv_drw_img.c:412 and lv_drw_img.c:432).In this function LV_ANTIALIAS is checked to “round” (set to 0 or 0xFF) the values of the mask (lv_draw_blend.c:226-235) but rounding alpha channel destroys transparency effects.
I checked the image img_cogwheel_argb.png used in your example and although it has an alpha channel, the transparency is used on a few pixels, so it’s hard to detect.
If you put a background color you can see small differences between images. Differences are more visible using gradient color.
I send you the png I used in example and 2 screenshots of my VS simulation (LV_ANTIALIAS=0/1). Here is the code to generate this example
LV_IMG_DECLARE(test_alpha)
lv_obj_t * img1 = lv_img_create(lv_scr_act(), NULL);
lv_obj_set_style_local_bg_color(img1, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLUE);
lv_obj_set_style_local_bg_opa(img1, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_img_set_src(img1, &test_alpha);
lv_obj_align(img1, NULL, LV_ALIGN_CENTER, 0, 0);
I generate the test_alpha.c using the online image tool and setting color format to true color with alpha
Best regards