shithub: vcrop

Download patch

ref: 4b9f1339df55862987166240d2e58ad1626c9963
parent: f36ef4b2a79306f34b825947a2a85229e4b8aa6f
author: phil9 <telephil9@gmail.com>
date: Sun Feb 6 23:42:41 EST 2022

fix transparent images artefacts when cropped

	we were using DNofill instead of DTransparent as the cropped image
	background which lead to display artefacts.
	Also use the source image chan type instead of the screen one to be
	sure we keep the same configuration between the source and the
	cropped image.

--- a/vcrop.c
+++ b/vcrop.c
@@ -58,7 +58,7 @@
 	if(o.y < n->r.min.y) o.y = n->r.min.y;
 	if((o.x + Dx(r)) > n->r.max.x) r.max.x = r.min.x + n->r.max.x - o.x;
 	if((o.y + Dy(r)) > n->r.max.y) r.max.y = r.min.y + n->r.max.y - o.y;
-	i = allocimage(display, r, screen->chan, 0, DNofill);
+	i = allocimage(display, r, n->chan, 0, DTransparent);
 	if(i==nil)
 		sysfatal("allocimage: %r");
 	draw(i, i->r, n, nil, o);