mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-04 21:50:54 +03:00
Added test for abbreviated Image paste mask syntax
This commit is contained in:
parent
581fef2ebd
commit
e8495e5917
|
@ -28,6 +28,15 @@ class TestImagingPaste(PillowTestCase):
|
||||||
]
|
]
|
||||||
self.assertEqual(actual, expected)
|
self.assertEqual(actual, expected)
|
||||||
|
|
||||||
|
def assert_9points_paste(self, im, im2, mask, expected):
|
||||||
|
im3 = im.copy()
|
||||||
|
im3.paste(im2, (0, 0), mask)
|
||||||
|
self.assert_9points_image(im3, expected)
|
||||||
|
|
||||||
|
# Abbreviated syntax
|
||||||
|
im.paste(im2, mask)
|
||||||
|
self.assert_9points_image(im, expected)
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def mask_1(self):
|
def mask_1(self):
|
||||||
mask = Image.new('1', (self.size, self.size))
|
mask = Image.new('1', (self.size, self.size))
|
||||||
|
@ -91,9 +100,7 @@ class TestImagingPaste(PillowTestCase):
|
||||||
im = Image.new(mode, (200, 200), 'white')
|
im = Image.new(mode, (200, 200), 'white')
|
||||||
im2 = getattr(self, 'gradient_' + mode)
|
im2 = getattr(self, 'gradient_' + mode)
|
||||||
|
|
||||||
im.paste(im2, (0, 0), self.mask_1)
|
self.assert_9points_paste(im, im2, self.mask_1, [
|
||||||
|
|
||||||
self.assert_9points_image(im, [
|
|
||||||
(255, 255, 255, 255),
|
(255, 255, 255, 255),
|
||||||
(255, 255, 255, 255),
|
(255, 255, 255, 255),
|
||||||
(127, 254, 127, 0),
|
(127, 254, 127, 0),
|
||||||
|
@ -110,9 +117,7 @@ class TestImagingPaste(PillowTestCase):
|
||||||
im = Image.new(mode, (200, 200), 'white')
|
im = Image.new(mode, (200, 200), 'white')
|
||||||
im2 = getattr(self, 'gradient_' + mode)
|
im2 = getattr(self, 'gradient_' + mode)
|
||||||
|
|
||||||
im.paste(im2, (0, 0), self.mask_L)
|
self.assert_9points_paste(im, im2, self.mask_L, [
|
||||||
|
|
||||||
self.assert_9points_image(im, [
|
|
||||||
(128, 191, 255, 191),
|
(128, 191, 255, 191),
|
||||||
(208, 239, 239, 208),
|
(208, 239, 239, 208),
|
||||||
(255, 255, 255, 255),
|
(255, 255, 255, 255),
|
||||||
|
@ -129,9 +134,7 @@ class TestImagingPaste(PillowTestCase):
|
||||||
im = Image.new(mode, (200, 200), 'white')
|
im = Image.new(mode, (200, 200), 'white')
|
||||||
im2 = getattr(self, 'gradient_' + mode)
|
im2 = getattr(self, 'gradient_' + mode)
|
||||||
|
|
||||||
im.paste(im2, (0, 0), self.gradient_RGBA)
|
self.assert_9points_paste(im, im2, self.gradient_RGBA, [
|
||||||
|
|
||||||
self.assert_9points_image(im, [
|
|
||||||
(128, 191, 255, 191),
|
(128, 191, 255, 191),
|
||||||
(208, 239, 239, 208),
|
(208, 239, 239, 208),
|
||||||
(255, 255, 255, 255),
|
(255, 255, 255, 255),
|
||||||
|
@ -148,9 +151,7 @@ class TestImagingPaste(PillowTestCase):
|
||||||
im = Image.new(mode, (200, 200), 'white')
|
im = Image.new(mode, (200, 200), 'white')
|
||||||
im2 = getattr(self, 'gradient_' + mode)
|
im2 = getattr(self, 'gradient_' + mode)
|
||||||
|
|
||||||
im.paste(im2, (0, 0), self.gradient_RGBa)
|
self.assert_9points_paste(im, im2, self.gradient_RGBa, [
|
||||||
|
|
||||||
self.assert_9points_image(im, [
|
|
||||||
(128, 255, 126, 255),
|
(128, 255, 126, 255),
|
||||||
(0, 127, 126, 255),
|
(0, 127, 126, 255),
|
||||||
(126, 253, 126, 255),
|
(126, 253, 126, 255),
|
||||||
|
@ -180,9 +181,7 @@ class TestImagingPaste(PillowTestCase):
|
||||||
im = Image.new(mode, (200, 200), (50, 60, 70, 80)[:len(mode)])
|
im = Image.new(mode, (200, 200), (50, 60, 70, 80)[:len(mode)])
|
||||||
color = (10, 20, 30, 40)[:len(mode)]
|
color = (10, 20, 30, 40)[:len(mode)]
|
||||||
|
|
||||||
im.paste(color, (0, 0), self.mask_1)
|
self.assert_9points_paste(im, color, self.mask_1, [
|
||||||
|
|
||||||
self.assert_9points_image(im, [
|
|
||||||
(50, 60, 70, 80),
|
(50, 60, 70, 80),
|
||||||
(50, 60, 70, 80),
|
(50, 60, 70, 80),
|
||||||
(10, 20, 30, 40),
|
(10, 20, 30, 40),
|
||||||
|
@ -199,9 +198,7 @@ class TestImagingPaste(PillowTestCase):
|
||||||
im = getattr(self, 'gradient_' + mode).copy()
|
im = getattr(self, 'gradient_' + mode).copy()
|
||||||
color = 'white'
|
color = 'white'
|
||||||
|
|
||||||
im.paste(color, (0, 0), self.mask_L)
|
self.assert_9points_paste(im, color, self.mask_L, [
|
||||||
|
|
||||||
self.assert_9points_image(im, [
|
|
||||||
(127, 191, 254, 191),
|
(127, 191, 254, 191),
|
||||||
(111, 207, 206, 110),
|
(111, 207, 206, 110),
|
||||||
(127, 254, 127, 0),
|
(127, 254, 127, 0),
|
||||||
|
@ -218,9 +215,7 @@ class TestImagingPaste(PillowTestCase):
|
||||||
im = getattr(self, 'gradient_' + mode).copy()
|
im = getattr(self, 'gradient_' + mode).copy()
|
||||||
color = 'white'
|
color = 'white'
|
||||||
|
|
||||||
im.paste(color, (0, 0), self.gradient_RGBA)
|
self.assert_9points_paste(im, color, self.gradient_RGBA, [
|
||||||
|
|
||||||
self.assert_9points_image(im, [
|
|
||||||
(127, 191, 254, 191),
|
(127, 191, 254, 191),
|
||||||
(111, 207, 206, 110),
|
(111, 207, 206, 110),
|
||||||
(127, 254, 127, 0),
|
(127, 254, 127, 0),
|
||||||
|
@ -237,9 +232,7 @@ class TestImagingPaste(PillowTestCase):
|
||||||
im = getattr(self, 'gradient_' + mode).copy()
|
im = getattr(self, 'gradient_' + mode).copy()
|
||||||
color = 'white'
|
color = 'white'
|
||||||
|
|
||||||
im.paste(color, (0, 0), self.gradient_RGBa)
|
self.assert_9points_paste(im, color, self.gradient_RGBa, [
|
||||||
|
|
||||||
self.assert_9points_image(im, [
|
|
||||||
(255, 63, 126, 63),
|
(255, 63, 126, 63),
|
||||||
(47, 143, 142, 46),
|
(47, 143, 142, 46),
|
||||||
(126, 253, 126, 255),
|
(126, 253, 126, 255),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user