Index: app/core/gimpdrawable-transform.c
===================================================================
RCS file: /cvs/gnome/gimp/app/core/gimpdrawable-transform.c,v
retrieving revision 1.99
diff -p -u -r1.99 gimpdrawable-transform.c
--- a/app/core/gimpdrawable-transform.c	15 Jun 2004 08:18:13 -0000	1.99
+++ b/app/core/gimpdrawable-transform.c	16 Jun 2004 05:20:57 -0000
@@ -387,11 +387,17 @@ gimp_drawable_transform_tiles_affine (Gi
           else
             {
               gint b;
+	      gint threshold;
+	      
+	      if (interpolation_type == GIMP_INTERPOLATION_LINEAR)
+	        threshold = 1;
+              else
+	        threshold = 3;
 
-              if (MAX4 (u[1], u[2], u[3], u[4]) < u1  ||
-                  MAX4 (v[1], v[2], v[3], v[4]) < v1  ||
-                  MIN4 (u[1], u[2], u[3], u[4]) >= u2 ||
-                  MIN4 (v[1], v[2], v[3], v[4]) >= v2)
+              if (MAX4 (u[1], u[2], u[3], u[4]) < (u1 - threshold) ||
+                  MAX4 (v[1], v[2], v[3], v[4]) < (v1 - threshold) ||
+                  MIN4 (u[1], u[2], u[3], u[4]) >= (u2 + threshold) ||
+                  MIN4 (v[1], v[2], v[3], v[4]) >= (v2 + threshold) )
                 {
                   /* not in source range */
                   /* increment the destination pointers  */
@@ -403,6 +409,13 @@ gimp_drawable_transform_tiles_affine (Gi
                 {
                   guchar color[MAX_CHANNELS];
 
+                  /* clamp UV coordinates */
+		  for (b = 0; b < 4; b++)
+		    {
+		      u[i] = CLAMP (u[i], u1 - threshold, u2 + threshold);
+		      v[i] = CLAMP (v[i], v1 - threshold, v2 + threshold);
+		    }
+
                   if (supersample &&
                       supersample_dtest (u[1], v[1], u[2], v[2],
                                          u[3], v[3], u[4], v[4]))
