8000 Merge pull request #20887 from richardsheridan/blit-bbox-valueerror · matplotlib/matplotlib@d615cf1 · GitHub
[go: up one dir, main page]

Skip to content

Commit d615cf1

Browse files
authored
Merge pull request #20887 from richardsheridan/blit-bbox-valueerror
FIX: Implement a consistent behavior in TkAgg backend for bad blit bbox
2 parents 5743492 + 32e0474 commit d615cf1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/matplotlib/backends/_backend_tk.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ def blit(photoimage, aggimage, offsets, bbox=None):
7878
7979
If *bbox* is passed, it defines the region that gets blitted. That region
8080
will be composed with the previous data according to the alpha channel.
81+
Blitting will be clipped to pixels inside the canvas, including silently
82+
doing nothing if the *bbox* region is entirely outside the canvas.
8183
8284
Tcl events must be dispatched to trigger a blit from a non-Tcl thread.
8385
"""
@@ -90,6 +92,8 @@ def blit(photoimage, aggimage, offsets, bbox=None):
9092
x2 = min(math.ceil(x2), width)
9193
y1 = max(math.floor(y1), 0)
9294
y2 = min(math.ceil(y2), height)
95+
if (x1 > x2) or (y1 > y2):
96+
return
9397
bboxptr = (x1, x2, y1, y2)
9498
comp_rule = TK_PHOTO_COMPOSITE_OVERLAY
9599
else:

0 commit comments

Comments
 (0)
0