This commit is contained in:
tarsin committed 2023-01-27 18:07:46 +08:00
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(