mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
修复图片尺寸计算错误的bug
This commit is contained in:
parent
12b3dd658a
commit
2446be96ed
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user