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 096fc56d2..572538ec8 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 @@ -646,7 +646,7 @@ class PhotoFragment : ViewPagerFragment() { } val regionDecoder = object : DecoderFactory { - override fun make() = PicassoRegionDecoder(showHighestQuality, mScreenWidth, mScreenHeight, minTileDpi) + override fun make() = PicassoRegionDecoder(showHighestQuality, mScreenWidth, mScreenHeight, minTileDpi, mMedium.isHeic()) } 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 2c98321e9..b6135f9ab 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 @@ -5,7 +5,13 @@ import android.graphics.* import android.net.Uri import com.davemorrissey.labs.subscaleview.ImageRegionDecoder -class PicassoRegionDecoder(val showHighestQuality: Boolean, val screenWidth: Int, val screenHeight: Int, val minTileDpi: Int) : ImageRegionDecoder { +class PicassoRegionDecoder( + val showHighestQuality: Boolean, + val screenWidth: Int, + val screenHeight: Int, + val minTileDpi: Int, + val isHeic: Boolean +) : ImageRegionDecoder { private var decoder: BitmapRegionDecoder? = null private val decoderLock = Any() @@ -29,9 +35,8 @@ class PicassoRegionDecoder(val showHighestQuality: Boolean, val screenWidth: Int val options = BitmapFactory.Options() options.inSampleSize = newSampleSize - options.inPreferredConfig = if (showHighestQuality) Bitmap.Config.ARGB_8888 else Bitmap.Config.RGB_565 + options.inPreferredConfig = if (showHighestQuality || isHeic) Bitmap.Config.ARGB_8888 else Bitmap.Config.RGB_565 val bitmap = decoder!!.decodeRegion(rect, options) - return bitmap ?: throw RuntimeException("Region decoder returned null bitmap - image format may not be supported") } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Medium.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Medium.kt index 6f38135b0..680384109 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Medium.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Medium.kt @@ -54,6 +54,8 @@ data class Medium( fun isHidden() = name.startsWith('.') + fun isHeic() = name.toLowerCase().endsWith(".heic") || name.toLowerCase().endsWith(".heif") + fun getBubbleText(sorting: Int, context: Context, dateFormat: String, timeFormat: String) = when { sorting and SORT_BY_NAME != 0 -> name sorting and SORT_BY_PATH != 0 -> path