1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 13:15:07 +00:00

Painter: Add alpha-blending support to blit_dimmed().

This commit is contained in:
Andreas Kling 2019-04-12 02:50:28 +02:00
parent 0f5114852a
commit 476c43ab22

View file

@ -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;