mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-10 16:22:22 +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))
|
im = im.crop((12, 23, im2.width + 12, im2.height + 23))
|
||||||
assert_image_equal(im, im2)
|
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"])
|
@pytest.mark.parametrize("mode", ["RGBA", "RGB", "L"])
|
||||||
def test_image_mask_1(self, mode: str) -> None:
|
def test_image_mask_1(self, mode: str) -> None:
|
||||||
im = Image.new(mode, (200, 200), "white")
|
im = Image.new(mode, (200, 200), "white")
|
||||||
|
|
|
@ -44,9 +44,15 @@ paste(
|
||||||
|
|
||||||
xsize *= pixelsize;
|
xsize *= pixelsize;
|
||||||
|
|
||||||
|
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++) {
|
for (y = 0; y < ysize; y++) {
|
||||||
memcpy(imOut->image[y + dy] + dx, imIn->image[y + sy] + sx, xsize);
|
memcpy(imOut->image[y + dy] + dx, imIn->image[y + sy] + sx, xsize);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
|
|
Loading…
Reference in New Issue
Block a user