gimp r27380 - in trunk: . app/paint-funcs



Author: neo
Date: Thu Oct 23 22:07:59 2008
New Revision: 27380
URL: http://svn.gnome.org/viewvc/gimp?rev=27380&view=rev

Log:
2008-10-24  Sven Neumann  <sven gimp org>

	* app/paint-funcs/scale-region.c (scale): use the inverse of the
	scale factor so that we can multiply instead of dividing in the
	loops.



Modified:
   trunk/ChangeLog
   trunk/app/paint-funcs/scale-region.c

Modified: trunk/app/paint-funcs/scale-region.c
==============================================================================
--- trunk/app/paint-funcs/scale-region.c	(original)
+++ trunk/app/paint-funcs/scale-region.c	Thu Oct 23 22:07:59 2008
@@ -466,8 +466,8 @@
   const guint     bytes      = tile_manager_bpp    (dstTM);
   const guint     dst_width  = tile_manager_width  (dstTM);
   const guint     dst_height = tile_manager_height (dstTM);
-  const gdouble   scaley     = (gdouble) dst_height / (gdouble) src_height;
-  const gdouble   scalex     = (gdouble) dst_width  / (gdouble) src_width;
+  const gdouble   scaley     = (gdouble) src_height / (gdouble) dst_height;
+  const gdouble   scalex     = (gdouble) src_width  / (gdouble) dst_width;
   gpointer        pr;
   gfloat         *kernel_lookup = NULL;
 
@@ -522,38 +522,38 @@
       for (y = region.y; y < y1; y++)
         {
           guchar  *pixel = row;
-          gdouble  yfrac = y / scaley + 0.5;
-          gint     sy0   = (gint) yfrac;
+          gdouble  yfrac = y * scaley + 0.5;
+          gint     sy    = (gint) yfrac;
           gint     x;
 
-          yfrac = yfrac - sy0;
+          yfrac = yfrac - sy;
 
           for (x = region.x; x < x1; x++)
             {
-              gdouble xfrac = x / scalex + 0.5;
-              gint    sx0   = (gint) xfrac;
+              gdouble xfrac = x * scalex + 0.5;
+              gint    sx    = (gint) xfrac;
 
-              xfrac = xfrac - sx0;
+              xfrac = xfrac - sx;
 
               switch (interpolation)
                 {
                 case GIMP_INTERPOLATION_NONE:
-                  interpolate_nearest (srcTM, sx0, sy0, xfrac, yfrac, pixel);
+                  interpolate_nearest (srcTM, sx, sy, xfrac, yfrac, pixel);
                   break;
 
                 case GIMP_INTERPOLATION_LINEAR:
                   interpolate_bilinear (surround,
-                                        sx0, sy0, xfrac, yfrac, bytes, pixel);
+                                        sx, sy, xfrac, yfrac, bytes, pixel);
                   break;
 
                 case GIMP_INTERPOLATION_CUBIC:
                   interpolate_cubic (surround,
-                                     sx0, sy0, xfrac, yfrac, bytes, pixel);
+                                     sx, sy, xfrac, yfrac, bytes, pixel);
                   break;
 
                 case GIMP_INTERPOLATION_LANCZOS:
                   interpolate_lanczos3 (surround,
-                                        sx0, sy0, xfrac, yfrac, bytes, pixel,
+                                        sx, sy, xfrac, yfrac, bytes, pixel,
                                         kernel_lookup);
                   break;
                 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]