From 44e443fa7588299c66569825d8896e68cd1f5a2f Mon Sep 17 00:00:00 2001 From: homm Date: Sat, 26 Nov 2016 01:38:55 +0300 Subject: [PATCH] fix int boundaries --- Tests/test_image_resample.py | 12 ++++++++++++ libImaging/Resample.c | 12 ++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Tests/test_image_resample.py b/Tests/test_image_resample.py index 680f0ba73..680633f2c 100644 --- a/Tests/test_image_resample.py +++ b/Tests/test_image_resample.py @@ -399,6 +399,18 @@ class CoreResampleRoiTest(PillowTestCase): self.assert_image_equal(tile1, tile2) + def test_subsample(self): + im = hopper() + reference = im.crop((0, 0, 125, 125)).resize((26, 26), Image.BICUBIC) + supersampled = im.resize((32, 32), Image.BOX) + without_roi = supersampled.resize((26, 26), Image.BICUBIC) + with_roi = supersampled.resize((26, 26), Image.BICUBIC, (0, 0, 31.25, 31.25)) + + self.assert_image_similar(reference, with_roi, 12) + + with self.assertRaisesRegexp(AssertionError, "difference 3\d\."): + self.assert_image_similar(reference, without_roi, 10) + if __name__ == '__main__': unittest.main() diff --git a/libImaging/Resample.c b/libImaging/Resample.c index fd29a1a93..a3c12c881 100644 --- a/libImaging/Resample.c +++ b/libImaging/Resample.c @@ -125,7 +125,7 @@ static inline UINT8 clip8(int in) int -precompute_coeffs(int inSize, int in0, int in1, int outSize, +precompute_coeffs(int inSize, float in0, float in1, int outSize, struct filter *filterp, int **xboundsp, double **kkp) { double support, scale, filterscale; double center, ww, ss; @@ -238,7 +238,7 @@ normalize_coeffs_8bpc(int outSize, int kmax, double *prekk, INT32 **kkp) Imaging -ImagingResampleHorizontal_8bpc(Imaging imIn, int x0, int x1, int xsize, +ImagingResampleHorizontal_8bpc(Imaging imIn, float x0, float x1, int xsize, struct filter *filterp) { ImagingSectionCookie cookie; @@ -345,7 +345,7 @@ ImagingResampleHorizontal_8bpc(Imaging imIn, int x0, int x1, int xsize, Imaging -ImagingResampleVertical_8bpc(Imaging imIn, int y0, int y1, int ysize, +ImagingResampleVertical_8bpc(Imaging imIn, float y0, float y1, int ysize, struct filter *filterp) { ImagingSectionCookie cookie; @@ -452,7 +452,7 @@ ImagingResampleVertical_8bpc(Imaging imIn, int y0, int y1, int ysize, Imaging -ImagingResampleHorizontal_32bpc(Imaging imIn, int x0, int x1, int xsize, +ImagingResampleHorizontal_32bpc(Imaging imIn, float x0, float x1, int xsize, struct filter *filterp) { ImagingSectionCookie cookie; @@ -514,7 +514,7 @@ ImagingResampleHorizontal_32bpc(Imaging imIn, int x0, int x1, int xsize, Imaging -ImagingResampleVertical_32bpc(Imaging imIn, int y0, int y1, int ysize, +ImagingResampleVertical_32bpc(Imaging imIn, float y0, float y1, int ysize, struct filter *filterp) { ImagingSectionCookie cookie; @@ -575,7 +575,7 @@ ImagingResampleVertical_32bpc(Imaging imIn, int y0, int y1, int ysize, } -typedef Imaging (*ResampleFunction)(Imaging imIn, int x0, int x1, int xsize, +typedef Imaging (*ResampleFunction)(Imaging imIn, float x0, float x1, int xsize, struct filter *filterp);