aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md2
-rw-r--r--render.c10
2 files changed, 5 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 795d395a..c25d5586 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -28,6 +28,8 @@
* Missing dependencies in meson, causing heavily parallelized builds
to fail.
+* Background color when alpha < 1.0 being wrong
+ (https://codeberg.org/dnkl/foot/issues/249).
### Security
diff --git a/render.c b/render.c
index df22dd6e..f66e277e 100644
--- a/render.c
+++ b/render.c
@@ -213,14 +213,10 @@ attrs_to_font(const struct terminal *term, const struct attributes *attrs)
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,
- .green = ((color >> 8 & 0xff) | (color >> 0 & 0xff00)) / alpha_div,
- .blue = ((color >> 0 & 0xff) | (color << 8 & 0xff00)) / alpha_div,
+ .red = ((color >> 16 & 0xff) | (color >> 8 & 0xff00)) * alpha / 0xffff,
+ .green = ((color >> 8 & 0xff) | (color >> 0 & 0xff00)) * alpha / 0xffff,
+ .blue = ((color >> 0 & 0xff) | (color << 8 & 0xff00)) * alpha / 0xffff,
.alpha = alpha,
};
}