Skip to content

Commit

Permalink
Merge pull request #4 from radarhere/bc6h
Browse files Browse the repository at this point in the history
Rename format to BC6H and BC6HS
  • Loading branch information
ShadelessFox committed Jul 23, 2022
2 parents 4b97f88 + 806f43f commit c5155fd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
18 changes: 6 additions & 12 deletions Tests/test_file_dds.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
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_BC6 = "Tests/images/bc6h.dds"
TEST_FILE_BC6S = "Tests/images/bc6h_sf.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"
TEST_FILE_DX10_BC7_UNORM_SRGB = "Tests/images/DXGI_FORMAT_BC7_UNORM_SRGB.dds"
TEST_FILE_DX10_R8G8B8A8 = "Tests/images/argb-32bpp_MipMaps-1.dds"
Expand Down Expand Up @@ -88,15 +88,9 @@ def test_dx10_bc5(image_path, expected_path):
assert_image_equal_tofile(im, expected_path.replace(".dds", ".png"))


@pytest.mark.parametrize(
("image_path", "expected_path"),
(
(TEST_FILE_BC6, TEST_FILE_BC6),
(TEST_FILE_BC6S, TEST_FILE_BC6S),
),
)
def test_dx10_bc6(image_path, expected_path):
"""Check DX10 BC6/BC6S images can be opened"""
@pytest.mark.parametrize("image_path", (TEST_FILE_BC6H, TEST_FILE_BC6HS))
def test_dx10_bc6h(image_path):
"""Check DX10 BC6H/BC6HS images can be opened"""

with Image.open(image_path) as im:
im.load()
Expand All @@ -105,7 +99,7 @@ def test_dx10_bc6(image_path, expected_path):
assert im.mode == "RGB"
assert im.size == (256, 256)

assert_image_equal_tofile(im, expected_path.replace(".dds", ".png"))
assert_image_equal_tofile(im, image_path.replace(".dds", ".png"))


def test_dx10_bc7():
Expand Down
4 changes: 2 additions & 2 deletions src/PIL/DdsImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,11 @@ def _open(self):
n = 5
self.mode = "RGB"
elif dxgi_format == DXGI_FORMAT_BC6H_UF16:
self.pixel_format = "BC6"
self.pixel_format = "BC6H"
n = 6
self.mode = "RGB"
elif dxgi_format == DXGI_FORMAT_BC6H_SF16:
self.pixel_format = "BC6S"
self.pixel_format = "BC6HS"
n = 6
self.mode = "RGB"
elif dxgi_format in (DXGI_FORMAT_BC7_TYPELESS, DXGI_FORMAT_BC7_UNORM):
Expand Down

0 comments on commit c5155fd

Please sign in to comment.