mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 10:46:16 +03:00
fixing dds plugin on Py 2.x, relaxing dxt5 test
This commit is contained in:
parent
13f2d22700
commit
18d48dc665
|
@ -145,7 +145,7 @@ def _dxt1(data, width, height):
|
|||
r, g, b = 0, 0, 0
|
||||
|
||||
idx = 4 * ((y + j) * width + (x + i))
|
||||
ret[idx:idx+4] = bytes([r, g, b, 0xff])
|
||||
ret[idx:idx+4] = struct.pack('4B', r, g, b, 255)
|
||||
|
||||
return bytes(ret)
|
||||
|
||||
|
@ -202,7 +202,7 @@ def _dxt5(data, width, height):
|
|||
r, g, b = _c3(r0, r1), _c3(g0, g1), _c3(b0, b1)
|
||||
|
||||
idx = 4 * ((y + j) * width + (x + i))
|
||||
ret[idx:idx+4] = bytes([r, g, b, alpha])
|
||||
ret[idx:idx+4] = struct.pack('4B', r, g, b, alpha)
|
||||
|
||||
return bytes(ret)
|
||||
|
||||
|
|
|
@ -12,26 +12,37 @@ class TestFileDds(PillowTestCase):
|
|||
|
||||
def test_sanity_dxt1(self):
|
||||
"""Check DXT1 images can be opened"""
|
||||
im = Image.open(TEST_FILE_DXT1)
|
||||
target = Image.open(TEST_FILE_DXT1.replace('.dds', '.png'))
|
||||
|
||||
im = Image.open(TEST_FILE_DXT1)
|
||||
im.load()
|
||||
|
||||
self.assertEqual(im.format, "DDS")
|
||||
self.assertEqual(im.mode, "RGBA")
|
||||
self.assertEqual(im.size, (256, 256))
|
||||
|
||||
target = Image.open(TEST_FILE_DXT1.replace('.dds', '.png'))
|
||||
target.show()
|
||||
|
||||
# This target image is from the test set of images, and is exact.
|
||||
self.assert_image_equal(target.convert('RGBA'), im)
|
||||
|
||||
def test_sanity_dxt5(self):
|
||||
"""Check DXT5 images can be opened"""
|
||||
|
||||
target = Image.open(TEST_FILE_DXT5.replace('.dds', '.png'))
|
||||
|
||||
im = Image.open(TEST_FILE_DXT5)
|
||||
im.load()
|
||||
|
||||
self.assertEqual(im.format, "DDS")
|
||||
self.assertEqual(im.mode, "RGBA")
|
||||
self.assertEqual(im.size, (256, 256))
|
||||
|
||||
target = Image.open(TEST_FILE_DXT5.replace('.dds', '.png'))
|
||||
self.assert_image_equal(target, im)
|
||||
|
||||
# Imagemagick, which generated this target image from the .dds
|
||||
# has a slightly different decoder than is standard. It looks
|
||||
# a little brighter. The 0,0 pixel is (00,6c,f8,ff) by our code,
|
||||
# and by the target image for the DXT1, and the imagemagick .png
|
||||
# is giving (00, 6d, ff, ff). So, assert similar, pretty tight
|
||||
# I'm currently seeing about a 3 for the epsilon.
|
||||
self.assert_image_similar(target, im, 5)
|
||||
|
||||
|
||||
def test_sanity_dxt3(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user