From f2dfd0bfb30b5741589fc124227b4052564ed7dd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 21 Oct 2022 23:41:26 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- Tests/test_file_bmp.py | 1 + src/PIL/BmpImagePlugin.py | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Tests/test_file_bmp.py b/Tests/test_file_bmp.py index ec852c905..e857f881c 100644 --- a/Tests/test_file_bmp.py +++ b/Tests/test_file_bmp.py @@ -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) diff --git a/src/PIL/BmpImagePlugin.py b/src/PIL/BmpImagePlugin.py index 107eb344d..d1517df27 100644 --- a/src/PIL/BmpImagePlugin.py +++ b/src/PIL/BmpImagePlugin.py @@ -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) # =============================================================================