Use previous pixel alpha for QOI_OP_RGB

This commit is contained in:
Andrew Murray 2023-08-31 09:27:33 +10:00
parent 24606216e1
commit 7bf7ff8217
2 changed files with 3 additions and 3 deletions

View File

@ -2,7 +2,7 @@ import pytest
from PIL import Image, QoiImagePlugin
from .helper import assert_image_equal_tofile, assert_image_similar_tofile
from .helper import assert_image_equal_tofile
def test_sanity():
@ -18,7 +18,7 @@ def test_sanity():
assert im.size == (162, 150)
assert im.format == "QOI"
assert_image_similar_tofile(im, "Tests/images/pil123rgba.png", 0.03)
assert_image_equal_tofile(im, "Tests/images/pil123rgba.png")
def test_invalid_file():

View File

@ -55,7 +55,7 @@ class QoiDecoder(ImageFile.PyDecoder):
while len(data) < self.state.xsize * self.state.ysize * bands:
byte = self.fd.read(1)[0]
if byte == 0b11111110: # QOI_OP_RGB
value = self.fd.read(3) + o8(255)
value = self.fd.read(3) + self._previous_pixel[3:]
elif byte == 0b11111111: # QOI_OP_RGBA
value = self.fd.read(4)
else: