From a318c5742b224f2eda982bb82081ef317582c965 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 26 Oct 2024 22:31:41 +1100 Subject: [PATCH] Do not skip failing records on 32-bit --- Tests/test_file_wmf.py | 2 ++ src/display.c | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Tests/test_file_wmf.py b/Tests/test_file_wmf.py index 2adf38d48c3..d8dddca48b8 100644 --- a/Tests/test_file_wmf.py +++ b/Tests/test_file_wmf.py @@ -4,6 +4,7 @@ from pathlib import Path from typing import IO +import sys import pytest from PIL import Image, ImageFile, WmfImagePlugin @@ -35,6 +36,7 @@ def test_load() -> None: assert im.load()[0, 0] == (255, 255, 255) +@pytest.mark.skipif(sys.maxsize <= 2**32, reason="Requires 64-bit system") def test_render() -> None: with open("Tests/images/drawing.emf", "rb") as fp: data = fp.read() diff --git a/src/display.c b/src/display.c index 03b9316c36a..00e07d80306 100644 --- a/src/display.c +++ b/src/display.c @@ -718,7 +718,7 @@ PyImaging_EventLoopWin32(PyObject *self, PyObject *args) { BOOL enhMetaFileProc( - HDC hdc, HANDLETABLE FAR *lpht, CONST ENHMETARECORD *lpmr, int nHandles, LPARAM data + HDC hdc, HANDLETABLE FAR *lpht, const ENHMETARECORD *lpmr, int nHandles, LPARAM data ) { PlayEnhMetaFileRecord(hdc, lpht, lpmr, nHandles); return TRUE; @@ -804,7 +804,14 @@ PyImaging_DrawWmf(PyObject *self, PyObject *args) { /* FIXME: make background transparent? configurable? */ FillRect(dc, &rect, GetStockObject(WHITE_BRUSH)); +#ifdef _WIN64 EnumEnhMetaFile(dc, meta, enhMetaFileProc, NULL, &rect); +#else + if (!PlayEnhMetaFile(dc, meta, &rect)) { + PyErr_SetString(PyExc_OSError, "cannot render metafile"); + goto error; + } +#endif /* step 4: extract bits from bitmap */