diff options
author | Robin Watts <robin.watts@artifex.com> | 2012-07-17 13:28:01 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2012-07-17 15:25:20 +0100 |
commit | cbcd1dc873db397af0866f9fd54a70421dc6692f (patch) | |
tree | 318fe565585128e8343002f0ac6232f04f87474b | |
parent | 2f12f569672d84a1846905c41701fca52f8dc55e (diff) | |
download | ghostpdl-cbcd1dc873db397af0866f9fd54a70421dc6692f.tar.gz |
Tweak interpolation calculations
In preparation for the next commit, tweak the image interpolation
calculations; rather than doing a matrix multiplication and then
only using the X coords from it, change to doing both width and
height calculations in the same way.
This causes various (350ish) small changes in interpolation output
due to rounding issues.
-rw-r--r-- | gs/base/gxiscale.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/gs/base/gxiscale.c b/gs/base/gxiscale.c index 18c95db60..476a4e532 100644 --- a/gs/base/gxiscale.c +++ b/gs/base/gxiscale.c @@ -76,7 +76,6 @@ gs_image_class_0_interpolate(gx_image_enum * penum) const stream_template *templat; byte *line; const gs_color_space *pcs = penum->pcs; - gs_point dst_xy; uint in_size; bool use_icc = false; int num_des_comps; @@ -140,9 +139,6 @@ gs_image_class_0_interpolate(gx_image_enum * penum) return 0; } #endif - /* Non-ANSI compilers require the following casts: */ - gs_distance_transform((float)penum->rect.w, (float)penum->rect.h, - &penum->matrix, &dst_xy); if (use_icc) { iss.BitsPerComponentOut = 16; iss.MaxValueOut = 0xffff; @@ -150,10 +146,15 @@ gs_image_class_0_interpolate(gx_image_enum * penum) iss.BitsPerComponentOut = sizeof(frac) * 8; iss.MaxValueOut = frac_1; } - iss.WidthOut = (int)ceil(fabs(dst_xy.x)); + iss.WidthOut = fixed2int_pixround_perfect((fixed)((int64_t)(penum->rect.x + penum->rect.w) * + penum->dst_width / penum->Width)) + - fixed2int_pixround_perfect((fixed)((int64_t)penum->rect.x * + penum->dst_width / penum->Width)); + iss.WidthOut = any_abs(iss.WidthOut); iss.HeightOut = fixed2int_pixround_perfect((fixed)((int64_t)(penum->rect.y + penum->rect.h) * - penum->dst_height / penum->Height)) - - fixed2int_pixround_perfect((fixed)((int64_t)penum->rect.y * penum->dst_height / penum->Height)); + penum->dst_height / penum->Height)) + - fixed2int_pixround_perfect((fixed)((int64_t)penum->rect.y * + penum->dst_height / penum->Height)); iss.HeightOut = any_abs(iss.HeightOut); iss.WidthIn = penum->rect.w; iss.HeightIn = penum->rect.h; |