mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-04-21 01:32:00 +03:00
If pasting an image onto itself at a lower position, copy from bottom
This commit is contained in:
parent
c8d98d56a0
commit
79f834ef65
|
@ -124,6 +124,18 @@ class TestImagingPaste:
|
|||
im = im.crop((12, 23, im2.width + 12, im2.height + 23))
|
||||
assert_image_equal(im, im2)
|
||||
|
||||
@pytest.mark.parametrize("y", [10, -10])
|
||||
def test_image_self(self, y: int) -> None:
|
||||
im = self.gradient_RGB
|
||||
|
||||
im_self = im.copy()
|
||||
im_self.paste(im_self, (0, y))
|
||||
|
||||
im_copy = im.copy()
|
||||
im_copy.paste(im_copy.copy(), (0, y))
|
||||
|
||||
assert_image_equal(im_self, im_copy)
|
||||
|
||||
@pytest.mark.parametrize("mode", ["RGBA", "RGB", "L"])
|
||||
def test_image_mask_1(self, mode: str) -> None:
|
||||
im = Image.new(mode, (200, 200), "white")
|
||||
|
|
|
@ -44,8 +44,14 @@ paste(
|
|||
|
||||
xsize *= pixelsize;
|
||||
|
||||
for (y = 0; y < ysize; y++) {
|
||||
memcpy(imOut->image[y + dy] + dx, imIn->image[y + sy] + sx, xsize);
|
||||
if (imOut == imIn && dy > sy) {
|
||||
for (y = ysize - 1; y >= 0; y--) {
|
||||
memcpy(imOut->image[y + dy] + dx, imIn->image[y + sy] + sx, xsize);
|
||||
}
|
||||
} else {
|
||||
for (y = 0; y < ysize; y++) {
|
||||
memcpy(imOut->image[y + dy] + dx, imIn->image[y + sy] + sx, xsize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user