From 2afdc3776d07718eb42f0b59f11b22578235cec2 Mon Sep 17 00:00:00 2001 From: wiredfool Date: Mon, 30 Sep 2013 22:01:23 -0700 Subject: [PATCH] quad test, with blank space test --- Tests/test_image_transform.py | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/Tests/test_image_transform.py b/Tests/test_image_transform.py index 0de86dc16..79cb11d5b 100644 --- a/Tests/test_image_transform.py +++ b/Tests/test_image_transform.py @@ -26,4 +26,33 @@ def test_quad(): scaled = im.resize((w*2, h*2), Image.BILINEAR).crop((0,0,w,h)) - assert_image_equal(transformed, scaled, 10) + assert_image_equal(transformed, scaled) + +def test_mesh(): + # this should be a checkerboard of halfsized lenas in ul, lr + im = lena('RGBA') + (w,h) = im.size + transformed = im.transform(im.size, Image.MESH, + [((0,0,w/2,h/2), # box + (0,0,0,h, + w,h,w,0)), # ul -> ccw around quad + ((w/2,h/2,w,h), # box + (0,0,0,h, + w,h,w,0))], # ul -> ccw around quad + Image.BILINEAR) + + scaled = im.resize((w/2, h/2), Image.BILINEAR) + + checker = Image.new('RGBA', im.size) + checker.paste(scaled, (0,0)) + checker.paste(scaled, (w/2,h/2)) + + assert_image_equal(transformed, checker) + + # now, check to see that the extra area is (0,0,0,0) + blank = Image.new('RGBA', (w/2,h/2), (0,0,0,0)) + + assert_image_equal(blank, transformed.crop((w/2,0,w,h/2))) + assert_image_equal(blank, transformed.crop((0,h/2,w/2,h))) + +