Skip to content

Commit

Permalink
Test BC1_UNORM and BC1_TYPELESS
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Oct 30, 2023
1 parent 17be898 commit e3ff5eb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
Binary file added Tests/images/bc1.dds
Binary file not shown.
Binary file added Tests/images/bc1_typeless.dds
Binary file not shown.
15 changes: 13 additions & 2 deletions Tests/test_file_dds.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
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_DX10_BC1 = "Tests/images/bc1.dds"
TEST_FILE_DX10_BC1_TYPELESS = "Tests/images/bc1_typeless.dds"
TEST_FILE_BC5S = "Tests/images/bc5s.dds"
TEST_FILE_BC5U = "Tests/images/bc5u.dds"
TEST_FILE_BC6H = "Tests/images/bc6h.dds"
Expand All @@ -29,11 +31,20 @@
TEST_FILE_UNCOMPRESSED_RGB_WITH_ALPHA = "Tests/images/uncompressed_rgb.dds"


def test_sanity_dxt1():
@pytest.mark.parametrize(
"image_path",
(
TEST_FILE_DXT1,
# hexeditted to use DX10 FourCC
TEST_FILE_DX10_BC1,
TEST_FILE_DX10_BC1_TYPELESS,
),
)
def test_sanity_bc1(image_path):
"""Check DXT1 images can be opened"""
with Image.open(TEST_FILE_DXT1.replace(".dds", ".png")) as target:
target = target.convert("RGBA")
with Image.open(TEST_FILE_DXT1) as im:
with Image.open(image_path) as im:
im.load()

assert im.format == "DDS"
Expand Down
1 change: 0 additions & 1 deletion src/PIL/DdsImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,6 @@ def _open(self):
self.fp.read(16)
if dxgi_format in (
DXGI_FORMAT.BC1_UNORM,
DXGI_FORMAT.BC1_UNORM_SRGB,
DXGI_FORMAT.BC1_TYPELESS,
):
self._mode = "RGBA"
Expand Down

0 comments on commit e3ff5eb

Please sign in to comment.