[lua] Fix clipping when drawing an image on a cel image (fix #3054)

This commit is contained in:
David Capello 2021-11-15 15:13:43 -03:00
parent 12e61d33be
commit 8deb9c46e7

View File

@ -230,15 +230,16 @@ int Image_drawImage(lua_State* L)
doc::copy_image(dst, src, pos.x, pos.y);
}
else {
gfx::Rect bounds(pos, src->size());
gfx::Rect output;
if (doc::algorithm::shrink_bounds2(src, dst, bounds, output)) {
Tx tx;
tx(new cmd::CopyRegion(
dst, src, gfx::Region(output),
gfx::Point(0, 0)));
tx.commit();
}
gfx::Rect bounds(0, 0, src->size().w, src->size().h);
// TODO Use something similar to doc::algorithm::shrink_bounds2()
// but we need something that does the render and compares
// the minimal modified area.
Tx tx;
tx(new cmd::CopyRegion(
dst, src, gfx::Region(bounds),
gfx::Point(pos.x + bounds.x, pos.y + bounds.y)));
tx.commit();
}
return 0;
}