[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): with pytest.raises(ValueError):
im.load() im.load()
def test_rle4(): def test_rle4():
with Image.open("Tests/images/hopper_rle4.bmp") as im: with Image.open("Tests/images/hopper_rle4.bmp") as im:
assert_image_similar_tofile(im, "Tests/images/hopper_4bit.bmp", 12) 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 # Too much data for row
num_pixels = max(0, self.state.xsize - x) num_pixels = max(0, self.state.xsize - x)
first_pixel = o8(byte[0] >> 4) first_pixel = o8(byte[0] >> 4)
second_pixel = o8(byte[0] & 0x0f) second_pixel = o8(byte[0] & 0x0F)
for index in range(num_pixels): for index in range(num_pixels):
if index % 2 == 0: if index % 2 == 0:
data += first_pixel data += first_pixel
@ -379,7 +379,7 @@ class BmpRle4Decoder(ImageFile.PyDecoder):
for byte_read in bytes_read: for byte_read in bytes_read:
first_pixel = o8(byte_read >> 4) first_pixel = o8(byte_read >> 4)
data += first_pixel data += first_pixel
second_pixel = o8(byte_read & 0x0f) second_pixel = o8(byte_read & 0x0F)
data += second_pixel data += second_pixel
if len(bytes_read) < total_bytes_to_read: if len(bytes_read) < total_bytes_to_read:
break break
@ -392,6 +392,7 @@ class BmpRle4Decoder(ImageFile.PyDecoder):
self.set_as_raw(bytes(data), (rawmode, 0, self.args[-1])) self.set_as_raw(bytes(data), (rawmode, 0, self.args[-1]))
return -1, 0 return -1, 0
# ============================================================================= # =============================================================================
# Image plugin for the DIB format (BMP alias) # Image plugin for the DIB format (BMP alias)
# ============================================================================= # =============================================================================