Bug 400177

Summary: Scale to New Size Doesn't Do Arithmetic Right
Product: [Applications] krita Reporter: Kenneth Evans <ken>
Component: Resize/Scale Image/LayerAssignee: Tiar <tamtamy.tymona>
Severity: normal CC: griffinvalley, tamtamy.tymona
Priority: NOR    
Version: 4.1.5   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Screenshot of Scale to New Size Dialog

Description Kenneth Evans 2018-10-23 01:36:19 UTC
Created attachment 115838 [details]
Screenshot of Scale to New Size Dialog

I resized an image to 18" x 12" at 300 dpi.  It didn't come out as 5400 x 3600, rather 5405 x 3602.  I then tried sizing it to 5400 x 3600, and the size was 17.99" x 11.99".  There seems to be an error somewhere.  Even if done in float, it should have more precision than this.

1. With an existing image, attempt to resize it to 18" x 12" @300 dpi.
2. Just look at the dialog.  (You don't have to actually do it.)

5405 x 3602 (or 17.99 x 11.99)

5400 x 3600 (or 18.00 x 12.00)

Image attached of the setting 5400 x 3600 case.
Comment 1 wolthera 2018-11-16 15:47:52 UTC
This is related to bug https://bugs.kde.org/show_bug.cgi?id=395267 but I am not 100% sure to say they are duplicates.
Comment 2 Kenneth Evans 2018-11-16 19:45:25 UTC
I don't think it is a duplicate. The other issue is about print sizes and a possible limit for print only. This one has to do with imprecise calculations of image size.
Comment 3 wolthera 2019-03-02 11:06:26 UTC
Git commit 03db690749bc2481396c510073a773acb6d3d60f by Wolthera van Hövell tot Westerflier, on behalf of Agata Cacko.
Committed on 02/03/2019 at 11:06.
Pushed by woltherav into branch 'master'.

Fix the conversion errors in Scale to New Size dialog

SpinBoxUnitManager used a function that not only converts units,
but also rounds them (for the View), hence the conversion errors.
This patch changes function to the precise one.

Test Plan:
Checking the Scale to New Size dialog to see whether the bug doesn't reproduce.
Checking whether it doesn't break other scale/resize/offset/crop dialogs and every other place
where the units are being used.

Reviewers: #krita, rempt

Reviewed By: #krita, rempt

Tags: #krita

Differential Revision: https://phabricator.kde.org/D19448

M  +1    -1    libs/widgetutils/kis_spin_box_unit_manager.cpp