File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 66import pytest
77
88from PIL import BmpImagePlugin , Image , _binary
9+ from PIL ._binary import o16le as o16
10+ from PIL ._binary import o32le as o32
911
1012from .helper import (
1113 assert_image_equal ,
@@ -114,7 +116,7 @@ def test_save_float_dpi(tmp_path: Path) -> None:
114116
115117
116118def test_load_dib () -> None :
117- # test for #1293, Imagegrab returning Unsupported Bitfields Format
119+ # test for #1293, ImageGrab returning Unsupported Bitfields Format
118120 with Image .open ("Tests/images/clipboard.dib" ) as im :
119121 assert im .format == "DIB"
120122 assert im .get_format_mimetype () == "image/bmp"
@@ -219,6 +221,18 @@ def test_rle8_eof(file_name: str, length: int) -> None:
219221 im .load ()
220222
221223
224+ def test_unsupported_bmp_bitfields_layout () -> None :
225+ fp = io .BytesIO (
226+ o32 (40 ) # header size
227+ + b"\x00 " * 10
228+ + o16 (1 ) # bits
229+ + o32 (3 ) # BITFIELDS compression
230+ + b"\x00 " * 32
231+ )
232+ with pytest .raises (OSError , match = "Unsupported BMP bitfields layout" ):
233+ Image .open (fp )
234+
235+
222236def test_offset () -> None :
223237 # This image has been hexedited
224238 # to exclude the palette size from the pixel data offset
You can’t perform that action at this time.
0 commit comments