mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Read BC5_TYPELESS as BC5_UNORM
This commit is contained in:
parent
1bb98974f8
commit
f59ff6d55b
BIN
Tests/images/bc5_typeless.dds
Normal file
BIN
Tests/images/bc5_typeless.dds
Normal file
Binary file not shown.
|
@ -10,6 +10,7 @@ from .helper import assert_image_equal, assert_image_equal_tofile
|
|||
TEST_FILE_DXT1 = "Tests/images/dxt1-rgb-4bbp-noalpha_MipMaps-1.dds"
|
||||
TEST_FILE_DXT3 = "Tests/images/dxt3-argb-8bbp-explicitalpha_MipMaps-1.dds"
|
||||
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_DX10_BC7 = "Tests/images/bc7-argb-8bpp_MipMaps-1.dds"
|
||||
|
@ -60,30 +61,23 @@ def test_sanity_dxt5():
|
|||
assert_image_equal_tofile(im, TEST_FILE_DXT5.replace(".dds", ".png"))
|
||||
|
||||
|
||||
def test_dx10_bc5_unorm():
|
||||
"""Check DX10 images can be opened"""
|
||||
@pytest.mark.parametrize(
|
||||
"image_path",
|
||||
(TEST_FILE_DX10_BC5_TYPELESS, TEST_FILE_DX10_BC5_UNORM, TEST_FILE_DX10_BC5_SNORM),
|
||||
)
|
||||
def test_dx10_bc5(image_path):
|
||||
"""Check DX10 BC5 images can be opened"""
|
||||
|
||||
with Image.open(TEST_FILE_DX10_BC5_UNORM) as im:
|
||||
with Image.open(image_path) as im:
|
||||
im.load()
|
||||
|
||||
assert im.format == "DDS"
|
||||
assert im.mode == "RGB"
|
||||
assert im.size == (256, 256)
|
||||
|
||||
assert_image_equal_tofile(im, TEST_FILE_DX10_BC5_UNORM.replace(".dds", ".png"))
|
||||
|
||||
|
||||
def test_dx10_bc5_snorm():
|
||||
"""Check DX10 images can be opened"""
|
||||
|
||||
with Image.open(TEST_FILE_DX10_BC5_SNORM) as im:
|
||||
im.load()
|
||||
|
||||
assert im.format == "DDS"
|
||||
assert im.mode == "RGB"
|
||||
assert im.size == (256, 256)
|
||||
|
||||
assert_image_equal_tofile(im, TEST_FILE_DX10_BC5_SNORM.replace(".dds", ".png"))
|
||||
assert_image_equal_tofile(
|
||||
im, image_path.replace("typeless", "unorm").replace(".dds", ".png")
|
||||
)
|
||||
|
||||
|
||||
def test_dx10_bc7():
|
||||
|
|
|
@ -97,6 +97,7 @@ DXT5_FOURCC = 0x35545844
|
|||
DXGI_FORMAT_R8G8B8A8_TYPELESS = 27
|
||||
DXGI_FORMAT_R8G8B8A8_UNORM = 28
|
||||
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29
|
||||
DXGI_FORMAT_BC5_TYPELESS = 82
|
||||
DXGI_FORMAT_BC5_UNORM = 83
|
||||
DXGI_FORMAT_BC7_TYPELESS = 97
|
||||
DXGI_FORMAT_BC7_UNORM = 98
|
||||
|
@ -160,7 +161,7 @@ class DdsImageFile(ImageFile.ImageFile):
|
|||
# ignoring flags which pertain to volume textures and cubemaps
|
||||
dxt10 = BytesIO(self.fp.read(20))
|
||||
dxgi_format, dimension = struct.unpack("<II", dxt10.read(8))
|
||||
if dxgi_format == DXGI_FORMAT_BC5_UNORM:
|
||||
if dxgi_format in (DXGI_FORMAT_BC5_TYPELESS, DXGI_FORMAT_BC5_UNORM):
|
||||
self.pixel_format = "BC5"
|
||||
n = 5
|
||||
self.mode = "RGB"
|
||||
|
|
Loading…
Reference in New Issue
Block a user