mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Added BC5_SNORM reading when FourCC is DX10
This commit is contained in:
parent
22fb2dbd29
commit
3b4db88202
Binary file not shown.
BIN
Tests/images/bc5s.dds
Normal file
BIN
Tests/images/bc5s.dds
Normal file
Binary file not shown.
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 82 KiB |
|
@ -13,6 +13,7 @@ TEST_FILE_DXT5 = "Tests/images/dxt5-argb-8bbp-interpolatedalpha_MipMaps-1.dds"
|
|||
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_BC5S = "Tests/images/bc5s.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"
|
||||
|
@ -62,10 +63,17 @@ def test_sanity_dxt5():
|
|||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"image_path",
|
||||
(TEST_FILE_DX10_BC5_TYPELESS, TEST_FILE_DX10_BC5_UNORM, TEST_FILE_DX10_BC5_SNORM),
|
||||
("image_path", "expected_path"),
|
||||
(
|
||||
# hexeditted to be typeless
|
||||
(TEST_FILE_DX10_BC5_TYPELESS, TEST_FILE_DX10_BC5_UNORM),
|
||||
(TEST_FILE_DX10_BC5_UNORM, TEST_FILE_DX10_BC5_UNORM),
|
||||
# hexeditted to use DX10 FourCC
|
||||
(TEST_FILE_DX10_BC5_SNORM, TEST_FILE_BC5S),
|
||||
(TEST_FILE_BC5S, TEST_FILE_BC5S),
|
||||
),
|
||||
)
|
||||
def test_dx10_bc5(image_path):
|
||||
def test_dx10_bc5(image_path, expected_path):
|
||||
"""Check DX10 BC5 images can be opened"""
|
||||
|
||||
with Image.open(image_path) as im:
|
||||
|
@ -75,9 +83,7 @@ def test_dx10_bc5(image_path):
|
|||
assert im.mode == "RGB"
|
||||
assert im.size == (256, 256)
|
||||
|
||||
assert_image_equal_tofile(
|
||||
im, image_path.replace("typeless", "unorm").replace(".dds", ".png")
|
||||
)
|
||||
assert_image_equal_tofile(im, expected_path.replace(".dds", ".png"))
|
||||
|
||||
|
||||
def test_dx10_bc7():
|
||||
|
|
|
@ -99,6 +99,7 @@ DXGI_FORMAT_R8G8B8A8_UNORM = 28
|
|||
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29
|
||||
DXGI_FORMAT_BC5_TYPELESS = 82
|
||||
DXGI_FORMAT_BC5_UNORM = 83
|
||||
DXGI_FORMAT_BC5_SNORM = 84
|
||||
DXGI_FORMAT_BC7_TYPELESS = 97
|
||||
DXGI_FORMAT_BC7_UNORM = 98
|
||||
DXGI_FORMAT_BC7_UNORM_SRGB = 99
|
||||
|
@ -165,6 +166,10 @@ class DdsImageFile(ImageFile.ImageFile):
|
|||
self.pixel_format = "BC5"
|
||||
n = 5
|
||||
self.mode = "RGB"
|
||||
elif dxgi_format == DXGI_FORMAT_BC5_SNORM:
|
||||
self.pixel_format = "BC5S"
|
||||
n = 5
|
||||
self.mode = "RGB"
|
||||
elif dxgi_format in (DXGI_FORMAT_BC7_TYPELESS, DXGI_FORMAT_BC7_UNORM):
|
||||
self.pixel_format = "BC7"
|
||||
n = 7
|
||||
|
|
Loading…
Reference in New Issue
Block a user