Index: gimpdrawable-transform.c
===================================================================
RCS file: /cvs/gnome/gimp/app/core/gimpdrawable-transform.c,v
retrieving revision 1.110
diff -u -p -r1.110 gimpdrawable-transform.c
--- gimpdrawable-transform.c	19 Jan 2005 10:22:19 -0000	1.110
+++ gimpdrawable-transform.c	21 Jan 2005 09:08:11 -0000
@@ -1681,7 +1681,7 @@ lanczos_sum (const guchar *data,
   gint    j, k;
 
   for (k = 0, j = 0; j < LANCZOS_WIDTH2; j++, k+=bytes)
-    sum += (l[j] * data[row+k]);
+    sum += (l[j] * data[row+k+byte]);
 
   return sum;
 }
@@ -1749,7 +1749,7 @@ sample_lanczos (PixelSurround *surround,
   gint     iv = floor(v);
 
   /* lock the pixel surround */
-  data = pixel_surround_lock (surround, iu - 1 , iv - 1 );
+  data = pixel_surround_lock (surround, iu - LANCZOS_WIDTH , iv - LANCZOS_WIDTH );
 
   row = pixel_surround_rowstride (surround);
 
@@ -1767,53 +1767,39 @@ sample_lanczos (PixelSurround *surround,
 
   weight = lusum * lvsum;
 
-  if (alpha != 0)
+  for ( aval = 0, i = 0 ; i < LANCZOS_WIDTH2 ; i ++ )
+    aval += lv[i] * lanczos_sum (data, lu,
+                                 i * row,
+                                 bytes, alpha);
+
+  /* calculate alpha of result */
+  aval /= weight;
+
+  if ( aval <= 0.0 )
+    {
+      arecip = 0.0;
+      color[alpha] = 0;
+    }
+  else if ( aval > 255.0 )
     {
-       for ( aval = 0, i = 0 ; i < LANCZOS_WIDTH2 ; i ++ )
-          aval += lv[i] * lanczos_sum (data, lu,
-                                       i * LANCZOS_WIDTH2 * bytes,
-                                       bytes, alpha);
-
-       /* calculate alpha of result */
-       aval /= weight;
-
-       if ( aval <= 0.0 )
-         {
-           arecip = 0.0;
-           color[alpha] = 0;
-         }
-       else if ( aval > 255.0 )
-         {
-           arecip = 1.0 / aval;
-           color[alpha] = 255;
-         }
-       else
-         {
-           arecip = 1.0 / aval;
-           color[alpha] = RINT (aval);
-         }
-
-       for (byte = 0; byte < alpha; byte++)
-         {
-           for (newval = 0, i = 0; i < LANCZOS_WIDTH2; i ++)
-             newval += lv[i] * lanczos_sum_mul (data, lu,
-                                                i * LANCZOS_WIDTH2 * bytes,
-                                                bytes, byte, alpha);
-           newval *= arecip;
-           color[byte] = CLAMP (newval, 0, 255);
-         }
+      arecip = 1.0 / aval;
+      color[alpha] = 255;
     }
   else
     {
-      for (byte = 0; byte < bytes; byte++)
-        {
-          for (newval = 0, i = 0 ; i < LANCZOS_WIDTH2 ; i++ )
-            newval += lv[i] * lanczos_sum (data, lu,
-                                           i * LANCZOS_WIDTH2 * bytes,
-                                           bytes, byte);
-
-          newval /= weight;
-          color[byte] = CLAMP ((gint) newval, 0, 255);
-        }
+      arecip = 1.0 / aval;
+      color[alpha] = RINT (aval);
     }
+
+  for (byte = 0; byte < alpha; byte++)
+    {
+      for (newval = 0, i = 0; i < LANCZOS_WIDTH2; i ++)
+        newval += lv[i] * lanczos_sum_mul (data, lu,
+                                           i * row,
+                                           bytes, byte, alpha);
+        newval *= arecip;
+        color[byte] = CLAMP (newval, 0, 255);
+    }
+
+  pixel_surround_release (surround);
 }
