mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 17:24:31 +03:00
Ensure that pixel data offset does not ignore palette
This commit is contained in:
parent
591e79e01e
commit
ff723e45ab
BIN
Tests/images/pal8_offset.bmp
Normal file
BIN
Tests/images/pal8_offset.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.0 KiB |
|
@ -123,3 +123,10 @@ def test_rgba_bitfields():
|
|||
im = Image.merge("RGB", (r, g, b))
|
||||
|
||||
assert_image_equal_tofile(im, "Tests/images/bmp/q/rgb32bf-xbgr.bmp")
|
||||
|
||||
|
||||
def test_offset():
|
||||
# This image has been hexedited
|
||||
# to exclude the palette size from the pixel data offset
|
||||
with Image.open("Tests/images/pal8_offset.bmp") as im:
|
||||
assert_image_equal_tofile(im, "Tests/images/bmp/g/pal8.bmp")
|
||||
|
|
|
@ -158,6 +158,8 @@ class BmpImageFile(ImageFile.ImageFile):
|
|||
if file_info.get("colors", 0)
|
||||
else (1 << file_info["bits"])
|
||||
)
|
||||
if offset == 14 + file_info["header_size"] and file_info["bits"] <= 8:
|
||||
offset += 4 * file_info["colors"]
|
||||
|
||||
# ---------------------- Check bit depth for unusual unsupported values
|
||||
self.mode, raw_mode = BIT2MODE.get(file_info["bits"], (None, None))
|
||||
|
|
Loading…
Reference in New Issue
Block a user