Skip to content

Commit

Permalink
Merge pull request #7358 from radarhere/bc5u
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Sep 4, 2023
2 parents 2f9ef61 + 2b9217b commit 10d4595
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Binary file added Tests/images/bc5u.dds
Binary file not shown.
15 changes: 12 additions & 3 deletions Tests/test_file_dds.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
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"
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/DdsImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def _open(self):
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"
Expand Down

0 comments on commit 10d4595

Please sign in to comment.