mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:17:44 +00:00
PixelPaint: Respect Mask when generating the display bitmap
This commit is contained in:
parent
82bfdec790
commit
a180b5f442
1 changed files with 14 additions and 0 deletions
|
@ -156,6 +156,20 @@ void Layer::update_cached_bitmap()
|
||||||
m_cached_display_bitmap = m_content_bitmap;
|
m_cached_display_bitmap = m_content_bitmap;
|
||||||
return;
|
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()
|
void Layer::create_mask()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue