Resolve #734
This commit is contained in:
1 parent
bb25449b35
commit
b36e5b7906
1 file changed
+5
@@ -24,6 +24,7 @@ import android.graphics.ImageDecoder.Source
|
||||
import android.graphics.drawable.Animatable
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.Build
|
||||
import com.hippo.ehviewer.EhApplication
|
||||
import java.nio.ByteBuffer
|
||||
import kotlin.math.min
|
||||
@@ -31,6 +32,10 @@ import kotlin.math.min
|
||||
class Image private constructor(source: Source, private var src: ByteBufferSource?) {
|
||||
var mObtainedDrawable: Drawable? =
|
||||
ImageDecoder.decodeDrawable(source) { decoder: ImageDecoder, info: ImageInfo, _: Source ->
|
||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.P) {
|
||||
// Allocating hardware bitmap may cause a crash on framework versions prior to Android Q
|
||||
decoder.allocator = ImageDecoder.ALLOCATOR_SOFTWARE
|
||||
}
|
||||
decoder.setTargetColorSpace(colorSpace)
|
||||
decoder.setTargetSampleSize(
|
||||
min(
|
||||
|
||||
Reference in new issue
Block a user