mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-17 18:54:46 +03:00
EMF: support negative bounding box coordinates
Similar to placeable WMF, bounding box coordinates should be interpreted as signed integer, otherwise opening EMF file with negative (x0,y0) fails.
This commit is contained in:
parent
37698d8395
commit
bfd09d7bf1
|
@ -66,6 +66,11 @@ def short(c, o=0):
|
|||
|
||||
dword = _binary.i32le
|
||||
|
||||
def _long(c, o=0):
|
||||
v = dword(c, o)
|
||||
if v >= 1<<31:
|
||||
v -= 1<<32
|
||||
return v
|
||||
|
||||
#
|
||||
# --------------------------------------------------------------------
|
||||
|
@ -121,10 +126,10 @@ class WmfStubImageFile(ImageFile.StubImageFile):
|
|||
# enhanced metafile
|
||||
|
||||
# get bounding box
|
||||
x0 = dword(s, 8)
|
||||
y0 = dword(s, 12)
|
||||
x1 = dword(s, 16)
|
||||
y1 = dword(s, 20)
|
||||
x0 = _long(s, 8)
|
||||
y0 = _long(s, 12)
|
||||
x1 = _long(s, 16)
|
||||
y1 = _long(s, 20)
|
||||
|
||||
# get frame (in 0.01 millimeter units)
|
||||
frame = dword(s, 24), dword(s, 28), dword(s, 32), dword(s, 36)
|
||||
|
|
Loading…
Reference in New Issue
Block a user