All pastes #2106422 Raw Edit

Mine

public text v1 · immutable
#2106422 ·published 2012-01-26 13:21 UTC
rendered paste body
diff --git a/draw/draw_scale.c b/draw/draw_scale.c
index b2e28b7..489a2eb 100644
--- a/draw/draw_scale.c
+++ b/draw/draw_scale.c
@@ -347,22 +347,28 @@ add_weight(fz_weights *weights, int j, int i, fz_scale_filter *filter,
                dist = -dist;
        f = filter->fn(filter, dist)*F;
        weight = (int)(256*f+0.5f);
-       if (weight == 0)
-               return;

        /* Ensure i is in range */
        if (i < 0)
        {
                i = 0;
-               weight = 0;
+               return;
        }
        else if (i >= src_w)
        {
                i = src_w-1;
-               weight = 0;
+               return;
        }
        if (weight == 0)
-               return;
+       {
+               /* We add a fudge factor here to allow for extreme downscales
+                * where all the weights round to 0. Ensure that at least one
+                * (arbitrarily the first one) is non zero. */
+               if (weights->new_line && f > 0)
+                       weight = 1;
+               else
+                       return;
+       }

        DBUG(("add_weight[%d][%d] = %d(%g) dist=%g\n",j,i,weight,f,dist));