From 6797894f1c515258ebccd0c835d8e80b4a02376d Mon Sep 17 00:00:00 2001 From: ag2s20150909 Date: Mon, 19 Dec 2022 15:09:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9C=A8=E6=9A=97=E8=89=B2?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=8B=EF=BC=8C=E6=9F=90=E4=BA=9B=E6=97=A0?= =?UTF-8?q?=E8=83=8C=E6=99=AF=E8=89=B2pdf=E6=98=BE=E7=A4=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/model/localBook/PdfFile.kt | 2 ++ app/src/main/java/io/legado/app/utils/BitmapUtils.kt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/model/localBook/PdfFile.kt b/app/src/main/java/io/legado/app/model/localBook/PdfFile.kt index 42482db73..16e50c14a 100644 --- a/app/src/main/java/io/legado/app/model/localBook/PdfFile.kt +++ b/app/src/main/java/io/legado/app/model/localBook/PdfFile.kt @@ -1,6 +1,7 @@ package io.legado.app.model.localBook import android.graphics.Bitmap +import android.graphics.Color import android.graphics.pdf.PdfRenderer import android.os.ParcelFileDescriptor import io.legado.app.constant.AppLog @@ -144,6 +145,7 @@ class PdfFile(var book: Book) { Bitmap.Config.ARGB_8888 ) .apply { + this.eraseColor(Color.WHITE) page.render(this, null, null, PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY) } } 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 3a08e9702..80c19e88f 100644 --- a/app/src/main/java/io/legado/app/utils/BitmapUtils.kt +++ b/app/src/main/java/io/legado/app/utils/BitmapUtils.kt @@ -214,7 +214,7 @@ object BitmapUtils { */ fun toInputStream(bitmap: Bitmap): InputStream { val bos = ByteArrayOutputStream() - bitmap.compress(Bitmap.CompressFormat.PNG, 0 /*ignored for PNG*/, bos) + bitmap.compress(Bitmap.CompressFormat.JPEG, 90 /*ignored for PNG*/, bos) return ByteArrayInputStream(bos.toByteArray()).also { bos.close() } }