Explorar o código

修复在暗色模式下,某些无背景色pdf显示问题。

ag2s20150909 %!s(int64=3) %!d(string=hai) anos
pai
achega
e371b8a5fc

+ 2 - 0
app/src/main/java/io/legado/app/model/localBook/PdfFile.kt

@@ -1,6 +1,7 @@
 package io.legado.app.model.localBook
 package io.legado.app.model.localBook
 
 
 import android.graphics.Bitmap
 import android.graphics.Bitmap
+import android.graphics.Color
 import android.graphics.pdf.PdfRenderer
 import android.graphics.pdf.PdfRenderer
 import android.os.ParcelFileDescriptor
 import android.os.ParcelFileDescriptor
 import io.legado.app.constant.AppLog
 import io.legado.app.constant.AppLog
@@ -144,6 +145,7 @@ class PdfFile(var book: Book) {
                 Bitmap.Config.ARGB_8888
                 Bitmap.Config.ARGB_8888
             )
             )
                 .apply {
                 .apply {
+                    this.eraseColor(Color.WHITE)
                     page.render(this, null, null, PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY)
                     page.render(this, null, null, PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY)
                 }
                 }
         }
         }

+ 1 - 1
app/src/main/java/io/legado/app/utils/BitmapUtils.kt

@@ -214,7 +214,7 @@ object BitmapUtils {
      */
      */
     fun toInputStream(bitmap: Bitmap): InputStream {
     fun toInputStream(bitmap: Bitmap): InputStream {
         val bos = ByteArrayOutputStream()
         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() }
         return ByteArrayInputStream(bos.toByteArray()).also { bos.close() }
     }
     }