mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:48:12 +00:00
PixelPaint+LibGfx: Allow resizing images and layers
This PR adds resize ability to PixelPaint as per issue 11862. The previous behaviour was to always rescale the canvas when resizing an image. This adds a checkbox to toggle between rescaling, and resizing which blits the existing canvas to the top left of the new, resized canvas. As part of this, a new ScalingMode is added to LibGfx - None.
This commit is contained in:
parent
d6334dcab1
commit
4bf587811f
6 changed files with 35 additions and 3 deletions
|
@ -70,10 +70,12 @@ ResizeImageDialog::ResizeImageDialog(Gfx::IntSize const& suggested_size, GUI::Wi
|
|||
auto nearest_neighbor_radio = main_widget.find_descendant_of_type_named<GUI::RadioButton>("nearest_neighbor_radio");
|
||||
auto smooth_pixels_radio = main_widget.find_descendant_of_type_named<GUI::RadioButton>("smooth_pixels_radio");
|
||||
auto bilinear_radio = main_widget.find_descendant_of_type_named<GUI::RadioButton>("bilinear_radio");
|
||||
auto resize_canvas_radio = main_widget.find_descendant_of_type_named<GUI::RadioButton>("resize_canvas");
|
||||
|
||||
VERIFY(nearest_neighbor_radio);
|
||||
VERIFY(smooth_pixels_radio);
|
||||
VERIFY(bilinear_radio);
|
||||
VERIFY(resize_canvas_radio);
|
||||
|
||||
m_scaling_mode = Gfx::Painter::ScalingMode::NearestNeighbor;
|
||||
if (bilinear_radio->is_checked()) {
|
||||
|
@ -92,6 +94,10 @@ ResizeImageDialog::ResizeImageDialog(Gfx::IntSize const& suggested_size, GUI::Wi
|
|||
if (is_checked)
|
||||
m_scaling_mode = Gfx::Painter::ScalingMode::BilinearBlend;
|
||||
};
|
||||
resize_canvas_radio->on_checked = [this](bool is_checked) {
|
||||
if (is_checked)
|
||||
m_scaling_mode = Gfx::Painter::ScalingMode::None;
|
||||
};
|
||||
|
||||
auto ok_button = main_widget.find_descendant_of_type_named<GUI::Button>("ok_button");
|
||||
auto cancel_button = main_widget.find_descendant_of_type_named<GUI::Button>("cancel_button");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue