]> Pileus Git - ~andy/gtk/commitdiff
Force all weight arrays to sum exactly to 65535. (Fixes #70971, reported
authorOwen Taylor <otaylor@redhat.com>
Sat, 9 Feb 2002 04:14:53 +0000 (04:14 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Sat, 9 Feb 2002 04:14:53 +0000 (04:14 +0000)
Fri Feb  8 23:11:15 2002  Owen Taylor  <otaylor@redhat.com>

        * pixops/pixops.c: Force all weight arrays to sum exactly
        to 65535. (Fixes #70971, reported by Federico Mena Quintero)

        * Makefile.am (libgdk_pixbuf_1_3_la_DEPENDENCIES): Add
        libpixops.la.

gdk-pixbuf/ChangeLog
gdk-pixbuf/Makefile.am
gdk-pixbuf/pixops/pixops.c

index 6e32150ab684294292e6213713984fe20b5bbcad..45f47084243bdfdb8539ebff11dd3f222d41cc3f 100644 (file)
@@ -1,3 +1,11 @@
+Fri Feb  8 23:11:15 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * pixops/pixops.c: Force all weight arrays to sum exactly
+       to 65535. (Fixes #70971, reported by Federico Mena Quintero)
+
+       * Makefile.am (libgdk_pixbuf_1_3_la_DEPENDENCIES): Add
+       libpixops.la.
+
 2002-02-08  Federico Mena Quintero  <federico@ximian.com>
 
        * pixops/pixops.h: Fix comment; PixopsInterpType -> GdkInterpType.
index e72011e37e1e748211b14337ff4ad19d2cd0e26c..0c79e995f64bfc4a730dba9ac2d445fc012c0700 100644 (file)
@@ -263,7 +263,7 @@ libgdk_pixbuf_1_3_la_LDFLAGS = @STRIP_BEGIN@ \
 @STRIP_END@
 
 libgdk_pixbuf_1_3_la_LIBADD = pixops/libpixops.la $(builtin_objs) $(GDK_PIXBUF_DEP_LIBS)
-libgdk_pixbuf_1_3_la_DEPENDENCIES = $(builtin_objs) $(gdk_pixbuf_def)
+libgdk_pixbuf_1_3_la_DEPENDENCIES = pixops/libpixops.la $(builtin_objs) $(gdk_pixbuf_def)
 
 gdk_pixbuf_headers =                   \
        gdk-pixbuf.h                    \
index 201c17c0e60d20bcf19d25e67eaf9298c7c8a86b..12ba7f754c338b2c4461919e7df03b58a9e20021 100644 (file)
@@ -1098,6 +1098,7 @@ tile_make_weights (PixopsFilter *filter, double x_scale, double y_scale, double
        double x = (double)j_offset / SUBSAMPLE;
        double y = (double)i_offset / SUBSAMPLE;
        int i,j;
+       int total = 0;
          
        for (i = 0; i < n_y; i++)
          {
@@ -1105,6 +1106,7 @@ tile_make_weights (PixopsFilter *filter, double x_scale, double y_scale, double
                
            if (i < y)
              {
+
                if (i + 1 > y)
                  th = MIN(i+1, y + 1/y_scale) - y;
                else
@@ -1120,6 +1122,8 @@ tile_make_weights (PixopsFilter *filter, double x_scale, double y_scale, double
                
            for (j = 0; j < n_x; j++)
              {
+               int weight;
+               
                if (j < x)
                  {
                    if (j + 1 > x)
@@ -1135,8 +1139,12 @@ tile_make_weights (PixopsFilter *filter, double x_scale, double y_scale, double
                      tw = 0;
                  }
 
-               *(pixel_weights + n_x * i + j) = 65536 * tw * x_scale * th * y_scale * overall_alpha;
+               weight = 65536 * tw * x_scale * th * y_scale * overall_alpha + 0.5;
+               total += weight;
+               *(pixel_weights + n_x * i + j) = weight;
              }
+
+           *(pixel_weights + n_x * n_y - 1) += 65536 - total;
          }
       }
 }
@@ -1184,7 +1192,8 @@ bilinear_make_fast_weights (PixopsFilter *filter, double x_scale, double y_scale
        double x = (double)j_offset / SUBSAMPLE;
        double y = (double)i_offset / SUBSAMPLE;
        int i,j;
-
+       int total = 0;
+       
        if (x_scale > 1.0)      /* Bilinear */
          {
            for (i = 0; i < n_x; i++)
@@ -1251,7 +1260,13 @@ bilinear_make_fast_weights (PixopsFilter *filter, double x_scale, double y_scale
 
        for (i = 0; i < n_y; i++)
          for (j = 0; j < n_x; j++)
-           *(pixel_weights + n_x * i + j) = 65536 * x_weights[j] * x_scale * y_weights[i] * y_scale * overall_alpha + 0.5;
+           {
+             int weight = 65536 * x_weights[j] * x_scale * y_weights[i] * y_scale * overall_alpha + 0.5;
+             *(pixel_weights + n_x * i + j) = weight;
+             total += weight;
+           }
+
+       *(pixel_weights + n_x * n_y - 1) += 65536 - total;
       }
 
   g_free (x_weights);
@@ -1336,19 +1351,24 @@ bilinear_make_weights (PixopsFilter *filter, double x_scale, double y_scale, dou
        double x = (double)j_offset / SUBSAMPLE;
        double y = (double)i_offset / SUBSAMPLE;
        int i,j;
-         
+       int total = 0;
+       
        for (i = 0; i < n_y; i++)
          for (j = 0; j < n_x; j++)
            {
              double w;
+             int weight;
 
              w = bilinear_quadrant  (0.5 + j - (x + 1 / x_scale), 0.5 + j - x, 0.5 + i - (y + 1 / y_scale), 0.5 + i - y);
              w += bilinear_quadrant (1.5 + x - j, 1.5 + (x + 1 / x_scale) - j, 0.5 + i - (y + 1 / y_scale), 0.5 + i - y);
              w += bilinear_quadrant (0.5 + j - (x + 1 / x_scale), 0.5 + j - x, 1.5 + y - i, 1.5 + (y + 1 / y_scale) - i);
              w += bilinear_quadrant (1.5 + x - j, 1.5 + (x + 1 / x_scale) - j, 1.5 + y - i, 1.5 + (y + 1 / y_scale) - i);
-             
-             *(pixel_weights + n_x * i + j) = 65536 * w * x_scale * y_scale * overall_alpha;
+             weight = 65536 * w * x_scale * y_scale * overall_alpha + 0.5;
+             *(pixel_weights + n_x * i + j) = weight;
+             total += weight;
            }
+
+       *(pixel_weights + n_x * n_y - 1) += 65536 - total;
       }
 }