Use image decoder for double pages
(cherry picked from commit 4ddc696fb5aa662a9831048a502d416085ce2566) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt
This commit is contained in:
parent
4cf068283b
commit
84d22c11ee
@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.ui.reader
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.graphics.BitmapFactory
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import androidx.annotation.ColorInt
|
||||
@ -64,6 +63,7 @@ import rx.Observable
|
||||
import rx.Subscription
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import rx.schedulers.Schedulers
|
||||
import tachiyomi.decoder.ImageDecoder
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
@ -773,7 +773,7 @@ class ReaderPresenter(
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun saveImages(
|
||||
private fun saveImages(
|
||||
page1: ReaderPage,
|
||||
page2: ReaderPage,
|
||||
isLTR: Boolean,
|
||||
@ -785,11 +785,8 @@ class ReaderPresenter(
|
||||
ImageUtil.findImageType(stream1) ?: throw Exception("Not an image")
|
||||
val stream2 = page2.stream!!
|
||||
ImageUtil.findImageType(stream2) ?: throw Exception("Not an image")
|
||||
val imageBytes = stream1().readBytes()
|
||||
val imageBitmap = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.size)
|
||||
|
||||
val imageBytes2 = stream2().readBytes()
|
||||
val imageBitmap2 = BitmapFactory.decodeByteArray(imageBytes2, 0, imageBytes2.size)
|
||||
val imageBitmap = ImageDecoder.newInstance(stream1())?.decode()!!
|
||||
val imageBitmap2 = ImageDecoder.newInstance(stream2())?.decode()!!
|
||||
|
||||
val chapter = page1.chapter.chapter
|
||||
|
||||
|
@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.ui.reader.viewer.pager
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.graphics.BitmapFactory
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import androidx.core.view.isVisible
|
||||
@ -24,6 +23,7 @@ import rx.Observable
|
||||
import rx.Subscription
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import rx.schedulers.Schedulers
|
||||
import tachiyomi.decoder.ImageDecoder
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.io.InputStream
|
||||
import java.util.concurrent.TimeUnit
|
||||
@ -366,13 +366,17 @@ class PagerPageHolder(
|
||||
}
|
||||
val imageBytes = imageStream.readBytes()
|
||||
val imageBitmap = try {
|
||||
BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.size)
|
||||
ImageDecoder.newInstance(imageBytes.inputStream())?.decode()
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e) { "Cannot combine pages" }
|
||||
null
|
||||
}
|
||||
if (imageBitmap == null) {
|
||||
imageStream2.close()
|
||||
imageStream.close()
|
||||
page.fullPage = true
|
||||
splitDoublePages()
|
||||
logcat(LogPriority.ERROR, e) { "Cannot combine pages" }
|
||||
logcat(LogPriority.ERROR) { "Cannot combine pages" }
|
||||
return imageBytes.inputStream()
|
||||
}
|
||||
viewer.scope.launchUI { progressIndicator.setProgress(96) }
|
||||
@ -389,14 +393,18 @@ class PagerPageHolder(
|
||||
|
||||
val imageBytes2 = imageStream2.readBytes()
|
||||
val imageBitmap2 = try {
|
||||
BitmapFactory.decodeByteArray(imageBytes2, 0, imageBytes2.size)
|
||||
ImageDecoder.newInstance(imageBytes2.inputStream())?.decode()
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e) { "Cannot combine pages" }
|
||||
null
|
||||
}
|
||||
if (imageBitmap2 == null) {
|
||||
imageStream2.close()
|
||||
imageStream.close()
|
||||
extraPage?.fullPage = true
|
||||
page.isolatedPage = true
|
||||
splitDoublePages()
|
||||
logcat(LogPriority.ERROR, e) { "Cannot combine pages" }
|
||||
logcat(LogPriority.ERROR) { "Cannot combine pages" }
|
||||
return imageBytes.inputStream()
|
||||
}
|
||||
viewer.scope.launchUI { progressIndicator.setProgress(97) }
|
||||
|
Loading…
x
Reference in New Issue
Block a user