changeset 1630:0204d7c830fb

swap x and y scale when scaling rotated images - it fixes tiles that were sometimes off by 1 pixel - thanks Petr for reporting, code cleanup
author nadvornik
date Sat, 06 Jun 2009 17:28:16 +0000
parents f8503019ac38
children 368b31e37674
files src/pixbuf-renderer.c
diffstat 1 files changed, 23 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/pixbuf-renderer.c	Sat Jun 06 16:14:07 2009 +0000
+++ b/src/pixbuf-renderer.c	Sat Jun 06 17:28:16 2009 +0000
@@ -2122,7 +2122,7 @@
 
 static void pr_tile_coords_map_orientation(PixbufRenderer *pr,
 				     gdouble tile_x, gdouble tile_y, /* coordinates of the tile */
-				     gint image_w, gint image_h,
+				     gdouble image_w, gdouble image_h,
 				     gdouble tile_w, gdouble tile_h,
 				     gdouble *res_x, gdouble *res_y)
 {
@@ -2651,15 +2651,30 @@
 		scale_x = (gdouble)pr->width / pr->image_width;
 		scale_y = (gdouble)pr->height / pr->image_height;
 
-		pr_tile_coords_map_orientation(pr, it->x / scale_x, it->y /scale_y ,
-					    pr->image_width, pr->image_height,
-					    pr->tile_width / scale_x , pr->tile_height / scale_y,
+		pr_tile_coords_map_orientation(pr, it->x, it->y,
+					    pr->image_width * scale_x, pr->image_height * scale_y,
+					    pr->tile_width, pr->tile_height,
 					    &src_x, &src_y);
 		pr_tile_region_map_orientation(pr, x, y,
 					    pr->tile_width, pr->tile_height,
 					    w, h,
 					    &pb_x, &pb_y,
 					    &pb_w, &pb_h);
+		switch (pr->orientation)
+			{
+			gdouble tmp;
+			case EXIF_ORIENTATION_LEFT_TOP:
+			case EXIF_ORIENTATION_RIGHT_TOP:
+			case EXIF_ORIENTATION_RIGHT_BOTTOM:
+			case EXIF_ORIENTATION_LEFT_BOTTOM:
+				tmp = scale_x;
+				scale_x = scale_y;
+				scale_y = tmp;
+				break;
+			default:
+				/* nothing to do */
+				break;
+			}
 
 		/* HACK: The pixbuf scalers get kinda buggy(crash) with extremely
 		 * small sizes for anything but GDK_INTERP_NEAREST
@@ -2669,16 +2684,16 @@
 		if (!has_alpha)
 			{
 			gdk_pixbuf_scale(pr->pixbuf, it->pixbuf, pb_x, pb_y, pb_w, pb_h,
-					 (gdouble) 0.0 - src_x * scale_x,
-					 (gdouble) 0.0 - src_y * scale_y,
+					 (gdouble) 0.0 - src_x,
+					 (gdouble) 0.0 - src_y,
 					 scale_x, scale_y,
 					 (fast) ? GDK_INTERP_NEAREST : pr->zoom_quality);
 			}
 		else
 			{
 			gdk_pixbuf_composite_color(pr->pixbuf, it->pixbuf, pb_x, pb_y, pb_w, pb_h,
-					 (gdouble) 0.0 - src_x * scale_x,
-					 (gdouble) 0.0 - src_y * scale_y,
+					 (gdouble) 0.0 - src_x,
+					 (gdouble) 0.0 - src_y,
 					 scale_x, scale_y,
 					 (fast) ? GDK_INTERP_NEAREST : pr->zoom_quality,
 					 255, it->x + pb_x, it->y + pb_y,