From 9fc9cde2490217fe2217c114569bf3c51ca0b0f8 Mon Sep 17 00:00:00 2001 From: moyuru Date: Mon, 8 Apr 2024 15:36:26 +0900 Subject: [PATCH] replace roundToInt with toInt --- cropify/src/main/java/io/moyuru/cropify/Cropify.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cropify/src/main/java/io/moyuru/cropify/Cropify.kt b/cropify/src/main/java/io/moyuru/cropify/Cropify.kt index 8fcabbf..1d24b99 100644 --- a/cropify/src/main/java/io/moyuru/cropify/Cropify.kt +++ b/cropify/src/main/java/io/moyuru/cropify/Cropify.kt @@ -25,7 +25,6 @@ import androidx.compose.ui.unit.IntSize import androidx.compose.ui.unit.dp import java.lang.Float.max import java.lang.Float.min -import kotlin.math.roundToInt import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext @@ -157,10 +156,10 @@ private suspend fun cropImage( val scale = bitmap.width / imageRect.width Bitmap.createBitmap( bitmap.asAndroidBitmap(), - ((frameRect.left - imageRect.left) * scale).roundToInt(), - ((frameRect.top - imageRect.top) * scale).roundToInt(), - (frameRect.width * scale).roundToInt(), - (frameRect.height * scale).roundToInt(), + ((frameRect.left - imageRect.left) * scale).toInt(), + ((frameRect.top - imageRect.top) * scale).toInt(), + (frameRect.width * scale).toInt().coerceIn(1..bitmap.width), + (frameRect.height * scale).toInt().coerceIn(1..bitmap.height), ).asImageBitmap() } }