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 553534 - centering issues after image scaling and setting zoom to 100%
centering issues after image scaling and setting zoom to 100%
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: User Interface
2.5.x
Other Linux
: Normal normal
: 2.6
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2008-09-24 09:48 UTC by Norm Murray
Modified: 2008-11-15 10:34 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
showing off center image (49.61 KB, image/jpeg)
2008-09-24 12:04 UTC, Norm Murray
Details

Description Norm Murray 2008-09-24 09:48:09 UTC
control-e to resize a window to a zoomed image. 
scale the image down to something smaller. the zoom level stays the same so the visible image in the window shrinks as expected. 
type "1" in the window in order to set zoom to 100%
expected based on past gimp behaviour:
   the image goes to 100% centered in the current window
current behaviour
   the image goes to 100%, but offset within the window so that the background is visible.

the scaled image is slightly larger than the current window size when this happens. it is reproducible on my system. 

resize window on zoom is turned off. 

local builds:
babl-0.0.22-1.fc9.x86_64
gegl-0.0.18-1.fc9.x86_64
gimp-2.5.4-1.fc9.x86_64
Comment 1 Martin Nordholts 2008-09-24 10:32:46 UTC
Hmm let me see if I got this straight. The problem should be reproducable with these steps, right?:

1. Create a new Image
2. Set zoom level to 50%
3. Press Ctrl-E to wrap the image window around the image so the image just fits within the image window.
4. Scale the image down a bit. The image is still centered in the image window but it does not fill the image window any longer, and zoom level is 50%
5. Press 1.

Expected result:
The zoom level is set to 100% and the image is centered in the image window

When I try this in GIMP 2.5 SVN trunk I get the expected result, but I *don't* get the expected result when I do this in GIMP 2.4, which is what you claim happends. The image does not become centered then.

So as far as I can see this works as you want in GIMP 2.5 SVN trunk. Are you sure you didn't not mix something up? Am I missing something?

Comment 2 Norm Murray 2008-09-24 12:04:28 UTC
Created attachment 119293 [details]
showing off center image

This is what I'm getting when
1) Open an image (in this case a 2920x4380 pixel image) - defaults to a zoom of 18.2%
2) Right click to bring up context menu, select image->scale image
3) enter new size, in this case 533 x 800, tabbing between fields, hitting enter when 'pixels' is highlighted
The image then scales and displays as a thumbnail within the window, centered
4) press '1' to set zoom to 100%

The attachment is one result. So far in my use of 2.5.4 the resulting slide of the image around seems to be fairly random. Mostly it seems to have an up/down skew, but I have seen it with some left/right offset as well (though so far not just with a left/right offset, the vertical component is always there).
Comment 3 Martin Nordholts 2008-09-24 12:27:54 UTC
I am able to reproduce this now, thanks for the bug report.
Comment 4 Martin Nordholts 2008-09-24 12:42:09 UTC
When you press '1', where do you keep the mouse pointer? If you keep the mouse pointer outside of the image window or in the center of it, the image should remain centered.

What happens here is that when the have the mouse pointer within the image window, GIMP tries to keep the pixel under the cursor stable. If you zoom in continuously with the + key you will notice that the pixel under the mouse pointer remain stable. What we see here is a side effect of this behavior.

Can you confirm the above theory?
Comment 5 Norm Murray 2008-09-24 12:49:00 UTC
I've had the cursor in the image window, to keep it selected (focus on window enter). So yes, if I bring the mouse pointer outside the window and return focus to it with alt-tab before pressing '1', the image remains centered when zooming. If I bring the pointer into the window but not in the center, that's when it skews. 

So I'd call the theory confirmed by behaviour. Thanks. 
Comment 6 Martin Nordholts 2008-09-25 07:19:34 UTC
Arguably using keyboard shortcuts for menu items should act as if the menu item was clicked. Then it follows that the current behavior is a bug. In order to fix it though I'd have to do stuff slightly too risky for GIMP 2.6, so I'm moving this to the GIMP 2.8 milestone.
Comment 7 Sven Neumann 2008-09-25 07:29:34 UTC
Could you show us the patch so we can evaluate how risky it is ?
Comment 8 Martin Nordholts 2008-09-25 07:39:55 UTC
The patch will be to give gimp_display_shell_scale() an origin-parameter and pass this on to gimp_display_shell_scale_get_zoom_focus() which will then use that parameter as a hint. That is, all calls to gimp_display_shell_scale() would be altered. That function is not used in an overwhelming amount of places, but its usage branches out through utility functions.

