Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a52b2f2

Browse files
committed
Fix bug in clipping rectangle in Agg backend whereby if the clipping rectangle is outside the bounds of the image *everything* gets clipped.
1 parent 0ce57c3 commit a52b2f2

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/_backend_agg.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,10 @@ RendererAgg::set_clipbox(const Py::Object& cliprect, R& rasterizer)
431431
double l, b, r, t;
432432
if (py_convert_bbox(cliprect.ptr(), l, b, r, t))
433433
{
434-
rasterizer.clip_box(int(mpl_round(l)), height - int(mpl_round(b)),
435-
int(mpl_round(r)), height - int(mpl_round(t)));
434+
rasterizer.clip_box(std::max(int(mpl_round(l)), 0),
435+
std::max(int(height) - int(mpl_round(b)), 0),
436+
std::min(int(mpl_round(r)), int(width)),
437+
std::min(int(height) - int(mpl_round(t)), int(height)));
436438
}
437439
else
438440
{

0 commit comments

Comments
 (0)