summaryrefslogtreecommitdiff
path: root/SharedGraphics
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-04-12 02:50:28 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-04-12 02:50:28 +0200
commit476c43ab22f47e5f9eb394828d1a3aa656b9ab5e (patch)
tree5f635be73b60614660d4bb703e78e495686ec9ff /SharedGraphics
parent0f5114852a5c70ae533d1f3b44eef4474847a9f3 (diff)
downloadserenity-476c43ab22f47e5f9eb394828d1a3aa656b9ab5e.zip
Painter: Add alpha-blending support to blit_dimmed().
Diffstat (limited to 'SharedGraphics')
-rw-r--r--SharedGraphics/Painter.cpp8
1 files changed, 7 insertions, 1 deletions
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;