Fix off-by-one pixel exports in Image Split

Fixes Bug 492965

this merge request fixes an off-by-one pixel discrepancy when splitting images using guide lines.

floating point precision loss during coordinate mapping (documentToImage.map()) caused exact values like 32.0 to become slightly less (e.g., 31.999999999999996). The old code implicitly truncated these values into integers, snapping coordinates backward and creating unequal tile sizes (e.g., 15px, 16px, or 17px instead of uniform 16px blocks).

the fix uses qRound() to correctly round the mapped coordinates to the nearest pixel boundary.

Images for reference:

Before fix:

WhatsApp Image 2026-06-03 at 7.01.36 PM.jpeg

WhatsApp Image 2026-06-03 at 6.47.21 PM.jpeg

After fix:

WhatsApp Image 2026-06-03 at 7.01.55 PM.jpeg

WhatsApp Image 2026-06-03 at 6.50.23 PM.jpeg

Test Plan

Test file (same as bug report, guides at 16px , 32px and 48px) :

bug_492965_file_with_guides (1).kra

  1. Open the test file given (or create a new image with horizontal and vertical guides set exactly at 16px, 32px, and 48px)
  2. Go to Image>Image Spilt and make sure to check "Use Guides"
  3. Check the dimensions of the exported image files. All tiles must be exactly 16×16 pixels. They should no longer vary between 15px, 16px, or 17px as they did before the fix (see references attached)

Formalities Checklist

  • I confirmed this builds.
  • I confirmed Krita ran and the relevant functions work.
  • I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!)
  • I made sure my commits build individually and have good descriptions as per KDE guidelines.
  • I made sure my code conforms to the standards set in the HACKING file.
  • I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.
  • Does the patch add a user-visible feature? If yes, is there a documentation MR ready for it at Krita Documentation Repository?

Reminder: the reviewer is responsible for merging the patch, this is to ensure at the least two people can build the patch. In case a patch breaks the build, both the author and the reviewer should be contacted to fix the build. If this is not possible, the commits shall be reverted, and a notification with the reasoning and any relevant logs shall be sent to the mailing list, kimageshop@kde.org.

Merge request reports

Loading