summaryrefslogtreecommitdiff
path: root/draw
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2010-07-23 18:47:33 +0000
committerRobin Watts <robin.watts@artifex.com>2010-07-23 18:47:33 +0000
commitc2992c2f3567a02772a420ad132180d42854d71b (patch)
tree42c76a210add3a0f06a870632ccdddf097814eac /draw
parent0da7075063e13032b2f11ca39fc9624f3c91e3c7 (diff)
downloadmupdf-c2992c2f3567a02772a420ad132180d42854d71b.tar.xz
Fix to stop the asserts in smoothscale.
Diffstat (limited to 'draw')
-rw-r--r--draw/imagesmooth.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/draw/imagesmooth.c b/draw/imagesmooth.c
index ed42b0d4..2c023b2a 100644
--- a/draw/imagesmooth.c
+++ b/draw/imagesmooth.c
@@ -131,7 +131,7 @@ mitchell(fz_scalefilter *filter, float x)
if (x >= 2)
return 0;
if (x >= 1)
- return (32 + x*(60 + x*(36 - 7*x)))/18;
+ return (32 + x*(-60 + x*(36 - 7*x)))/18;
return (16 + x*x*(-36 + 21*x))/18;
}
@@ -271,13 +271,14 @@ add_weight(fz_weights *weights, int j, int i, fz_scalefilter *filter,
{
float dist = j + 0.5f - (x + (i + 0.5f)*dst_w/src_w);
float f;
- int min, len, index;
+ int min, len, index, weight;
dist *= G;
if (dist < 0)
dist = -dist;
f = filter->fn(filter, dist)*F;
- if (f == 0)
+ weight = (int)(256*f+0.5f);
+ if (weight == 0)
return;
/* wrap i back into range */
@@ -345,14 +346,14 @@ add_weight(fz_weights *weights, int j, int i, fz_scalefilter *filter,
weights->index[index+len-1] = 0;
}
assert(len-1 == i-min);
- weights->index[index+i-min] = (int)(256*f+0.5f);
+ weights->index[index+i-min] = weight;
weights->index[index-1] = len;
assert(len <= weights->max_len);
}
else
{
/* Infrequent case */
- weights->index[index+i-min] += (int)(256*f+0.5f);
+ weights->index[index+i-min] += weight;
}
}