mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-16 18:24:45 +03:00
added tests for dxt3 compression format
This commit is contained in:
parent
8f8061b774
commit
e006dcc61e
|
@ -188,7 +188,7 @@ def _dxt3(data, width, height):
|
||||||
|
|
||||||
for j in range(4):
|
for j in range(4):
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
alpha = ((ai >> 4 * (4 * j + i)) & 15) * 16
|
alpha = ((ai >> 4 * (4 * j + i)) & 15) * 17 # map alpha to range 0-255
|
||||||
|
|
||||||
cc = (code >> 2 * (4 * j + i)) & 3
|
cc = (code >> 2 * (4 * j + i)) & 3
|
||||||
if cc == 0:
|
if cc == 0:
|
||||||
|
|
BIN
Tests/images/dxt3-argb-8bbp-explicitalpha_MipMaps-1.png
Normal file
BIN
Tests/images/dxt3-argb-8bbp-explicitalpha_MipMaps-1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
|
@ -46,9 +46,24 @@ class TestFileDds(PillowTestCase):
|
||||||
self.assert_image_similar(target, im, 5)
|
self.assert_image_similar(target, im, 5)
|
||||||
|
|
||||||
def test_sanity_dxt3(self):
|
def test_sanity_dxt3(self):
|
||||||
"""Check DXT3 images are not supported"""
|
"""Check DXT3 images can be opened"""
|
||||||
self.assertRaises(NotImplementedError,
|
|
||||||
lambda: Image.open(TEST_FILE_DXT3))
|
target = Image.open(TEST_FILE_DXT3.replace('.dds', '.png'))
|
||||||
|
|
||||||
|
im = Image.open(TEST_FILE_DXT3)
|
||||||
|
im.load()
|
||||||
|
|
||||||
|
self.assertEqual(im.format, "DDS")
|
||||||
|
self.assertEqual(im.mode, "RGBA")
|
||||||
|
self.assertEqual(im.size, (256, 256))
|
||||||
|
|
||||||
|
# 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__validate_true(self):
|
def test__validate_true(self):
|
||||||
"""Check valid prefix"""
|
"""Check valid prefix"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user