mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 09:14:27 +03:00
Skip failing records when rendering
This commit is contained in:
parent
81a3bf5f58
commit
ce4059171c
|
@ -1,5 +1,6 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from io import BytesIO
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import IO
|
from typing import IO
|
||||||
|
|
||||||
|
@ -7,7 +8,7 @@ import pytest
|
||||||
|
|
||||||
from PIL import Image, ImageFile, WmfImagePlugin
|
from PIL import Image, ImageFile, WmfImagePlugin
|
||||||
|
|
||||||
from .helper import assert_image_similar_tofile, hopper
|
from .helper import assert_image_equal_tofile, assert_image_similar_tofile, hopper
|
||||||
|
|
||||||
|
|
||||||
def test_load_raw() -> None:
|
def test_load_raw() -> None:
|
||||||
|
@ -34,6 +35,15 @@ def test_load() -> None:
|
||||||
assert im.load()[0, 0] == (255, 255, 255)
|
assert im.load()[0, 0] == (255, 255, 255)
|
||||||
|
|
||||||
|
|
||||||
|
def test_render() -> None:
|
||||||
|
with open("Tests/images/drawing.emf", "rb") as fp:
|
||||||
|
data = fp.read()
|
||||||
|
b = BytesIO(data[:808] + b"\x00" + data[809:])
|
||||||
|
with Image.open(b) as im:
|
||||||
|
if hasattr(Image.core, "drawwmf"):
|
||||||
|
assert_image_equal_tofile(im, "Tests/images/drawing.emf")
|
||||||
|
|
||||||
|
|
||||||
def test_register_handler(tmp_path: Path) -> None:
|
def test_register_handler(tmp_path: Path) -> None:
|
||||||
class TestHandler(ImageFile.StubHandler):
|
class TestHandler(ImageFile.StubHandler):
|
||||||
methodCalled = False
|
methodCalled = False
|
||||||
|
|
|
@ -716,6 +716,14 @@ PyImaging_EventLoopWin32(PyObject *self, PyObject *args) {
|
||||||
|
|
||||||
#define GET32(p, o) ((DWORD *)(p + o))[0]
|
#define GET32(p, o) ((DWORD *)(p + o))[0]
|
||||||
|
|
||||||
|
BOOL
|
||||||
|
enhMetaFileProc(
|
||||||
|
HDC hdc, HANDLETABLE FAR *lpht, CONST ENHMETARECORD *lpmr, int nHandles, LPARAM data
|
||||||
|
) {
|
||||||
|
PlayEnhMetaFileRecord(hdc, lpht, lpmr, nHandles);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyImaging_DrawWmf(PyObject *self, PyObject *args) {
|
PyImaging_DrawWmf(PyObject *self, PyObject *args) {
|
||||||
HBITMAP bitmap;
|
HBITMAP bitmap;
|
||||||
|
@ -796,10 +804,7 @@ PyImaging_DrawWmf(PyObject *self, PyObject *args) {
|
||||||
/* FIXME: make background transparent? configurable? */
|
/* FIXME: make background transparent? configurable? */
|
||||||
FillRect(dc, &rect, GetStockObject(WHITE_BRUSH));
|
FillRect(dc, &rect, GetStockObject(WHITE_BRUSH));
|
||||||
|
|
||||||
if (!PlayEnhMetaFile(dc, meta, &rect)) {
|
EnumEnhMetaFile(dc, meta, enhMetaFileProc, NULL, &rect);
|
||||||
PyErr_SetString(PyExc_OSError, "cannot render metafile");
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* step 4: extract bits from bitmap */
|
/* step 4: extract bits from bitmap */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user