Once we have branched out for GIMP 2.6 we can see how complicated this actually becomes. If it turns out that it wasn't such a big deal we can backport the fix to GIMP 2.6.1.
Comment 9 Norm Murray 2008-09-25 07:45:28 UTC
Outside thought - since this is related to keeping the pixels under the mouse constant on zoom change, could it make sense to 'fix' by checking if the pixels are in the image or not - if not, then don't try to keep them constant when zooming? 
Comment 10 Martin Nordholts 2008-10-02 14:55:07 UTC
Actually the fix can be made as good as failure proof. I've commited a "failure proof" fix to trunk, rev 27104:

2008-10-02  Martin Nordholts  <martinn@svn.gnome.org>

	Bug 553534 – centering issues after image scaling and setting zoom
	to 100%

	* app/display/display-enums.h: Added a GimpZoomFocus enum with
	'best guess', 'pointer' or 'image center' values.

	* app/display/gimpdisplayshell-scale.[ch]
	(gimp_display_shell_scale): Take a GimpZoomFocus parameter and
	pass it on to

	(gimp_display_shell_scale_get_zoom_focus): which returns the
	requested zoom focus point if one was given, else makes a best
	guess.

	* app/actions/view-commands.c
	* app/display/gimpstatusbar.c
	* app/display/gimpnavigationeditor.c
	* app/display/gimpdisplayshell-callbacks.c
	* app/display/gimpdisplayshell-scale-dialog.c: For explicit-zoom
	commands like "zoom to 100%", always use the image center as the
	zoom focus point. For all other zooming, continue to use the
	best-guess method.

	* app/display/display-enums.c: Regenerated.
Comment 11 Martin Nordholts 2008-10-08 05:32:16 UTC
*** Bug 555493 has been marked as a duplicate of this bug. ***
Comment 12 Claus Berghammer 2008-10-25 17:50:16 UTC
I see Bug 555493 is marked as duplicate, but still open and growing. Not shure if I shall post here or there, now? -> I do here!

The Patch in 2.6.1 makes the situation even worse to me (Windows User). If I zoomed in with 2.6.0, put the cursor on the "pixels of interest", and type "1", the pixels of interest WAS at (or close to) the cursor (as expected). Now, with 2.6.1, the "pixels of interest" are somewhere, but not by far close to the cursor. Instead I always see the corner which is closest to the "pixels of interest" centered in the window.

Beside that, the patch didn't do anything to the problem, when mouse is outside the image. In that case, both 2.6.0 and 2.6.1 behave not as I would expect (I expect the current pixel in the center of the view, still to be the pixel in the center of the view after zooming out [no mather if I use "1" or the 100% entry in "zoom bar"].

How to reproduce:
1.) open large image file (large enough, that zoom is smaller than 100%, e.g. 33%)
2.) zoom into a place that is not close to any symetric axes (e.g. 25% from left and top)
3.) place the cursor on the pixels you like to see
4.) type "1"

Expected result:
Pixels under cursor before zoom out should be pixels under cursor after zoom out

Actual results:
Image-corner closest to pixels of interest are centerd in view.
Comment 13 Martin Nordholts 2008-10-25 18:06:01 UTC
Regarding your first point, that is a matter of taste. I prefer the way it works now and I don't see any compelling reason to change.

Regarding your second point, I think that behavior might have been introduced when zooming out didn't center the image if the image fits in the viewport. Since it does that now, it might be reasonable to change that back. Please ask for feedback on the gimp-developer mailing list regarding this. If it turns out people like to focus on the image under the cursor even when the cursor is outside the image window, we can change this back.

One mores, please don't use bug reports to discuss things that is not about the bug report itself, use the gimp-developer or gimp-user mailing lists instead.
Comment 14 Martin Nordholts 2008-11-15 10:34:11 UTC
I am starting to question my decision to handle explicit zooming with '1' different from relative zooming with '+' as far as zoom focusing goes.

I have made '1' work like '+' except for the use case in this bug report which I for now consider a special case:

2008-11-15  Martin Nordholts  <martinn@svn.gnome.org>

	Bug 560903 – Explicit zooming with e.g. '1' should handle
	zoom-focus better

	* app/display/display-enums.h: Added
	GIMP_ZOOM_FOCUS_RETAIN_CENTERING_ELSE_BEST_GUESS.

	* app/display/gimpdisplayshell-scale.c
	(gimp_display_shell_scale_get_zoom_focus): Take the new enum into
	account; if the image is centered, keep it centered, else use the
	best-guess method.

	* app/actions/view-commands.c (view_zoom_explicit_cmd_callback):
	Use the new enum for explicit zooming.

	* app/display/display-enums.c: Regenerated.