test for consistency

This commit is contained in:
homm 2016-05-03 13:22:51 +02:00
parent e13297b396
commit 9618ec98b8
2 changed files with 21 additions and 4 deletions

View File

@ -150,5 +150,22 @@ class TestImagingCoreResampleAccuracy(PillowTestCase):
self.make_sample(data, (12, 12)))
class CoreResampleConsistencyTest(PillowTestCase):
def test_8u(self):
im = Image.new('RGB', (512, 9), (0, 64, 255))
im = im.resize((9, 512), Image.LANCZOS)
r, g, b = im.split()
for channel, color in [(r, 0), (g, 64), (b, 255)]:
px = channel.load()
for x in range(channel.size[0]):
for y in range(channel.size[1]):
if px[x, y] != color:
message = "{} != {} for pixel {}".format(
px[x, y], color, (x, y))
self.assertEqual(px[x, y], color, message)
if __name__ == '__main__':
unittest.main()

View File

@ -178,7 +178,7 @@ ImagingResampleHorizontal(Imaging imIn, int xsize, struct filter *filterp)
xmin = xbounds[xx * 2 + 0];
xmax = xbounds[xx * 2 + 1];
k = &kk[xx * kmax];
ss0 = 0;
ss0 = 1 << (PRECISION_BITS -1);
for (x = xmin; x < xmax; x++)
ss0 += ((UINT8) imIn->image8[yy][x]) * k[x - xmin];
imOut->image8[yy][xx] = clip8(ss0);
@ -192,7 +192,7 @@ ImagingResampleHorizontal(Imaging imIn, int xsize, struct filter *filterp)
xmin = xbounds[xx * 2 + 0];
xmax = xbounds[xx * 2 + 1];
k = &kk[xx * kmax];
ss0 = ss1 = 0;
ss0 = ss1 = 1 << (PRECISION_BITS -1);
for (x = xmin; x < xmax; x++) {
ss0 += ((UINT8) imIn->image[yy][x*4 + 0]) * k[x - xmin];
ss1 += ((UINT8) imIn->image[yy][x*4 + 3]) * k[x - xmin];
@ -205,7 +205,7 @@ ImagingResampleHorizontal(Imaging imIn, int xsize, struct filter *filterp)
xmin = xbounds[xx * 2 + 0];
xmax = xbounds[xx * 2 + 1];
k = &kk[xx * kmax];
ss0 = ss1 = ss2 = 0;
ss0 = ss1 = ss2 = 1 << (PRECISION_BITS -1);
for (x = xmin; x < xmax; x++) {
ss0 += ((UINT8) imIn->image[yy][x*4 + 0]) * k[x - xmin];
ss1 += ((UINT8) imIn->image[yy][x*4 + 1]) * k[x - xmin];
@ -220,7 +220,7 @@ ImagingResampleHorizontal(Imaging imIn, int xsize, struct filter *filterp)
xmin = xbounds[xx * 2 + 0];
xmax = xbounds[xx * 2 + 1];
k = &kk[xx * kmax];
ss0 = ss1 = ss2 = ss3 = 0;
ss0 = ss1 = ss2 = ss3 = 1 << (PRECISION_BITS -1);
for (x = xmin; x < xmax; x++) {
ss0 += ((UINT8) imIn->image[yy][x*4 + 0]) * k[x - xmin];
ss1 += ((UINT8) imIn->image[yy][x*4 + 1]) * k[x - xmin];