Skip to content

Commit

Permalink
Convert bitmap to HARDWARE config (#3)
Browse files Browse the repository at this point in the history
* Convert bitmap to HARDWARE config

* optional on sdk 26
  • Loading branch information
wwww-wwww authored Apr 18, 2024
1 parent aeaa170 commit e620608
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import android.graphics.Bitmap
import android.graphics.Point
import android.graphics.Rect
import android.os.Build
import android.util.Log
import com.davemorrissey.labs.subscaleview.provider.InputProvider
import tachiyomi.decoder.ImageDecoder
Expand Down Expand Up @@ -52,7 +53,10 @@ class Decoder(
* @return The decoded region. It is safe to return null if decoding fails.
*/
override fun decodeRegion(sRect: Rect, sampleSize: Int): Bitmap {
val bitmap = decoder?.decode(sRect, sampleSize)
var bitmap = decoder?.decode(sRect, sampleSize)
if (Build.VERSION.SDK_INT >= 26) {
bitmap = bitmap?.copy(Bitmap.Config.HARDWARE, false)
}
return bitmap ?: error("Null region bitmap")
}

Expand Down
2 changes: 1 addition & 1 deletion sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {

defaultConfig {
applicationId = "com.davemorrissey.labs.subscaleview.test"
minSdk = 24
minSdk = 21
targetSdk = 34

versionCode = 4
Expand Down

0 comments on commit e620608

Please sign in to comment.