1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:38:11 +00:00

ImageViewer: Allow choice between nearest neighbor and bilinear scaling

Currently, ImageViewer always uses nearest neighbor scaling.
This allows the user to choose whether to use nearest neighbor
or bilinear scaling. It current defaults to nearest neighbor.
This commit is contained in:
Luke Wilde 2021-12-29 15:37:04 +00:00 committed by Andreas Kling
parent e179cf2540
commit 8eb01c0b11
3 changed files with 33 additions and 2 deletions

View file

@ -14,7 +14,6 @@
#include <LibCore/MappedFile.h>
#include <LibCore/Timer.h>
#include <LibGUI/MessageBox.h>
#include <LibGUI/Painter.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/Orientation.h>
#include <LibGfx/Palette.h>
@ -178,7 +177,7 @@ void ViewWidget::paint_event(GUI::PaintEvent& event)
Gfx::StylePainter::paint_transparency_grid(painter, frame_inner_rect(), palette());
if (!m_bitmap.is_null())
painter.draw_scaled_bitmap(m_bitmap_rect, *m_bitmap, m_bitmap->rect());
painter.draw_scaled_bitmap(m_bitmap_rect, *m_bitmap, m_bitmap->rect(), 1.0f, m_scaling_mode);
}
void ViewWidget::mousedown_event(GUI::MouseEvent& event)
@ -343,4 +342,10 @@ void ViewWidget::animate()
}
}
void ViewWidget::set_scaling_mode(Gfx::Painter::ScalingMode scaling_mode)
{
m_scaling_mode = scaling_mode;
update();
}
}