diff src/pixbuf-renderer.c @ 1615:d960b1743ad8

preserve image center over short periods when the "broken image" icon is displayed http://sourceforge.net/tracker/?func=detail&aid=2793057&group_id=222125&atid=1054680
author nadvornik
date Sat, 30 May 2009 20:18:22 +0000
parents 24a12aa0cb54
children 0204d7c830fb
line wrap: on
line diff
--- a/src/pixbuf-renderer.c	Tue May 26 19:41:22 2009 +0000
+++ b/src/pixbuf-renderer.c	Sat May 30 20:18:22 2009 +0000
@@ -3172,11 +3172,23 @@
 	gint src_x, src_y;
 	if (!pr->width || !pr->height) return;
 
-	src_x = pr->x_scroll + pr->vis_width / 2;
-	src_y = pr->y_scroll + pr->vis_height / 2;
-
-	pr->norm_center_x = (gdouble)src_x / pr->width;
-	pr->norm_center_y = (gdouble)src_y / pr->height;
+	/* 
+	 * Update norm_center only if the image is bigger than the window.
+	 * With this condition the stored center survives also a temporary display
+	 * of the "broken image" icon.
+	*/
+
+	if (pr->width > pr->window_width)
+		{
+		src_x = pr->x_scroll + pr->vis_width / 2;
+		pr->norm_center_x = (gdouble)src_x / pr->width;
+		}
+	
+	if (pr->height > pr->window_height)
+		{
+		src_y = pr->y_scroll + pr->vis_height / 2;
+		pr->norm_center_y = (gdouble)src_y / pr->height;
+		}
 }