pull/36/head
kunfei 5 years ago
parent bced8f3837
commit 0a26d404b0
  1. 13
      app/src/main/java/io/legado/app/utils/BitmapUtil.kt

@ -13,9 +13,12 @@ import android.view.View
import io.legado.app.App import io.legado.app.App
import java.io.IOException import java.io.IOException
import kotlin.math.ceil import kotlin.math.ceil
import kotlin.math.floor
import kotlin.math.min
import kotlin.math.sqrt
@SuppressWarnings("unused", "WeakerAccess") @Suppress("unused", "WeakerAccess")
object BitmapUtil { object BitmapUtil {
/** /**
* 从path中获取图片信息,在通过BitmapFactory.decodeFile(String path)方法将突破转成Bitmap时 * 从path中获取图片信息,在通过BitmapFactory.decodeFile(String path)方法将突破转成Bitmap时
@ -195,11 +198,11 @@ object BitmapUtil {
val lowerBound = if (maxNumOfPixels == -1) val lowerBound = if (maxNumOfPixels == -1)
1 1
else else
Math.ceil(Math.sqrt(w * h / maxNumOfPixels)).toInt() ceil(sqrt(w * h / maxNumOfPixels)).toInt()
val upperBound = if (minSideLength == -1) 128 else Math.min( val upperBound = if (minSideLength == -1) 128 else min(
Math.floor(w / minSideLength), floor(w / minSideLength),
Math.floor(h / minSideLength) floor(h / minSideLength)
).toInt() ).toInt()
if (upperBound < lowerBound) { if (upperBound < lowerBound) {

Loading…
Cancel
Save