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

PixelPaint: Add Image>Resize Image... dialog. (Front end)

This commit is contained in:
Andrew Smith 2022-03-08 06:00:04 -06:00 committed by Andreas Kling
parent abaecb878b
commit 02399d4775
11 changed files with 302 additions and 0 deletions

View file

@ -180,6 +180,31 @@ void Layer::crop(Gfx::IntRect const& rect)
did_modify_bitmap();
}
void Layer::resize(Gfx::IntSize const& new_size, Gfx::Painter::ScalingMode scaling_mode)
{
const Gfx::IntRect old_rect(Gfx::IntPoint(0, 0), size());
const Gfx::IntRect new_rect(Gfx::IntPoint(0, 0), new_size);
{
auto resized = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, new_size).release_value_but_fixme_should_propagate_errors();
Gfx::Painter painter(resized);
painter.draw_scaled_bitmap(new_rect, *m_content_bitmap, old_rect, 1.0f, scaling_mode);
m_content_bitmap = move(resized);
}
if (m_mask_bitmap) {
auto resized = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, new_size).release_value_but_fixme_should_propagate_errors();
Gfx::Painter painter(resized);
painter.draw_scaled_bitmap(new_rect, *m_mask_bitmap, old_rect, 1.0f, scaling_mode);
m_mask_bitmap = move(resized);
}
did_modify_bitmap();
}
void Layer::update_cached_bitmap()
{
if (!is_masked()) {