mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-04-27 20:43:43 +03:00
Removed INVALID enum
This commit is contained in:
parent
cadac4aad2
commit
bd4826591b
BIN
Tests/images/unimplemented_fourcc.dds
Executable file
BIN
Tests/images/unimplemented_fourcc.dds
Executable file
Binary file not shown.
BIN
Tests/images/unimplemented_pfflags.dds
Executable file
BIN
Tests/images/unimplemented_pfflags.dds
Executable file
Binary file not shown.
|
@ -289,9 +289,18 @@ def test_dxt5_colorblock_alpha_issue_4142():
|
||||||
assert px[2] != 0
|
assert px[2] != 0
|
||||||
|
|
||||||
|
|
||||||
def test_unimplemented_pixel_format():
|
@pytest.mark.parametrize(
|
||||||
|
"test_file",
|
||||||
|
(
|
||||||
|
"Tests/images/unknown_fourcc.dds",
|
||||||
|
"Tests/images/unimplemented_fourcc.dds",
|
||||||
|
"Tests/images/unimplemented_dxgi_format.dds",
|
||||||
|
"Tests/images/unimplemented_pfflags.dds",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
def test_not_implemented(test_file):
|
||||||
with pytest.raises(NotImplementedError):
|
with pytest.raises(NotImplementedError):
|
||||||
with Image.open("Tests/images/unimplemented_pixel_format.dds"):
|
with Image.open(test_file):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -184,11 +184,6 @@ class DXGI_FORMAT(IntEnum):
|
||||||
V408 = 132
|
V408 = 132
|
||||||
SAMPLER_FEEDBACK_MIN_MIP_OPAQUE = 133
|
SAMPLER_FEEDBACK_MIN_MIP_OPAQUE = 133
|
||||||
SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE = 134
|
SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE = 134
|
||||||
INVALID = -1
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def _missing_(cls, value: object):
|
|
||||||
return cls.INVALID
|
|
||||||
|
|
||||||
|
|
||||||
class D3DFMT(IntEnum):
|
class D3DFMT(IntEnum):
|
||||||
|
@ -262,11 +257,6 @@ class D3DFMT(IntEnum):
|
||||||
ATI1 = i32(b"ATI1")
|
ATI1 = i32(b"ATI1")
|
||||||
ATI2 = i32(b"ATI2")
|
ATI2 = i32(b"ATI2")
|
||||||
MULTI2_ARGB8 = i32(b"MET1")
|
MULTI2_ARGB8 = i32(b"MET1")
|
||||||
INVALID = -1
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def _missing_(cls, value: object):
|
|
||||||
return cls.INVALID
|
|
||||||
|
|
||||||
|
|
||||||
class DdsImageFile(ImageFile.ImageFile):
|
class DdsImageFile(ImageFile.ImageFile):
|
||||||
|
@ -297,7 +287,6 @@ class DdsImageFile(ImageFile.ImageFile):
|
||||||
# pixel format
|
# pixel format
|
||||||
pfsize, pfflags_, fourcc_, bitcount = struct.unpack("<4I", header.read(16))
|
pfsize, pfflags_, fourcc_, bitcount = struct.unpack("<4I", header.read(16))
|
||||||
pfflags = DDPF(pfflags_)
|
pfflags = DDPF(pfflags_)
|
||||||
fourcc = D3DFMT(fourcc_)
|
|
||||||
masks = struct.unpack("<4I", header.read(16))
|
masks = struct.unpack("<4I", header.read(16))
|
||||||
if flags & DDSD.CAPS:
|
if flags & DDSD.CAPS:
|
||||||
header.seek(20, io.SEEK_CUR)
|
header.seek(20, io.SEEK_CUR)
|
||||||
|
@ -333,6 +322,10 @@ class DdsImageFile(ImageFile.ImageFile):
|
||||||
raise OSError(msg)
|
raise OSError(msg)
|
||||||
elif pfflags & DDPF.FOURCC:
|
elif pfflags & DDPF.FOURCC:
|
||||||
data_offs = header_size + 4
|
data_offs = header_size + 4
|
||||||
|
try:
|
||||||
|
fourcc = D3DFMT(fourcc_)
|
||||||
|
except ValueError:
|
||||||
|
raise NotImplementedError(f"Unimplemented pixel format {repr(fourcc_)}")
|
||||||
if fourcc == D3DFMT.DXT1:
|
if fourcc == D3DFMT.DXT1:
|
||||||
self.mode = "RGBA"
|
self.mode = "RGBA"
|
||||||
self.pixel_format = "DXT1"
|
self.pixel_format = "DXT1"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user