From 75a0e9001c95d85bfba9ccf75461a5e9bb23f3ea Mon Sep 17 00:00:00 2001 From: Cedric Porter Date: Sat, 14 Jul 2012 20:50:34 +0800 Subject: [PATCH] antialias not work for local warping. --- EffectLab/Effect.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/EffectLab/Effect.py b/EffectLab/Effect.py index 36effb3..35d54f4 100755 --- a/EffectLab/Effect.py +++ b/EffectLab/Effect.py @@ -58,8 +58,27 @@ def filter(self, img): for y in range(height): if sqrt((x - cx) ** 2 + (y - cy) ** 2) > r: continue - u, v = self.warp(x, y, r, (cx, cy), (mx, my)) - new_img.putpixel((x, y), img.getpixel((u, v)) ) + + found = 0 + psum = (0, ) * nband + new_img.putpixel((x, y), (128, 128, 128, 255)) + + for ai in range(antialias): + for aj in range(antialias): + _x = x + ai + _y = y + aj + + u, v = self.warp(_x, _y, r, (cx, cy), (mx, my)) + u = int(round(u)) + v = int(round(v)) + pt = img.getpixel((u, v)) + psum = map(operator.add, psum, pt) + found += 1 + + if found > 0: + psum = map(operator.div, psum, (antialias * antialias, ) * len(psum)) + new_img.putpixel((x, y), tuple(psum)) + # new_img.putpixel((x, y), img.getpixel((u, v)) ) return new_img