mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-05-30 18:53:28 +03:00
Try test
This commit is contained in:
parent
d9c14e9ccd
commit
919f38e3d9
BIN
Tests/images/blp/blp1_jpeg.jpg
Normal file
BIN
Tests/images/blp/blp1_jpeg.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
BIN
Tests/images/blp/blp1_jpeg.png
Normal file
BIN
Tests/images/blp/blp1_jpeg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 270 B |
BIN
Tests/images/blp/war3mapMap.blp
Normal file
BIN
Tests/images/blp/war3mapMap.blp
Normal file
Binary file not shown.
BIN
Tests/images/blp/war3mapMap.jpg
Normal file
BIN
Tests/images/blp/war3mapMap.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
BIN
Tests/images/blp/war3mapMap.png
Normal file
BIN
Tests/images/blp/war3mapMap.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 270 B |
|
@ -20,6 +20,12 @@ def test_load_blp2_dxt1a():
|
||||||
assert_image_equal_tofile(im, "Tests/images/blp/blp2_dxt1a.png")
|
assert_image_equal_tofile(im, "Tests/images/blp/blp2_dxt1a.png")
|
||||||
|
|
||||||
|
|
||||||
|
def test_load_blp1():
|
||||||
|
with Image.open("Tests/images/blp/war3mapMap.blp") as im:
|
||||||
|
im.convert("RGB")
|
||||||
|
assert_image_equal_tofile(im, "Tests/images/blp/war3mapMap.png")
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"test_file",
|
"test_file",
|
||||||
[
|
[
|
||||||
|
|
|
@ -28,7 +28,7 @@ BLP files come in many different flavours:
|
||||||
- DXT3 compression is used if alpha_encoding == 1.
|
- DXT3 compression is used if alpha_encoding == 1.
|
||||||
- DXT5 compression is used if alpha_encoding == 7.
|
- DXT5 compression is used if alpha_encoding == 7.
|
||||||
"""
|
"""
|
||||||
|
print("foo")
|
||||||
import struct
|
import struct
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ class BlpImageFile(ImageFile.ImageFile):
|
||||||
|
|
||||||
if self.magic == b"BLP1":
|
if self.magic == b"BLP1":
|
||||||
decoder = "BLP1"
|
decoder = "BLP1"
|
||||||
self.mode = "RGBA"
|
self.mode = "BGRA"
|
||||||
elif self.magic == b"BLP2":
|
elif self.magic == b"BLP2":
|
||||||
decoder = "BLP2"
|
decoder = "BLP2"
|
||||||
self.mode = "RGBA" if self._blp_alpha_depth else "RGB"
|
self.mode = "RGBA" if self._blp_alpha_depth else "RGB"
|
||||||
|
@ -361,6 +361,16 @@ class BLP1Decoder(_BLPBaseDecoder):
|
||||||
image.tile = [("jpeg", (0, 0) + self.size, 0, ("RGBA", ""))]
|
image.tile = [("jpeg", (0, 0) + self.size, 0, ("RGBA", ""))]
|
||||||
|
|
||||||
b, g, r, a = image.split()
|
b, g, r, a = image.split()
|
||||||
|
print(b, g, r, a)
|
||||||
|
if not any(
|
||||||
|
[a.getpixel((x, y)) for x in range(a.width) for y in range(a.height)]
|
||||||
|
):
|
||||||
|
# try to unprotect completely transparent pictures
|
||||||
|
from PIL import ImageOps
|
||||||
|
|
||||||
|
a = ImageOps.invert(a)
|
||||||
|
|
||||||
|
|
||||||
image = Image.merge("RGBA", (r, g, b, a))
|
image = Image.merge("RGBA", (r, g, b, a))
|
||||||
self.set_as_raw(image.tobytes())
|
self.set_as_raw(image.tobytes())
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user