Bug 413668 - 1 pixel lines exceed after using Transform tool
Summary: 1 pixel lines exceed after using Transform tool
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Tools/Transform (show other bugs)
Version: 4.2.7
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Dmitry Kazakov
URL:
Keywords:
: 429937 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-10-31 13:02 UTC by nambinh1095
Modified: 2021-07-23 14:15 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
The screenshot (143.75 KB, image/png)
2019-10-31 13:14 UTC, Halla Rempt
Details

Note You need to log in before you can comment on or make changes to this bug.
Description nambinh1095 2019-10-31 13:02:14 UTC
SUMMARY


STEPS TO REPRODUCE
1. Create a selection with Rectangular Selection tool, transform the selected part.
2. Enable grid view and Snap to grid option, scale the selected part to match the grid, apply selection.

OBSERVED RESULT
The image exceed 1 pixel wide after transformed, even after snapped to the grid. It can happen to all 4 sides of the transformed image.


EXPECTED RESULT
The image's pixels fit exactly what is preview when in transform mode / fit exactly to the grid.

SOFTWARE/OS VERSIONS
Windows: 10
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Screenshot
https://prnt.sc/pqn4gt
Comment 1 Halla Rempt 2019-10-31 13:14:20 UTC
Created attachment 123619 [details]
The screenshot
Comment 2 M 2019-11-02 01:57:39 UTC
I can reproduce this. At first I thought it was an issue with snapping and zoom level, but even placing the transform handles pixel perfect can result in this 1 pixel overshoot on 1 or more edges after applying the transformation.
Comment 3 M 2019-11-02 02:19:14 UTC
It looks like there is a mismatch in the active preview of the Transform Tool. I can click and press ESC repeatedly on the previous 1-pixel-off transform result and see that the corner handles and image preview align exactly with the grid.
Comment 4 Dmitry Kazakov 2021-05-24 11:37:45 UTC
I can still reproduce that
Comment 5 Dmitry Kazakov 2021-05-25 12:27:00 UTC
Git commit 26ddc0bed921d20f4331f25e4383752cffa8580e by Dmitry Kazakov.
Committed on 25/05/2021 at 12:26.
Pushed by dkazakov into branch 'master'.

Fix pixel alignment when using transform tool on pixel art

There were two problems:

1) KisTransformWorker accepted the offset measured in integers,
   which created a small drift of the whole image

2) KisFilterWeightsApplicator calculated the destination rect
   too aggressively. The formula might be okay for the filters
   that have whole-pixel support, but for half-pixel-support
   filters it caused issues.

M  +2    -2    libs/image/kis_filter_weights_applicator.h
M  +11   -6    libs/image/kis_transform_worker.cc
M  +2    -2    libs/image/kis_transform_worker.h
M  +42   -0    libs/image/tests/kis_transform_worker_test.cpp
M  +3    -0    libs/image/tests/kis_transform_worker_test.h
M  +2    -2    plugins/tools/tool_transform2/kis_transform_utils.cpp

https://invent.kde.org/graphics/krita/commit/26ddc0bed921d20f4331f25e4383752cffa8580e
Comment 6 Anunay 2021-07-23 14:15:53 UTC
*** Bug 429937 has been marked as a duplicate of this bug. ***