Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added BC5U reading #7358

Merged
merged 1 commit into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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