mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-05-02 23:13:40 +03:00
Support RGB bitcount 8
This commit is contained in:
parent
f58f410b21
commit
85485229e3
BIN
Tests/images/rgb8.dds
Normal file
BIN
Tests/images/rgb8.dds
Normal file
Binary file not shown.
|
@ -340,6 +340,12 @@ def test_open(mode, test_file):
|
||||||
assert_image_equal_tofile(im, test_file.replace(".dds", ".png"))
|
assert_image_equal_tofile(im, test_file.replace(".dds", ".png"))
|
||||||
|
|
||||||
|
|
||||||
|
def test_open_rgb8():
|
||||||
|
with Image.open("Tests/images/rgb8.dds") as im:
|
||||||
|
assert im.mode == "L"
|
||||||
|
assert_image_equal_tofile(im, "Tests/images/mode-l.png")
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("mode", "test_file"),
|
("mode", "test_file"),
|
||||||
[
|
[
|
||||||
|
|
|
@ -353,21 +353,22 @@ class DdsImageFile(ImageFile.ImageFile):
|
||||||
if pfflags & DDPF.RGB:
|
if pfflags & DDPF.RGB:
|
||||||
# Texture contains uncompressed RGB data
|
# Texture contains uncompressed RGB data
|
||||||
masks = {mask: ["R", "G", "B", "A"][i] for i, mask in enumerate(masks)}
|
masks = {mask: ["R", "G", "B", "A"][i] for i, mask in enumerate(masks)}
|
||||||
if bitcount == 24:
|
if bitcount == 8:
|
||||||
|
self._mode = "L"
|
||||||
|
elif bitcount == 24:
|
||||||
self._mode = "RGB"
|
self._mode = "RGB"
|
||||||
rawmode = masks[0x00FF0000] + masks[0x0000FF00] + masks[0x000000FF]
|
rawmode = masks[0x000000FF] + masks[0x0000FF00] + masks[0x00FF0000]
|
||||||
elif bitcount == 32 and pfflags & DDPF.ALPHAPIXELS:
|
elif bitcount == 32 and pfflags & DDPF.ALPHAPIXELS:
|
||||||
self._mode = "RGBA"
|
self._mode = "RGBA"
|
||||||
rawmode = (
|
rawmode = (
|
||||||
masks[0xFF000000]
|
masks[0x000000FF]
|
||||||
+ masks[0x00FF0000]
|
|
||||||
+ masks[0x0000FF00]
|
+ masks[0x0000FF00]
|
||||||
+ masks[0x000000FF]
|
+ masks[0x00FF0000]
|
||||||
|
+ masks[0xFF000000]
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
msg = f"Unsupported bitcount {bitcount} for {pfflags}"
|
msg = f"Unsupported bitcount {bitcount} for {pfflags}"
|
||||||
raise OSError(msg)
|
raise OSError(msg)
|
||||||
rawmode = rawmode[::-1]
|
|
||||||
elif pfflags & DDPF.LUMINANCE:
|
elif pfflags & DDPF.LUMINANCE:
|
||||||
if bitcount == 8:
|
if bitcount == 8:
|
||||||
self._mode = "L"
|
self._mode = "L"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user