From 7f962cd9d330f6fe5ec171bd101792da1dcaff24 Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Sun, 21 Nov 2021 15:37:46 +0100 Subject: [PATCH] PixelPaint: Floor effective viewport size to whole integers We don't have fractional pixels available, so don't attempt to use them. --- Userland/Applications/PixelPaint/ImageEditor.cpp | 6 +++--- 1 file 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);