diff options
Diffstat (limited to 'Userland/Applications/PixelPaint/Image.cpp')
-rw-r--r-- | Userland/Applications/PixelPaint/Image.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Userland/Applications/PixelPaint/Image.cpp b/Userland/Applications/PixelPaint/Image.cpp index a5435a29e2..ba2131baf6 100644 --- a/Userland/Applications/PixelPaint/Image.cpp +++ b/Userland/Applications/PixelPaint/Image.cpp @@ -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) |