summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorTobias Christiansen <tobyase@serenityos.org>2022-03-07 22:19:41 +0100
committerAndreas Kling <kling@serenityos.org>2022-03-08 22:07:12 +0100
commita180b5f442bba8ea90d26dc6d3cd81701ad9fd54 (patch)
tree717a9fa5758fbddc92819298d085b2df8ad506c0 /Userland
parent82bfdec7906bf83a02e5a5f5d7f28dac8033e7f2 (diff)
downloadserenity-a180b5f442bba8ea90d26dc6d3cd81701ad9fd54.zip
PixelPaint: Respect Mask when generating the display bitmap
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Applications/PixelPaint/Layer.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/Userland/Applications/PixelPaint/Layer.cpp b/Userland/Applications/PixelPaint/Layer.cpp
index 5d63541740..e5905ce9e3 100644
--- a/Userland/Applications/PixelPaint/Layer.cpp
+++ b/Userland/Applications/PixelPaint/Layer.cpp
@@ -156,6 +156,20 @@ void Layer::update_cached_bitmap()
m_cached_display_bitmap = m_content_bitmap;
return;
}
+
+ if (m_content_bitmap.ptr() == m_cached_display_bitmap.ptr())
+ m_cached_display_bitmap = MUST(Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, size()));
+
+ // FIXME: This can probably be done nicer
+ m_cached_display_bitmap->fill(Color::Transparent);
+ for (int y = 0; y < size().height(); ++y) {
+ for (int x = 0; x < size().width(); ++x) {
+ auto opacity_multiplier = (float)m_mask_bitmap->get_pixel(x, y).to_grayscale().red() / 255;
+ auto content_color = m_content_bitmap->get_pixel(x, y);
+ content_color.set_alpha(content_color.alpha() * opacity_multiplier);
+ m_cached_display_bitmap->set_pixel(x, y, content_color);
+ }
+ }
}
void Layer::create_mask()