summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Wiederhake <BenWiederhake.GitHub@gmx.de>2021-11-21 15:37:46 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-22 22:14:53 +0100
commit7f962cd9d330f6fe5ec171bd101792da1dcaff24 (patch)
tree3a51ce48670c4958262323ba125f06faef4409df
parenta436f0c6681aed3bf3dd5d2ea8e5074cad1665da (diff)
downloadserenity-7f962cd9d330f6fe5ec171bd101792da1dcaff24.zip
PixelPaint: Floor effective viewport size to whole integers
We don't have fractional pixels available, so don't attempt to use them.
-rw-r--r--Userland/Applications/PixelPaint/ImageEditor.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp
index f448f1b354..fd3093c92f 100644
--- a/Userland/Applications/PixelPaint/ImageEditor.cpp
+++ b/Userland/Applications/PixelPaint/ImageEditor.cpp
@@ -616,9 +616,9 @@ void ImageEditor::fit_image_to_view()
const float border_ratio = 0.95f;
auto image_size = image().size();
- auto height_ratio = viewport_rect.height() / (float)image_size.height();
- auto width_ratio = viewport_rect.width() / (float)image_size.width();
- m_scale = border_ratio * min(height_ratio, width_ratio);
+ auto height_ratio = floorf(border_ratio * viewport_rect.height()) / (float)image_size.height();
+ auto width_ratio = floorf(border_ratio * viewport_rect.width()) / (float)image_size.width();
+ m_scale = min(height_ratio, width_ratio);
float offset = m_show_rulers ? -m_ruler_thickness / (m_scale * 2.0f) : 0.0f;
m_pan_origin = Gfx::FloatPoint(offset, offset);