mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-13 10:00:50 +03:00
Fixed reading uncompressed BLP2 with alpha
This commit is contained in:
parent
169025df6c
commit
3ec928251c
|
@ -2,7 +2,12 @@ import pytest
|
|||
|
||||
from PIL import BlpImagePlugin, Image
|
||||
|
||||
from .helper import assert_image_equal, assert_image_equal_tofile, hopper
|
||||
from .helper import (
|
||||
assert_image_equal,
|
||||
assert_image_equal_tofile,
|
||||
assert_image_similar,
|
||||
hopper,
|
||||
)
|
||||
|
||||
|
||||
def test_load_blp1():
|
||||
|
@ -33,6 +38,13 @@ def test_save(tmp_path):
|
|||
with Image.open(f) as reloaded:
|
||||
assert_image_equal(im.convert("RGB"), reloaded)
|
||||
|
||||
with Image.open("Tests/images/transparent.png") as im:
|
||||
f = str(tmp_path / "temp.blp")
|
||||
im.convert("P").save(f)
|
||||
|
||||
with Image.open(f) as reloaded:
|
||||
assert_image_similar(im, reloaded, 8)
|
||||
|
||||
im = hopper()
|
||||
with pytest.raises(ValueError):
|
||||
im.save(f)
|
||||
|
|
|
@ -406,7 +406,10 @@ class BLP2Decoder(_BLPBaseDecoder):
|
|||
except struct.error:
|
||||
break
|
||||
b, g, r, a = palette[offset]
|
||||
data.extend((r, g, b))
|
||||
d = (r, g, b)
|
||||
if self._blp_alpha_depth:
|
||||
d += (a,)
|
||||
data.extend(d)
|
||||
|
||||
elif self._blp_encoding == Encoding.DXT:
|
||||
if self._blp_alpha_encoding == AlphaEncoding.DXT1:
|
||||
|
|
Loading…
Reference in New Issue
Block a user