From 1dd06fc09a371c49799b6a65cc616ca7bf311ebf Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 21 Feb 2019 10:55:41 +0100 Subject: [PATCH] really use argb_8888 format at max quality --- app/build.gradle | 2 +- .../gallery/pro/fragments/PhotoFragment.kt | 9 +++++---- .../gallery/pro/helpers/PicassoRegionDecoder.kt | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ec5ee2c56..29fce13b4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -61,7 +61,7 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:5.8.5' + implementation 'com.simplemobiletools:commons:5.8.7' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'androidx.multidex:multidex:2.0.1' implementation 'it.sephiroth.android.exif:library:1.0.1' 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 62a4cef79..9ec6c71a6 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 @@ -438,13 +438,15 @@ class PhotoFragment : ViewPagerFragment() { private fun addZoomableView() { val rotation = degreesForRotation(mImageOrientation) mIsSubsamplingVisible = true + val config = context!!.config + val showHighestQuality = config.showHighestQuality val bitmapDecoder = object : DecoderFactory { override fun make() = PicassoDecoder(mMedium.path, Picasso.get(), rotation) } val regionDecoder = object : DecoderFactory { - override fun make() = PicassoRegionDecoder() + override fun make() = PicassoRegionDecoder(showHighestQuality) } var newOrientation = (rotation + mCurrentRotationDegrees) % 360 @@ -452,10 +454,9 @@ class PhotoFragment : ViewPagerFragment() { newOrientation += 360 } - val config = context!!.config mView.subsampling_view.apply { - setMaxTileSize(if (config.showHighestQuality) Integer.MAX_VALUE else 4096) - setMinimumTileDpi(if (config.showHighestQuality) -1 else getMinTileDpi()) + setMaxTileSize(if (showHighestQuality) Integer.MAX_VALUE else 4096) + setMinimumTileDpi(if (showHighestQuality) -1 else getMinTileDpi()) background = ColorDrawable(Color.TRANSPARENT) bitmapDecoderFactory = bitmapDecoder regionDecoderFactory = regionDecoder 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 85b0e1133..7c488b64d 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,7 @@ import android.graphics.* import android.net.Uri import com.davemorrissey.labs.subscaleview.ImageRegionDecoder -class PicassoRegionDecoder : ImageRegionDecoder { +class PicassoRegionDecoder(val showHighestQuality: Boolean) : ImageRegionDecoder { private var decoder: BitmapRegionDecoder? = null private val decoderLock = Any() @@ -20,7 +20,7 @@ class PicassoRegionDecoder : ImageRegionDecoder { synchronized(decoderLock) { val options = BitmapFactory.Options() options.inSampleSize = sampleSize - options.inPreferredConfig = Bitmap.Config.RGB_565 + options.inPreferredConfig = if (showHighestQuality) 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") }