Skip to content

Commit

Permalink
chore(decoder): only premultiply for images have alpha (lvgl#5370)
Browse files Browse the repository at this point in the history
Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
  • Loading branch information
XuNeo authored Jan 18, 2024
1 parent 0d3f299 commit 8d67e9c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/draw/lv_image_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ lv_draw_buf_t * lv_image_decoder_post_process(lv_image_decoder_dsc_t * dsc, lv_d

/*Premultiply alpha channel*/
if(args->premultiply
&& !LV_COLOR_FORMAT_IS_ALPHA_ONLY(decoded->header.cf)
&& lv_color_format_has_alpha(decoded->header.cf)
&& !lv_draw_buf_has_flag(decoded, LV_IMAGE_FLAGS_PREMULTIPLIED) /*Hasn't done yet*/
) {
LV_LOG_TRACE("Alpha premultiply.");
Expand Down
6 changes: 6 additions & 0 deletions src/misc/lv_color.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ uint8_t lv_color_format_get_bpp(lv_color_format_t cf)
bool lv_color_format_has_alpha(lv_color_format_t cf)
{
switch(cf) {
case LV_COLOR_FORMAT_A1:
case LV_COLOR_FORMAT_A2:
case LV_COLOR_FORMAT_A4:
case LV_COLOR_FORMAT_A8:
case LV_COLOR_FORMAT_I1:
case LV_COLOR_FORMAT_I2:
case LV_COLOR_FORMAT_I4:
case LV_COLOR_FORMAT_I8:
case LV_COLOR_FORMAT_RGB565A8:
case LV_COLOR_FORMAT_ARGB8888:
Expand Down

0 comments on commit 8d67e9c

Please sign in to comment.