mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-31 16:07:30 +03:00 
			
		
		
		
	Merge pull request #5313 from radarhere/alpha_composite
Allow alpha_composite destination to be negative
This commit is contained in:
		
						commit
						e110e093a6
					
				|  | @ -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)) | ||||
| 
 | ||||
|  |  | |||
|  | @ -13,6 +13,14 @@ when Tk/Tcl 8.5 will be the minimum supported. | |||
| API Changes | ||||
| =========== | ||||
| 
 | ||||
| Image.alpha_composite: dest | ||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||||
| 
 | ||||
| When calling :py:meth:`~PIL.Image.Image.alpha_composite`, the ``dest`` argument now | ||||
| accepts negative co-ordinates, like the upper left corner of the ``box`` argument of | ||||
| :py:meth:`~PIL.Image.Image.paste` can be negative. Naturally, this has effect of | ||||
| cropping the overlaid image. | ||||
| 
 | ||||
| ImageDraw.rounded_rectangle | ||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||||
| 
 | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user