diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog index 4923f1e3cf..fd590b150f 100644 --- a/gdk-pixbuf/ChangeLog +++ b/gdk-pixbuf/ChangeLog @@ -1,3 +1,8 @@ +2003-07-18 Matthias Clasen + + * pixops/pixops.c (correct_total): Split correction into multiple pieces if no single weight is large + enough to apply the unsplit correction. (#117431, problem reported by Tomas Ögren) + 2003-07-11 Matthias Clasen * queryloaders.c (query_module): Handle absolute filenames properly. (#117170, Jens Elkner) diff --git a/gdk-pixbuf/pixops/pixops.c b/gdk-pixbuf/pixops/pixops.c index 1a6c06118f..5b61bd8f79 100644 --- a/gdk-pixbuf/pixops/pixops.c +++ b/gdk-pixbuf/pixops/pixops.c @@ -1078,22 +1078,29 @@ pixops_process (guchar *dest_buf, static void correct_total (int *weights, - int n_x, - int n_y, - int total, - double overall_alpha) + int n_x, + int n_y, + int total, + double overall_alpha) { int correction = (int)(0.5 + 65536 * overall_alpha) - total; - int i; - for (i = n_x * n_y - 1; i >= 0; i--) + int remaining, c, d, i; + + if (correction != 0) { - if (*(weights + i) + correction >= 0) - { - *(weights + i) += correction; - break; - } + remaining = correction; + for (d = 1, c = correction; c != 0 && remaining != 0; d++, c = correction / d) + for (i = n_x * n_y - 1; i >= 0 && c != 0 && remaining != 0; i--) + if (*(weights + i) + c >= 0) + { + *(weights + i) += c; + remaining -= c; + if ((0 < remaining && remaining < c) || + (0 > remaining && remaining > c)) + c = remaining; + } } -} +} static void tile_make_weights (PixopsFilter *filter, double x_scale, double y_scale, double overall_alpha)