Bug 400177 - Scale to New Size Doesn't Do Arithmetic Right
Summary: Scale to New Size Doesn't Do Arithmetic Right
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Resize/Scale Image/Layer (show other bugs)
Version: 4.1.5
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Tiar
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-23 01:36 UTC by Kenneth Evans
Modified: 2019-03-02 11:06 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Screenshot of Scale to New Size Dialog (25.57 KB, image/png)
2018-10-23 01:36 UTC, Kenneth Evans
Details

Note You need to log in before you can comment on or make changes to this bug.
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.


STEPS TO REPRODUCE
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.)
3. 

OBSERVED RESULT
5405 x 3602 (or 17.99 x 11.99)

EXPECTED RESULT
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

Summary:
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

https://commits.kde.org/krita/03db690749bc2481396c510073a773acb6d3d60f