From aebc260940a8e78fdd2fcbf1d09074976312c8a5 Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Fri, 19 May 2023 00:29:05 +0200 Subject: PixelPaint: Add support for box sampling scaling --- Userland/Applications/PixelPaint/ResizeImageDialog.cpp | 9 +++++++-- Userland/Applications/PixelPaint/ResizeImageDialog.gml | 8 +++++++- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'Userland') diff --git a/Userland/Applications/PixelPaint/ResizeImageDialog.cpp b/Userland/Applications/PixelPaint/ResizeImageDialog.cpp index edc2e26d01..dc6b9d9504 100644 --- a/Userland/Applications/PixelPaint/ResizeImageDialog.cpp +++ b/Userland/Applications/PixelPaint/ResizeImageDialog.cpp @@ -69,17 +69,18 @@ ResizeImageDialog::ResizeImageDialog(Gfx::IntSize suggested_size, GUI::Window* p auto nearest_neighbor_radio = main_widget->find_descendant_of_type_named("nearest_neighbor_radio"); auto smooth_pixels_radio = main_widget->find_descendant_of_type_named("smooth_pixels_radio"); auto bilinear_radio = main_widget->find_descendant_of_type_named("bilinear_radio"); + auto box_sampling_radio = main_widget->find_descendant_of_type_named("box_sampling_radio"); auto resize_canvas_radio = main_widget->find_descendant_of_type_named("resize_canvas"); VERIFY(nearest_neighbor_radio); VERIFY(smooth_pixels_radio); VERIFY(bilinear_radio); + VERIFY(box_sampling_radio); VERIFY(resize_canvas_radio); m_scaling_mode = Gfx::Painter::ScalingMode::NearestNeighbor; - if (bilinear_radio->is_checked()) { + if (bilinear_radio->is_checked()) m_scaling_mode = Gfx::Painter::ScalingMode::BilinearBlend; - } nearest_neighbor_radio->on_checked = [this](bool is_checked) { if (is_checked) @@ -93,6 +94,10 @@ ResizeImageDialog::ResizeImageDialog(Gfx::IntSize suggested_size, GUI::Window* p if (is_checked) m_scaling_mode = Gfx::Painter::ScalingMode::BilinearBlend; }; + box_sampling_radio->on_checked = [this](bool is_checked) { + if (is_checked) + m_scaling_mode = Gfx::Painter::ScalingMode::BoxSampling; + }; resize_canvas_radio->on_checked = [this](bool is_checked) { if (is_checked) m_scaling_mode = Gfx::Painter::ScalingMode::None; diff --git a/Userland/Applications/PixelPaint/ResizeImageDialog.gml b/Userland/Applications/PixelPaint/ResizeImageDialog.gml index fa743b49ec..39bcca0a57 100644 --- a/Userland/Applications/PixelPaint/ResizeImageDialog.gml +++ b/Userland/Applications/PixelPaint/ResizeImageDialog.gml @@ -1,7 +1,7 @@ @GUI::Widget { fill_with_background_color: true min_width: 260 - min_height: 260 + min_height: 280 layout: @GUI::VerticalBoxLayout { margins: [4] } @@ -93,6 +93,12 @@ autosize: true } + @GUI::RadioButton { + name: "box_sampling_radio" + text: "Box Sampling" + autosize: true + } + @GUI::RadioButton { name: "resize_canvas" text: "Resize Canvas (None)" -- cgit v1.2.3