Skip to content

Commit 86016a8

Browse files
committed
feat(color): add color format ARGB8565
Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
1 parent 52426ec commit 86016a8

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

src/draw/lv_draw_buf.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,21 @@ lv_result_t lv_draw_buf_premultiply(lv_draw_buf_t * draw_buf)
362362
alpha += alpha_stride;
363363
}
364364
}
365+
else if(cf == LV_COLOR_FORMAT_ARGB8565) {
366+
uint32_t h = draw_buf->header.h;
367+
uint32_t w = draw_buf->header.w;
368+
uint32_t stride = draw_buf->header.stride;
369+
uint8_t * line = (uint8_t *)draw_buf->data;
370+
for(uint32_t y = 0; y < h; y++) {
371+
uint8_t * pixel = line;
372+
for(uint32_t x = 0; x < w; x++) {
373+
uint8_t alpha = pixel[2];
374+
lv_color16_premultiply((lv_color16_t *)pixel, alpha);
375+
pixel += 3;
376+
}
377+
line += stride;
378+
}
379+
}
365380
else if(LV_COLOR_FORMAT_IS_ALPHA_ONLY(cf)) {
366381
/*Pass*/
367382
}

src/libs/bin_decoder/lv_bin_decoder.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ lv_result_t lv_bin_decoder_open(lv_image_decoder_t * decoder, lv_image_decoder_d
230230
|| cf == LV_COLOR_FORMAT_XRGB8888 \
231231
|| cf == LV_COLOR_FORMAT_RGB888 \
232232
|| cf == LV_COLOR_FORMAT_RGB565 \
233-
|| cf == LV_COLOR_FORMAT_RGB565A8) {
233+
|| cf == LV_COLOR_FORMAT_RGB565A8 \
234+
|| cf == LV_COLOR_FORMAT_ARGB8565) {
234235
res = decode_rgb(decoder, dsc);
235236
}
236237
#else
@@ -381,6 +382,7 @@ lv_result_t lv_bin_decoder_get_area(lv_image_decoder_t * decoder, lv_image_decod
381382
|| cf == LV_COLOR_FORMAT_XRGB8888 \
382383
|| cf == LV_COLOR_FORMAT_RGB888 \
383384
|| cf == LV_COLOR_FORMAT_RGB565 \
385+
|| cf == LV_COLOR_FORMAT_ARGB8565 \
384386
|| cf == LV_COLOR_FORMAT_RGB565A8;
385387
if(!supported) {
386388
LV_LOG_WARN("CF: %d is not supported", cf);
@@ -469,7 +471,7 @@ lv_result_t lv_bin_decoder_get_area(lv_image_decoder_t * decoder, lv_image_decod
469471
}
470472

471473
if(cf == LV_COLOR_FORMAT_ARGB8888 || cf == LV_COLOR_FORMAT_XRGB8888 || cf == LV_COLOR_FORMAT_RGB888
472-
|| cf == LV_COLOR_FORMAT_RGB565) {
474+
|| cf == LV_COLOR_FORMAT_RGB565 || cf == LV_COLOR_FORMAT_ARGB8565) {
473475
uint32_t len = (w_px * bpp) / 8;
474476
offset += decoded_area->y1 * dsc->header.stride;
475477
offset += decoded_area->x1 * bpp / 8; /*Move to x1*/

src/misc/lv_color.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ uint8_t lv_color_format_get_bpp(lv_color_format_t cf)
6262
case LV_COLOR_FORMAT_RGB565:
6363
return 16;
6464

65+
case LV_COLOR_FORMAT_ARGB8565:
6566
case LV_COLOR_FORMAT_RGB888:
6667
return 24;
6768
case LV_COLOR_FORMAT_ARGB8888:

src/misc/lv_color.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ typedef uint8_t lv_opa_t;
7676
(cf) == LV_COLOR_FORMAT_I8 ? 8 : \
7777
(cf) == LV_COLOR_FORMAT_RGB565 ? 16 : \
7878
(cf) == LV_COLOR_FORMAT_RGB565A8 ? 16 : \
79+
(cf) == LV_COLOR_FORMAT_ARGB8565 ? 24 : \
7980
(cf) == LV_COLOR_FORMAT_RGB888 ? 24 : \
8081
(cf) == LV_COLOR_FORMAT_ARGB8888 ? 32 : \
8182
(cf) == LV_COLOR_FORMAT_XRGB8888 ? 32 : \
@@ -127,6 +128,7 @@ enum _lv_color_format_t {
127128

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

132134
/*3 byte (+alpha) formats*/

0 commit comments

Comments
 (0)