Skip to content

Commit

Permalink
replace roundToInt with toInt
Browse files Browse the repository at this point in the history
  • Loading branch information
MoyuruAizawa committed Apr 8, 2024
1 parent 8d86ad2 commit 5826147
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions cropify/src/main/java/io/moyuru/cropify/Cropify.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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().coerceAtLeast(1).coerceAtMost(bitmap.width),
(frameRect.height * scale).toInt().coerceAtLeast(1).coerceAtMost(bitmap.height),
).asImageBitmap()
}
}
Expand Down

0 comments on commit 5826147

Please sign in to comment.