Skip to content

Commit

Permalink
Merge pull request #1881 from uploadcare/fpi-resample
Browse files Browse the repository at this point in the history
Fixed point integer resample
  • Loading branch information
wiredfool committed May 26, 2016
2 parents 73c8140 + 5ffd9e5 commit 0cfcc9e
Show file tree
Hide file tree
Showing 2 changed files with 263 additions and 169 deletions.
36 changes: 36 additions & 0 deletions Tests/test_image_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,41 @@ def test_enlarge_lanczos(self):
self.make_sample(data, (12, 12)))


class CoreResampleConsistencyTest(PillowTestCase):
def make_case(self, mode, fill):
im = Image.new(mode, (512, 9), fill)
return (im.resize((9, 512), Image.LANCZOS), im.load()[0, 0])

def run_case(self, case):
channel, color = case
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)

def test_8u(self):
im, color = self.make_case('RGB', (0, 64, 255))
r, g, b = im.split()
self.run_case((r, color[0]))
self.run_case((g, color[1]))
self.run_case((b, color[2]))
self.run_case(self.make_case('L', 12))

def test_32i(self):
self.run_case(self.make_case('I', 12))
self.run_case(self.make_case('I', 0x7fffffff))
self.run_case(self.make_case('I', -12))
self.run_case(self.make_case('I', -1 << 31))

def test_32f(self):
self.run_case(self.make_case('F', 1))
self.run_case(self.make_case('F', 3.40282306074e+38))
self.run_case(self.make_case('F', 1.175494e-38))
self.run_case(self.make_case('F', 1.192093e-07))


if __name__ == '__main__':
unittest.main()

0 comments on commit 0cfcc9e

Please sign in to comment.