After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 143887 - selection rectangle "move" when start at the top-right corner
selection rectangle "move" when start at the top-right corner
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Tools
2.0.x
Other Linux
: Normal minor
: 2.2
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2004-06-07 17:30 UTC by Baptiste Mille-Mathias
Modified: 2005-03-18 01:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
selection tool rewrite (16.22 KB, patch)
2005-03-07 15:16 UTC, Nils Björklund
none Details | Review

Description Baptiste Mille-Mathias 2004-06-07 17:30:59 UTC
create a picture (say 64 x 64)
zoom a lit bit.
start a rectangle selection which from the top right corner of the picture.
you can see the right side of the selection doesn't stay on the right border of
the picture. (the pb appears when you extend the selction on the left, not to
bottom).

Hope you will understand the problem.
Comment 1 Sven Neumann 2004-06-07 18:13:57 UTC
Difficult to understand since you need to start exactly at the right edge of the
image (not in the canvas beyond the right edge). This isn't really common usage
so I am lowering the severity of this report to minor.
Comment 2 Nils Björklund 2005-03-07 15:14:10 UTC
This problem occurs when selection goes in any direction except down-right from
the starting point and the starting point is close to a pixel center. It doesn't
matter where the on the canvas the selection starts. 

The easiest way to reproduce it is the create a picture and zoom to 200% and
select in a up-left direction. You may have to try a few times to trigger it.
Ellipse selection is also affected.

The cause is rounding errors in gimprectselecttool.c, I have a patch that fixes
the problem and IMO cleans up the code. I'm a gimp coding newbie however, so it
is probably full of errors =).
Comment 3 Nils Björklund 2005-03-07 15:16:13 UTC
Created attachment 38366 [details] [review]
selection tool rewrite
Comment 4 Sven Neumann 2005-03-07 15:21:55 UTC
The patch looks reasonable but it would be nice if you could add a short
explanation of the approach that your patch takes.
Comment 5 Nils Björklund 2005-03-07 15:56:51 UTC
Sure, the first thing I did was to add a starting point that keeps the
coordinate where the mouse button was first pressed. In the motion function the
selection coordinate, width and height are calculated from the starting point
and the current cursor coordinate. This is unlike previously when the selection
coordinate, width and height where calculated from the previous coordinate,
width and height and the current coordinate. I wanted to avoid this because of
the risk of rounding errors stacking up. It also made the code simpler.

Second change was to keep the calculation of absolute width and height separate
from the direction of the selection to simplify the code.

Third change was to add proper rounding to fix the bug.

Fourth change was changing variable types from gdoubles to gints as they would
always have integer values anyway.
Comment 6 Sven Neumann 2005-03-07 21:31:50 UTC
Applied to the HEAD branch so that it gets some testing:

2005-03-07  Sven Neumann  <sven@gimp.org>

	* app/tools/gimpellipseselecttool.c
	* app/tools/gimprectselecttool.[ch]: applied a patch by Nils
	Bjorklund that should fix bug #143887 (selection rectangle "moves"
	when starting at the top-right corner).
Comment 7 Sven Neumann 2005-03-18 01:59:38 UTC
I've merged this change into the gimp-2-2 branch now. Closing as FIXED. Nils,
thanks a lot for the patch.