From 2446be96eddd5d6249087e6586065543d99d379f Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 18 May 2022 20:37:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9B=BE=E7=89=87=E5=B0=BA?= =?UTF-8?q?=E5=AF=B8=E8=AE=A1=E7=AE=97=E9=94=99=E8=AF=AF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/utils/BitmapUtils.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/utils/BitmapUtils.kt b/app/src/main/java/io/legado/app/utils/BitmapUtils.kt index c237deba7..e2407c95e 100644 --- a/app/src/main/java/io/legado/app/utils/BitmapUtils.kt +++ b/app/src/main/java/io/legado/app/utils/BitmapUtils.kt @@ -53,13 +53,13 @@ object BitmapUtils { height: Int? = null ): Int { //获取比例大小 - val wRatio = width?.let { ceil((options.outWidth / it).toDouble()).toInt() } ?: -1 - val hRatio = height?.let { ceil((options.outHeight / it).toDouble()).toInt() } ?: -1 + val wRatio = width?.let { ceil((options.outWidth / it.toFloat())).toInt() } ?: -1 + val hRatio = height?.let { ceil((options.outHeight / it.toFloat())).toInt() } ?: -1 //如果超出指定大小,则缩小相应的比例 return when { wRatio > 1 && hRatio > 1 -> max(wRatio, hRatio) wRatio > 1 -> wRatio - hRatio > 1 -> hRatio + hRatio > 1 -> hRatio else -> 1 } }