[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2022-10-21 23:41:26 +00:00
parent 455ffff735
commit f2dfd0bfb3
2 changed files with 5 additions and 3 deletions

View File

@ -175,6 +175,7 @@ def test_rle8():
with pytest.raises(ValueError):
im.load()
def test_rle4():
with Image.open("Tests/images/hopper_rle4.bmp") as im:
assert_image_similar_tofile(im, "Tests/images/hopper_4bit.bmp", 12)

View File

@ -348,7 +348,7 @@ class BmpRle4Decoder(ImageFile.PyDecoder):
# Too much data for row
num_pixels = max(0, self.state.xsize - x)
first_pixel = o8(byte[0] >> 4)
second_pixel = o8(byte[0] & 0x0f)
second_pixel = o8(byte[0] & 0x0F)
for index in range(num_pixels):
if index % 2 == 0:
data += first_pixel
@ -379,11 +379,11 @@ class BmpRle4Decoder(ImageFile.PyDecoder):
for byte_read in bytes_read:
first_pixel = o8(byte_read >> 4)
data += first_pixel
second_pixel = o8(byte_read & 0x0f)
second_pixel = o8(byte_read & 0x0F)
data += second_pixel
if len(bytes_read) < total_bytes_to_read:
break
x += byte[0]
x += byte[0]
# align to 16-bit word boundary
if self.fd.tell() % 2 != 0:
@ -392,6 +392,7 @@ class BmpRle4Decoder(ImageFile.PyDecoder):
self.set_as_raw(bytes(data), (rawmode, 0, self.args[-1]))
return -1, 0
# =============================================================================
# Image plugin for the DIB format (BMP alias)
# =============================================================================