Skip to content

Commit

Permalink
feat(color): add color format ARGB8565
Browse files Browse the repository at this point in the history
Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
  • Loading branch information
XuNeo committed Feb 4, 2024
1 parent 52426ec commit 86016a8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/draw/lv_draw_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,21 @@ lv_result_t lv_draw_buf_premultiply(lv_draw_buf_t * draw_buf)
alpha += alpha_stride;
}
}
else if(cf == LV_COLOR_FORMAT_ARGB8565) {
uint32_t h = draw_buf->header.h;
uint32_t w = draw_buf->header.w;
uint32_t stride = draw_buf->header.stride;
uint8_t * line = (uint8_t *)draw_buf->data;
for(uint32_t y = 0; y < h; y++) {
uint8_t * pixel = line;
for(uint32_t x = 0; x < w; x++) {
uint8_t alpha = pixel[2];
lv_color16_premultiply((lv_color16_t *)pixel, alpha);
pixel += 3;
}
line += stride;
}
}
else if(LV_COLOR_FORMAT_IS_ALPHA_ONLY(cf)) {
/*Pass*/
}
Expand Down
6 changes: 4 additions & 2 deletions src/libs/bin_decoder/lv_bin_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ lv_result_t lv_bin_decoder_open(lv_image_decoder_t * decoder, lv_image_decoder_d
|| cf == LV_COLOR_FORMAT_XRGB8888 \
|| cf == LV_COLOR_FORMAT_RGB888 \
|| cf == LV_COLOR_FORMAT_RGB565 \
|| cf == LV_COLOR_FORMAT_RGB565A8) {
|| cf == LV_COLOR_FORMAT_RGB565A8 \
|| cf == LV_COLOR_FORMAT_ARGB8565) {
res = decode_rgb(decoder, dsc);
}
#else
Expand Down Expand Up @@ -381,6 +382,7 @@ lv_result_t lv_bin_decoder_get_area(lv_image_decoder_t * decoder, lv_image_decod
|| cf == LV_COLOR_FORMAT_XRGB8888 \
|| cf == LV_COLOR_FORMAT_RGB888 \
|| cf == LV_COLOR_FORMAT_RGB565 \
|| cf == LV_COLOR_FORMAT_ARGB8565 \
|| cf == LV_COLOR_FORMAT_RGB565A8;
if(!supported) {
LV_LOG_WARN("CF: %d is not supported", cf);
Expand Down Expand Up @@ -469,7 +471,7 @@ lv_result_t lv_bin_decoder_get_area(lv_image_decoder_t * decoder, lv_image_decod
}

if(cf == LV_COLOR_FORMAT_ARGB8888 || cf == LV_COLOR_FORMAT_XRGB8888 || cf == LV_COLOR_FORMAT_RGB888
|| cf == LV_COLOR_FORMAT_RGB565) {
|| cf == LV_COLOR_FORMAT_RGB565 || cf == LV_COLOR_FORMAT_ARGB8565) {
uint32_t len = (w_px * bpp) / 8;
offset += decoded_area->y1 * dsc->header.stride;
offset += decoded_area->x1 * bpp / 8; /*Move to x1*/
Expand Down
1 change: 1 addition & 0 deletions src/misc/lv_color.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ uint8_t lv_color_format_get_bpp(lv_color_format_t cf)
case LV_COLOR_FORMAT_RGB565:
return 16;

case LV_COLOR_FORMAT_ARGB8565:
case LV_COLOR_FORMAT_RGB888:
return 24;
case LV_COLOR_FORMAT_ARGB8888:
Expand Down
2 changes: 2 additions & 0 deletions src/misc/lv_color.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ typedef uint8_t lv_opa_t;
(cf) == LV_COLOR_FORMAT_I8 ? 8 : \
(cf) == LV_COLOR_FORMAT_RGB565 ? 16 : \
(cf) == LV_COLOR_FORMAT_RGB565A8 ? 16 : \
(cf) == LV_COLOR_FORMAT_ARGB8565 ? 24 : \
(cf) == LV_COLOR_FORMAT_RGB888 ? 24 : \
(cf) == LV_COLOR_FORMAT_ARGB8888 ? 32 : \
(cf) == LV_COLOR_FORMAT_XRGB8888 ? 32 : \
Expand Down Expand Up @@ -127,6 +128,7 @@ enum _lv_color_format_t {

/*2 byte (+alpha) formats*/
LV_COLOR_FORMAT_RGB565 = 0x12,
LV_COLOR_FORMAT_ARGB8565 = 0x13, /**< Not supported by sw renderer yet. */
LV_COLOR_FORMAT_RGB565A8 = 0x14 /**< Color array followed by Alpha array*/,

/*3 byte (+alpha) formats*/
Expand Down

0 comments on commit 86016a8

Please sign in to comment.