Merge pull request #7358 from radarhere/bc5u

This commit is contained in:
Hugo van Kemenade 2023-09-04 09:54:52 -06:00 committed by GitHub
commit 10d45950ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 4 deletions

BIN
Tests/images/bc5u.dds Normal file

Binary file not shown.

View File

@ -16,6 +16,7 @@ TEST_FILE_DX10_BC5_TYPELESS = "Tests/images/bc5_typeless.dds"
TEST_FILE_DX10_BC5_UNORM = "Tests/images/bc5_unorm.dds"
TEST_FILE_DX10_BC5_SNORM = "Tests/images/bc5_snorm.dds"
TEST_FILE_BC5S = "Tests/images/bc5s.dds"
TEST_FILE_BC5U = "Tests/images/bc5u.dds"
TEST_FILE_BC6H = "Tests/images/bc6h.dds"
TEST_FILE_BC6HS = "Tests/images/bc6h_sf.dds"
TEST_FILE_DX10_BC7 = "Tests/images/bc7-argb-8bpp_MipMaps-1.dds"
@ -81,10 +82,18 @@ def test_sanity_ati1():
assert_image_equal_tofile(im, TEST_FILE_ATI1.replace(".dds", ".png"))
def test_sanity_ati2():
"""Check ATI2 images can be opened"""
@pytest.mark.parametrize(
"image_path",
(
TEST_FILE_ATI2,
# hexeditted to use BC5U FourCC
TEST_FILE_BC5U,
),
)
def test_sanity_ati2_bc5u(image_path):
"""Check ATI2 and BC5U images can be opened"""
with Image.open(TEST_FILE_ATI2) as im:
with Image.open(image_path) as im:
im.load()
assert im.format == "DDS"

View File

@ -173,7 +173,7 @@ class DdsImageFile(ImageFile.ImageFile):
self.pixel_format = "BC4"
n = 4
self._mode = "L"
elif fourcc == b"ATI2":
elif fourcc in (b"ATI2", b"BC5U"):
self.pixel_format = "BC5"
n = 5
self._mode = "RGB"