Merge pull request #4 from radarhere/bc6h

Rename format to BC6H and BC6HS
This commit is contained in:
ShadelessFox 2022-07-23 05:19:24 -07:00 committed by GitHub
commit c5155fdcef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 14 deletions

View File

@ -14,8 +14,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_UNORM = "Tests/images/bc5_unorm.dds"
TEST_FILE_DX10_BC5_SNORM = "Tests/images/bc5_snorm.dds" TEST_FILE_DX10_BC5_SNORM = "Tests/images/bc5_snorm.dds"
TEST_FILE_BC5S = "Tests/images/bc5s.dds" TEST_FILE_BC5S = "Tests/images/bc5s.dds"
TEST_FILE_BC6 = "Tests/images/bc6h.dds" TEST_FILE_BC6H = "Tests/images/bc6h.dds"
TEST_FILE_BC6S = "Tests/images/bc6h_sf.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 = "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_BC7_UNORM_SRGB = "Tests/images/DXGI_FORMAT_BC7_UNORM_SRGB.dds"
TEST_FILE_DX10_R8G8B8A8 = "Tests/images/argb-32bpp_MipMaps-1.dds" TEST_FILE_DX10_R8G8B8A8 = "Tests/images/argb-32bpp_MipMaps-1.dds"
@ -88,15 +88,9 @@ def test_dx10_bc5(image_path, expected_path):
assert_image_equal_tofile(im, expected_path.replace(".dds", ".png")) assert_image_equal_tofile(im, expected_path.replace(".dds", ".png"))
@pytest.mark.parametrize( @pytest.mark.parametrize("image_path", (TEST_FILE_BC6H, TEST_FILE_BC6HS))
("image_path", "expected_path"), def test_dx10_bc6h(image_path):
( """Check DX10 BC6H/BC6HS images can be opened"""
(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"""
with Image.open(image_path) as im: with Image.open(image_path) as im:
im.load() im.load()
@ -105,7 +99,7 @@ def test_dx10_bc6(image_path, expected_path):
assert im.mode == "RGB" assert im.mode == "RGB"
assert im.size == (256, 256) 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(): def test_dx10_bc7():

View File

@ -176,11 +176,11 @@ class DdsImageFile(ImageFile.ImageFile):
n = 5 n = 5
self.mode = "RGB" self.mode = "RGB"
elif dxgi_format == DXGI_FORMAT_BC6H_UF16: elif dxgi_format == DXGI_FORMAT_BC6H_UF16:
self.pixel_format = "BC6" self.pixel_format = "BC6H"
n = 6 n = 6
self.mode = "RGB" self.mode = "RGB"
elif dxgi_format == DXGI_FORMAT_BC6H_SF16: elif dxgi_format == DXGI_FORMAT_BC6H_SF16:
self.pixel_format = "BC6S" self.pixel_format = "BC6HS"
n = 6 n = 6
self.mode = "RGB" self.mode = "RGB"
elif dxgi_format in (DXGI_FORMAT_BC7_TYPELESS, DXGI_FORMAT_BC7_UNORM): elif dxgi_format in (DXGI_FORMAT_BC7_TYPELESS, DXGI_FORMAT_BC7_UNORM):