Fix cropping still images

Can't use Rect.width()/.height() with negative left/top values
because these get cropped at 0/0 of course.

Before this commit, the cropped image was larger than it should be.
This commit is contained in:
Markus Fisch
2021-12-15 10:27:15 +01:00
parent 8618a5b482
commit d4c5c6a1dc
@@ -59,8 +59,8 @@ fun crop(bitmap: Bitmap, rect: RectF, rotation: Float) = try {
erected,
x,
y,
min(w - x, (rect.width() * w).roundToInt()),
min(h - y, (rect.height() * h).roundToInt())
min(w - x, (rect.right * w).roundToInt() - x),
min(h - y, (rect.bottom * h).roundToInt() - y)
)
} catch (e: OutOfMemoryError) {
null