aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-02-28 17:35:21 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-02-28 17:35:21 +0000
commit925088a8f21c2b2b136d30ca2d4bc45fd816ce35 (patch)
treefc234c9e69e46b54eaaeb32aad9774e5d96aa4ef
parentterminal: error out when we fail to load the primary font (diff)
render: color_hex_to_pixman_with_alpha(): handle alpha == 0 (transparent)
-rw-r--r--render.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/render.c b/render.c
index 98ea90f6..634e07dc 100644
--- a/render.c
+++ b/render.c
@@ -218,6 +218,9 @@ color_hex_to_rgb(uint32_t color)
static inline pixman_color_t
color_hex_to_pixman_with_alpha(uint32_t color, uint16_t alpha)
{
+ if (alpha == 0)
+ return (pixman_color_t){0, 0, 0, 0};
+
int alpha_div = 0xffff / alpha;
return (pixman_color_t){
.red = ((color >> 16 & 0xff) | (color >> 8 & 0xff00)) / alpha_div,