Allow alpha_composite destination to be negative

This commit is contained in:
Andrew Murray 2021-03-06 20:54:21 +11:00
parent 1d7cbeb338
commit 690cf9ebe2
2 changed files with 6 additions and 4 deletions

View File

@ -344,6 +344,12 @@ class TestImage:
assert_image_equal(offset.crop((64, 64, 127, 127)), target.crop((0, 0, 63, 63)))
assert offset.size == (128, 128)
# with negative offset
offset = src.copy()
offset.alpha_composite(over, (-64, -64))
assert_image_equal(offset.crop((0, 0, 63, 63)), target.crop((64, 64, 127, 127)))
assert offset.size == (128, 128)
# offset and crop
box = src.copy()
box.alpha_composite(over, (64, 64), (0, 0, 32, 32))
@ -367,8 +373,6 @@ class TestImage:
source.alpha_composite(over, 0)
with pytest.raises(ValueError):
source.alpha_composite(over, (0, 0), 0)
with pytest.raises(ValueError):
source.alpha_composite(over, (0, -1))
with pytest.raises(ValueError):
source.alpha_composite(over, (0, 0), (0, -1))

View File

@ -1544,8 +1544,6 @@ class Image:
raise ValueError("Destination must be a 2-tuple")
if min(source) < 0:
raise ValueError("Source must be non-negative")
if min(dest) < 0:
raise ValueError("Destination must be non-negative")
if len(source) == 2:
source = source + im.size