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 6
6
import pytest
7
7
8
8
from PIL import BmpImagePlugin , Image , _binary
9
+ from PIL ._binary import o16le as o16
10
+ from PIL ._binary import o32le as o32
9
11
10
12
from .helper import (
11
13
assert_image_equal ,
@@ -114,7 +116,7 @@ def test_save_float_dpi(tmp_path: Path) -> None:
114
116
115
117
116
118
def test_load_dib () -> None :
117
- # test for #1293, Imagegrab returning Unsupported Bitfields Format
119
+ # test for #1293, ImageGrab returning Unsupported Bitfields Format
118
120
with Image .open ("Tests/images/clipboard.dib" ) as im :
119
121
assert im .format == "DIB"
120
122
assert im .get_format_mimetype () == "image/bmp"
@@ -219,6 +221,18 @@ def test_rle8_eof(file_name: str, length: int) -> None:
219
221
im .load ()
220
222
221
223
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
+
222
236
def test_offset () -> None :
223
237
# This image has been hexedited
224
238
# to exclude the palette size from the pixel data offset
You can’t perform that action at this time.
0 commit comments