From 476c43ab22f47e5f9eb394828d1a3aa656b9ab5e Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 12 Apr 2019 02:50:28 +0200 Subject: Painter: Add alpha-blending support to blit_dimmed(). --- SharedGraphics/Painter.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'SharedGraphics') diff --git a/SharedGraphics/Painter.cpp b/SharedGraphics/Painter.cpp index 55e4acfb49..b6f9777320 100644 --- a/SharedGraphics/Painter.cpp +++ b/SharedGraphics/Painter.cpp @@ -257,7 +257,13 @@ void Painter::blit_dimmed(const Point& position, const GraphicsBitmap& source, c for (int row = first_row; row <= last_row; ++row) { for (int x = 0; x <= (last_column - first_column); ++x) { - dst[x] = Color::from_rgba(src[x]).to_grayscale().darkened().value(); + byte alpha = Color::from_rgba(src[x]).alpha(); + if (alpha == 0xff) + dst[x] = Color::from_rgba(src[x]).to_grayscale().lightened().value(); + else if (!alpha) + continue; + else + dst[x] = Color::from_rgba(dst[x]).blend(Color::from_rgba(src[x]).to_grayscale().lightened()).value(); } dst += dst_skip; src += src_skip; -- cgit v1.2.3