mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-16 05:57:29 +01:00
PagerPageHolder: Move chooseBackground call to IO thread (#5737)
* ImageUtil.chooseBackground: Use built-in decoder * PagerPageHolder: Move chooseBackground call to IO thread Also move stuffs and reuse image stream as bytes
This commit is contained in:
@@ -18,7 +18,6 @@ import androidx.core.graphics.green
|
||||
import androidx.core.graphics.red
|
||||
import tachiyomi.decoder.Format
|
||||
import tachiyomi.decoder.ImageDecoder
|
||||
import tachiyomi.decoder.ImageType
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.InputStream
|
||||
@@ -181,11 +180,9 @@ object ImageUtil {
|
||||
* Algorithm for determining what background to accompany a comic/manga page
|
||||
*/
|
||||
fun chooseBackground(context: Context, imageStream: InputStream): Drawable {
|
||||
imageStream.mark(imageStream.available() + 1)
|
||||
|
||||
val image = BitmapFactory.decodeStream(imageStream)
|
||||
|
||||
imageStream.reset()
|
||||
val decoder = ImageDecoder.newInstance(imageStream)
|
||||
val image = decoder?.decode()
|
||||
decoder?.recycle()
|
||||
|
||||
val whiteColor = Color.WHITE
|
||||
if (image == null) return ColorDrawable(whiteColor)
|
||||
|
||||
Reference in New Issue
Block a user