32-bit color transparency problem


I have a ili9341 16-bit color display, how can I display a transparent color on it?

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


What do you want to achieve?

I want to achieve a picture with a transparent color

What have you tried so far?

I turned the image into a True color chroma key C array, which is a disordered line on the display, and it doesn’t display properly.

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

/*You code here*/

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

“Doesn’t display properly” is not enough information for us to diagnose the issue. A screenshot would be helpful. Does it work with regular True color mode or True color with alpha mode?

I converted the image to a true color chroma keyed format and imported it into the project. The code is as follows:


void create(){
lv_obj_t *test_image = lv_img_create(lv_disp_get_scr_act(NULL), NULL);
lv_img_set_src(test_image, &test);
test.c (866.4 KB)

device photo:

It seems that there are only white lines, and only part of it

my lv_conf.h is like this

#define LV_COLOR_DEPTH     32
#define LV_COLOR_16_SWAP   0
#define LV_ANTIALIAS        1
#define LV_DISP_DEF_REFR_PERIOD      30      /*[ms]*/
#define LV_DPI              100     /*[px]*/
typedef int16_t lv_coord_t;

   Memory manager settings
#define LV_MEM_CUSTOM      1
#if LV_MEM_CUSTOM == 0
#  define LV_MEM_SIZE    (32U * 1024U)
#  define LV_MEM_ATTR
#  define LV_MEM_ADR          0
#  define LV_MEM_AUTO_DEFRAG  1
#else       /*LV_MEM_CUSTOM*/
#  define LV_MEM_CUSTOM_INCLUDE <stdlib.h>   /*Header for the dynamic memory function*/
#  define LV_MEM_CUSTOM_ALLOC   malloc       /*Wrapper to malloc*/
#  define LV_MEM_CUSTOM_FREE    free         /*Wrapper to free*/
#endif     /*LV_MEM_CUSTOM*/

Why did you set LV_COLOR_DEPTH 32 if you have a 16 bit display?

Does the other drawings work well? Buttons, labels, etc.

Next time please format your code like this:


Is it possible to display a transparent PNG image on a 16-bit color depth display? I put an image button on the background image, I want it to appear to be partially transparent.

You should be able to display transparent images on any color depth within LittlevGL, but you can’t draw a background with another library and then have LittlevGL transparently draw on top of it (unless you are using 32-bit color depth and you’ve enabled the appropriate setting in lv_conf.h).

I understand what you mean, I made a new attempt, but it still shows up abnormally.
This is my configuration:
#define LV_COLOR_DEPTH 16
#define LV_COLOR_16_SWAP 1

This is my original picture:%E7%AA%97%E5%B8%98
On this page(https://littlevgl.com/image-to-c-array ), I chose true color chroma keyed

When I select true color instead of true color chroma keyed, it displays correctly

1 Like