From b29ce638df868604ed518be82626ea81072d05e4 Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Sun, 4 Sep 2022 11:56:53 +0800 Subject: [PATCH] Revert https://github.com/Xwite/legado/commit/38e2fe103a75ca7744333934a65ca3dfb2531003 --- .../io/legado/app/model/localBook/EpubFile.kt | 13 ++++++------- .../java/io/legado/app/utils/BitmapUtils.kt | 18 ------------------ 2 files changed, 6 insertions(+), 25 deletions(-) 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 设备上下文