Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Tests/test_imagewin.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_dib_paste(self) -> None:
def test_dib_paste_bbox(self) -> None:
# Arrange
im = hopper()
bbox = (0, 0, 10, 10)
bbox = (0, 0, 128, 128)

mode = "RGBA"
size = (128, 128)
Expand All @@ -101,6 +101,9 @@ def test_dib_paste_bbox(self) -> None:
# Assert
assert dib.size == (128, 128)

with pytest.raises(ValueError, match="images do not match"):
dib.paste(im, (0, 0, 1, 1))

def test_dib_frombytes_tobytes_roundtrip(self) -> None:
# Arrange
# Make two different DIB images
Expand Down
4 changes: 4 additions & 0 deletions src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,13 @@ _paste(ImagingDisplayObject *display, PyObject *args) {

if (xy[2] <= xy[0]) {
xy[2] = xy[0] + im->xsize;
} else if (xy[2] - xy[0] != im->xsize) {
return ImagingError_Mismatch();
}
if (xy[3] <= xy[1]) {
xy[3] = xy[1] + im->ysize;
} else if (xy[3] - xy[1] != im->ysize) {
return ImagingError_Mismatch();
}

ImagingPasteDIB(display->dib, im, xy);
Expand Down
Loading