SUMMARY I often use 'invert selection' to grow and create a cut line for files sent off to be made into stickers or other printouts in Krita. After updating to Krita 3.0, the 'invert selection' includes a strange selection in the bottom and right portions off canvas consistently with all my files, whether transparent .png files or cropping and selecting with a new blank .kra file. STEPS TO REPRODUCE 1. Create new file, color a blob anywhere. Crop to desired size, save as a png (this is showing up with jpg as well now though not as dramatically). 2. Close document, reopen flattened file (jpg or png), and use the selection tool to select around the color blob. Choose invert. 3. Selection inverts but adds a selection around the right and/or bottom outside of canvas. OBSERVED RESULT https://krita-artists.org/t/krita-5-3-selection-update-issue/177356 https://youtu.be/w1SMdWeHnxQ EXPECTED RESULT Expected result is to not include outside the canvas. SOFTWARE/OS VERSIONS Windows: 10
I can confirm this for the 5.3.0 appimage running on Linux Mint. It happens with any .png file, not just one made by Exporting from krita but the contents have an effect. If there is an isolated blob on a transparent background then inverting a selection shows the problem. If there are two or more blobs on a transparent background then there is no problem. Also, modifying the image by erasing outside of the canvas will increase the selected area that is added by inverting a selection. These observations do not happen with a new document made in krita, only with an imported .png/.jpg file.
*** Bug 518940 has been marked as a duplicate of this bug. ***
*** Bug 519757 has been marked as a duplicate of this bug. ***
This can happen with any document no matter how it was created. The number of blobs/marks or how they were does not matter as far as I can tell, only the location of the non-transparent pixels does. Pixels close to the bottom and right edges cause this, as do pixels anywhere off-canvas. I'm guessing Krita allocates data in chunks rather than pixel by pixel or for the entire layer, and when there are marks near the bottom/right canvas edge or off the canvas to the top/left, it allocates chunks that partially go off-canvas, and those off-canvas empty pixels are erroneously included when inverting the selection. I experimented with various canvas sizes, and it seems the extra pixels "added" in the inverted selection always pad the effective size to some multiple of a power of 2. On a 64x64 canvas, the bug does not occur unless pixels are placed off-canvas, I'm guessing because the allocated chunks exactly match the canvas size. (The chunk size seems to grow with the canvas size though, so just making the canvas a multiple of 64x64 is not enough to avoid this bug, it's likely there are only a few "perfect" canvas sizes.) (I'm on 5.3.1)
I can reproduce on Arch Linux on KDE with the Krita development branch. We're not handling well, where the selection size exceeds the canvas size. See commit d361e80ffa4676619a242ac3b53b27bd1ec89761 on invent. It seems like we're iterating incorrectly over the canvas, which leaves these "gaps" in the +X/-Y space. I will open an MR if I have time.
I set you as an assignee, then. Thanks!
(In reply to Tiar from comment #6) > I set you as an assignee, then. Thanks! FYI I have a patch open to resolve. Pending approval to merge to the dev branch. Thank you.
MR: https://invent.kde.org/graphics/krita/-/merge_requests/2788
Fixed in https://invent.kde.org/graphics/krita/-/commit/5e83a17d045e5a54b26bf0c5c03234a1e625345b