mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Added reading 8-bit color images
This commit is contained in:
parent
b723e9e62e
commit
cd4adb1677
BIN
Tests/images/palette.dds
Normal file
BIN
Tests/images/palette.dds
Normal file
Binary file not shown.
|
@ -298,6 +298,11 @@ def test_dxt5_colorblock_alpha_issue_4142():
|
|||
assert px[2] != 0
|
||||
|
||||
|
||||
def test_palette():
|
||||
with Image.open("Tests/images/palette.dds") as im:
|
||||
assert_image_equal_tofile(im, "Tests/images/transparent.gif")
|
||||
|
||||
|
||||
def test_unimplemented_pixel_format():
|
||||
with pytest.raises(NotImplementedError):
|
||||
with Image.open("Tests/images/unimplemented_pixel_format.dds"):
|
||||
|
|
|
@ -13,7 +13,7 @@ Full text of the CC0 license:
|
|||
import struct
|
||||
from io import BytesIO
|
||||
|
||||
from . import Image, ImageFile
|
||||
from . import Image, ImageFile, ImagePalette
|
||||
from ._binary import o32le as o32
|
||||
|
||||
# Magic ("DDS ")
|
||||
|
@ -157,6 +157,10 @@ class DdsImageFile(ImageFile.ImageFile):
|
|||
rawmode += masks[0xFF0000] + masks[0xFF00] + masks[0xFF]
|
||||
|
||||
self.tile = [("raw", (0, 0) + self.size, 0, (rawmode[::-1], 0, 1))]
|
||||
elif pfflags & DDPF_PALETTEINDEXED8:
|
||||
self._mode = "P"
|
||||
self.palette = ImagePalette.raw("RGBA", self.fp.read(1024))
|
||||
self.tile = [("raw", (0, 0) + self.size, 0, "L")]
|
||||
else:
|
||||
data_start = header_size + 4
|
||||
n = 0
|
||||
|
|
Loading…
Reference in New Issue
Block a user