1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:37:34 +00:00

PixelPaint: Add copy action (copies the selection from active layer)

You can now select a part of a layer, copy it, and then paste it as
a new layer. Very cool :^)
This commit is contained in:
Andreas Kling 2021-06-14 17:59:15 +02:00
parent 4cecd79000
commit 765286f691
4 changed files with 29 additions and 0 deletions

View file

@ -6,6 +6,7 @@
#include "Layer.h"
#include "Image.h"
#include "Selection.h"
#include <LibGfx/Bitmap.h>
namespace PixelPaint {
@ -89,4 +90,11 @@ void Layer::set_name(String name)
m_image.layer_did_modify_properties({}, *this);
}
RefPtr<Gfx::Bitmap> Layer::try_copy_bitmap(Selection const& selection) const
{
auto bounding_rect = selection.bounding_rect().translated(-m_location);
// FIXME: This needs to be smarter once we add more complex selections.
return m_bitmap->cropped(bounding_rect);
}
}