mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:47:45 +00:00
PixelPaint: Add method to flatten image layers
This adds Image::flatten_all_layers() that allows the user to flatten all the visible layers into one.
This commit is contained in:
parent
76a18e1172
commit
9be08e33ea
4 changed files with 30 additions and 0 deletions
|
@ -366,6 +366,24 @@ void Image::remove_layer(Layer& layer)
|
|||
did_modify_layer_stack();
|
||||
}
|
||||
|
||||
void Image::flatten_all_layers()
|
||||
{
|
||||
if (m_layers.size() < 2)
|
||||
return;
|
||||
|
||||
auto& bottom_layer = m_layers.at(0);
|
||||
|
||||
GUI::Painter painter(bottom_layer.bitmap());
|
||||
paint_into(painter, { 0, 0, m_size.width(), m_size.height() });
|
||||
|
||||
for (size_t index = m_layers.size() - 1; index > 0; index--) {
|
||||
auto& layer = m_layers.at(index);
|
||||
remove_layer(layer);
|
||||
}
|
||||
bottom_layer.set_name("Background");
|
||||
select_layer(&bottom_layer);
|
||||
}
|
||||
|
||||
void Image::select_layer(Layer* layer)
|
||||
{
|
||||
for (auto* client : m_clients)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue