From 92ea6d81388b0d187a525dc38166c01ad6ceb10b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Fri, 21 Jul 2023 15:27:07 +0200 Subject: [PATCH] Always use ARGB_8888 to avoid artifacts in images This closes #343 --- .../simplemobiletools/gallery/pro/fragments/PhotoFragment.kt | 2 +- .../gallery/pro/helpers/PicassoRegionDecoder.kt | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt index d094d4ba6..84da27361 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt @@ -665,7 +665,7 @@ class PhotoFragment : ViewPagerFragment() { } val regionDecoder = object : DecoderFactory { - override fun make() = PicassoRegionDecoder(showHighestQuality, mScreenWidth, mScreenHeight, minTileDpi, mMedium.isHeic()) + override fun make() = PicassoRegionDecoder(showHighestQuality, mScreenWidth, mScreenHeight, minTileDpi) } var newOrientation = (rotation + mCurrentRotationDegrees) % 360 diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/PicassoRegionDecoder.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/PicassoRegionDecoder.kt index b3133327d..35a7c6cfc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/PicassoRegionDecoder.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/PicassoRegionDecoder.kt @@ -9,8 +9,7 @@ class PicassoRegionDecoder( val showHighestQuality: Boolean, val screenWidth: Int, val screenHeight: Int, - val minTileDpi: Int, - val isHeic: Boolean + val minTileDpi: Int ) : ImageRegionDecoder { private var decoder: BitmapRegionDecoder? = null private val decoderLock = Any() @@ -35,7 +34,7 @@ class PicassoRegionDecoder( val options = BitmapFactory.Options() options.inSampleSize = newSampleSize - options.inPreferredConfig = if (showHighestQuality || isHeic) Bitmap.Config.ARGB_8888 else Bitmap.Config.RGB_565 + options.inPreferredConfig = Bitmap.Config.ARGB_8888 val bitmap = decoder!!.decodeRegion(rect, options) return bitmap ?: throw RuntimeException("Region decoder returned null bitmap - image format may not be supported") }