mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:07:34 +00:00
PixelPaint: Add Image>Resize Image... dialog. (Front end)
This commit is contained in:
parent
abaecb878b
commit
02399d4775
11 changed files with 302 additions and 0 deletions
|
@ -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()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue