diff --git a/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt b/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt index 52bcb35a7..368305998 100644 --- a/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt +++ b/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt @@ -1,6 +1,7 @@ package io.legado.app.model.localBook import android.graphics.Bitmap +import android.graphics.BitmapFactory import android.text.TextUtils import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter @@ -84,13 +85,11 @@ class EpubFile(var book: Book) { if (!File(book.coverUrl!!).exists()) { /*部分书籍DRM处理后,封面获取异常,待优化*/ it.coverImage?.inputStream?.use { input -> - BitmapUtils.decodeBitmap(input)?.let { cover -> - val out = - FileOutputStream(FileUtils.createFileIfNotExist(book.coverUrl!!)) - cover.compress(Bitmap.CompressFormat.JPEG, 90, out) - out.flush() - out.close() - } + val cover = BitmapFactory.decodeStream(input) + val out = FileOutputStream(FileUtils.createFileIfNotExist(book.coverUrl!!)) + cover.compress(Bitmap.CompressFormat.JPEG, 90, out) + out.flush() + out.close() } } } 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 40f7f7280..b6ef49b99 100644 --- a/app/src/main/java/io/legado/app/utils/BitmapUtils.kt +++ b/app/src/main/java/io/legado/app/utils/BitmapUtils.kt @@ -10,7 +10,6 @@ import android.graphics.Color import com.google.android.renderscript.Toolkit import java.io.FileInputStream import java.io.IOException -import java.io.InputStream import kotlin.math.* @@ -82,23 +81,6 @@ object BitmapUtils { } } - /** 从path中获取Bitmap图片 - * @param path 图片路径 - * @return - */ - @Throws(IOException::class) - fun decodeBitmap(inputStream: InputStream): Bitmap? { - return inputStream.use { - val opts = BitmapFactory.Options() - opts.inJustDecodeBounds = true - - BitmapFactory.decodeStream(inputStream, null, opts) - opts.inSampleSize = computeSampleSize(opts, -1, 128 * 128) - opts.inJustDecodeBounds = false - BitmapFactory.decodeStream(inputStream, null, opts) - } - } - /** * 以最省内存的方式读取本地资源的图片 * @param context 设备上下文