From 96626e6b009ca1340240898371669aa33962e2b1 Mon Sep 17 00:00:00 2001 From: Markus Fisch Date: Wed, 10 Jan 2024 22:38:31 +0100 Subject: [PATCH] Move origin subtraction out of min() Simplifies the calculation of the width and height of the crop section. --- .../de/markusfisch/android/binaryeye/graphics/BitmapEditor.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/de/markusfisch/android/binaryeye/graphics/BitmapEditor.kt b/app/src/main/kotlin/de/markusfisch/android/binaryeye/graphics/BitmapEditor.kt index 2ce1d319..cc51c909 100644 --- a/app/src/main/kotlin/de/markusfisch/android/binaryeye/graphics/BitmapEditor.kt +++ b/app/src/main/kotlin/de/markusfisch/android/binaryeye/graphics/BitmapEditor.kt @@ -64,8 +64,8 @@ fun Bitmap.crop( b, x, y, - min(w - x, (rect.right * w).roundToInt() - x), - min(h - y, (rect.bottom * h).roundToInt() - y) + min(w, (rect.right * w).roundToInt()) - x, + min(h, (rect.bottom * h).roundToInt()) - y ) } catch (e: OutOfMemoryError) { null