Skip to content

Commit b4ba466

Browse files
committed
Do not skip failing records on 32-bit
1 parent 8c1dc0d commit b4ba466

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Tests/test_file_wmf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import sys
34
from io import BytesIO
45
from pathlib import Path
56
from typing import IO
@@ -35,6 +36,7 @@ def test_load() -> None:
3536
assert im.load()[0, 0] == (255, 255, 255)
3637

3738

39+
@pytest.mark.skipif(sys.maxsize <= 2**32, reason="Requires 64-bit system")
3840
def test_render() -> None:
3941
with open("Tests/images/drawing.emf", "rb") as fp:
4042
data = fp.read()

src/display.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -716,12 +716,12 @@ PyImaging_EventLoopWin32(PyObject *self, PyObject *args) {
716716

717717
#define GET32(p, o) ((DWORD *)(p + o))[0]
718718

719-
BOOL
719+
int
720720
enhMetaFileProc(
721-
HDC hdc, HANDLETABLE FAR *lpht, CONST ENHMETARECORD *lpmr, int nHandles, LPARAM data
721+
HDC hdc, HANDLETABLE *lpht, const ENHMETARECORD *lpmr, int nHandles, LPARAM data
722722
) {
723723
PlayEnhMetaFileRecord(hdc, lpht, lpmr, nHandles);
724-
return TRUE;
724+
return 1;
725725
}
726726

727727
PyObject *
@@ -804,7 +804,14 @@ PyImaging_DrawWmf(PyObject *self, PyObject *args) {
804804
/* FIXME: make background transparent? configurable? */
805805
FillRect(dc, &rect, GetStockObject(WHITE_BRUSH));
806806

807+
#ifdef _WIN64
807808
EnumEnhMetaFile(dc, meta, enhMetaFileProc, NULL, &rect);
809+
#else
810+
if (!PlayEnhMetaFile(dc, meta, &rect)) {
811+
PyErr_SetString(PyExc_OSError, "cannot render metafile");
812+
goto error;
813+
}
814+
#endif
808815

809816
/* step 4: extract bits from bitmap */
810817

0 commit comments

Comments
 (0)