mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-03 05:04:24 +03:00
Test DIB header size
This commit is contained in:
parent
e2a57263c7
commit
94fe670c0b
|
@ -5,7 +5,7 @@ from pathlib import Path
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from PIL import BmpImagePlugin, Image
|
from PIL import BmpImagePlugin, Image, _binary
|
||||||
|
|
||||||
from .helper import (
|
from .helper import (
|
||||||
assert_image_equal,
|
assert_image_equal,
|
||||||
|
@ -128,6 +128,29 @@ def test_load_dib() -> None:
|
||||||
assert_image_equal_tofile(im, "Tests/images/clipboard_target.png")
|
assert_image_equal_tofile(im, "Tests/images/clipboard_target.png")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"header_size, path",
|
||||||
|
(
|
||||||
|
(12, "g/pal8os2.bmp"),
|
||||||
|
(40, "g/pal1.bmp"),
|
||||||
|
(52, "q/rgb32h52.bmp"),
|
||||||
|
(56, "q/rgba32h56.bmp"),
|
||||||
|
(64, "q/pal8os2v2.bmp"),
|
||||||
|
(108, "g/pal8v4.bmp"),
|
||||||
|
(124, "g/pal8v5.bmp"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
def test_dib_header_size(header_size, path):
|
||||||
|
image_path = "Tests/images/bmp/" + path
|
||||||
|
with open(image_path, "rb") as fp:
|
||||||
|
data = fp.read()[14:]
|
||||||
|
assert _binary.i32le(data) == header_size
|
||||||
|
|
||||||
|
dib = io.BytesIO(data)
|
||||||
|
with Image.open(dib) as im:
|
||||||
|
im.load()
|
||||||
|
|
||||||
|
|
||||||
def test_save_dib(tmp_path: Path) -> None:
|
def test_save_dib(tmp_path: Path) -> None:
|
||||||
outfile = str(tmp_path / "temp.dib")
|
outfile = str(tmp_path / "temp.dib")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user