How to make backgroud transparent with color key?


I’m now working for a new NVR product (Network video record, recored video data from network).It has two visible layout(or framebuffer), one is show video at bottom, the other is for our application. System framebuffer’s color format must be ARGB1555, so OPA is invalid for lvgl. But a “Color Key” value replace it(the same with image color key).

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


What have you tried so far? What do you want to achieve?

I set pure green as color key(the same with lvgl), and creat a ‘cont’ as bottom window(with color key background), this window now is transparent. When I creat some widget on it, the widget’s shadow is mixed with green color.Do you have any idea to make the shadow still work correctlly?

Code to reproduce

Screenshot and/or video

The shadows are semitransparent pixels. If the screen is transparent too than LittlevGL stores the alpha value of the shadow pixels in the alpha channel of ARGB888 colors (LV_COLOR_SCREEN_TRANSP needs to be enabled to work like this). However, if you have only 1 bit alpha it’s not possible.

It seems your best option is not to use shadows. :frowning_face:

However, you don’t have to use green color as transparent. Basically every color should work which has 0 in the alpha bit.

BTW, how do you use ARGB1555 format? Have you modified the color functions? (They work with RGB565 by default)

Thank you, I understand.

I add “LV_COLOR_FMT_RGB1555” to support it, Your lib may add them too.

— lv_color.h
typedef union
#if LV_COLOR_16_SWAP == 0
uint16_t blue : 5;
uint16_t green : 5;
uint16_t red : 5;
uint16_t alpha : 1;
uint16_t blue : 5;
uint16_t green : 6;
uint16_t red : 5;
uint16_t green_h : 3;
uint16_t red : 5;
uint16_t blue : 5;
uint16_t green_l : 3;
} ch;
uint16_t full;
} lv_color16_t;

#elif LV_COLOR_DEPTH == 16
#if LV_COLOR_16_SWAP == 0

#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8 >> 3, g8 >> 3, r8 >> 3, 1}})
static inline lv_color_t lv_color_make(uint8_t r8, uint8_t g8, uint8_t b8)
lv_color_t color; = (uint16_t)(b8 >> 3); = (uint16_t)(g8 >> 3); = (uint16_t)(r8 >> 3); = 1;
return color;


Can you send a Pull request with these updates?

Ok, I will try pull a request later.

1 Like

Hi, I tested littlevgl background alpha on hi3536D, in;
1, call ioctl(fd, FBIOPUT_ALPHA_HIFB, &stAlpha) in /mod/mpp/3536d/src/mpp.c:gsf_mpp_fb_start();
2, call LV_COLOR_SET_A() in /mod/app/littlevgl/lv_examples/lv_apps/demo.c:demo_create();

Color keyong is not supported on “normal colors” only on images.

Do you want to make the whole background transparent?