really use argb_8888 format at max quality

This commit is contained in:
tibbi 2019-02-21 10:55:41 +01:00
parent 4b546b6d52
commit 1dd06fc09a
3 changed files with 8 additions and 7 deletions

View file

@ -61,7 +61,7 @@ android {
} }
dependencies { 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 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.multidex:multidex:2.0.1'
implementation 'it.sephiroth.android.exif:library:1.0.1' implementation 'it.sephiroth.android.exif:library:1.0.1'

View file

@ -438,13 +438,15 @@ class PhotoFragment : ViewPagerFragment() {
private fun addZoomableView() { private fun addZoomableView() {
val rotation = degreesForRotation(mImageOrientation) val rotation = degreesForRotation(mImageOrientation)
mIsSubsamplingVisible = true mIsSubsamplingVisible = true
val config = context!!.config
val showHighestQuality = config.showHighestQuality
val bitmapDecoder = object : DecoderFactory<ImageDecoder> { val bitmapDecoder = object : DecoderFactory<ImageDecoder> {
override fun make() = PicassoDecoder(mMedium.path, Picasso.get(), rotation) override fun make() = PicassoDecoder(mMedium.path, Picasso.get(), rotation)
} }
val regionDecoder = object : DecoderFactory<ImageRegionDecoder> { val regionDecoder = object : DecoderFactory<ImageRegionDecoder> {
override fun make() = PicassoRegionDecoder() override fun make() = PicassoRegionDecoder(showHighestQuality)
} }
var newOrientation = (rotation + mCurrentRotationDegrees) % 360 var newOrientation = (rotation + mCurrentRotationDegrees) % 360
@ -452,10 +454,9 @@ class PhotoFragment : ViewPagerFragment() {
newOrientation += 360 newOrientation += 360
} }
val config = context!!.config
mView.subsampling_view.apply { mView.subsampling_view.apply {
setMaxTileSize(if (config.showHighestQuality) Integer.MAX_VALUE else 4096) setMaxTileSize(if (showHighestQuality) Integer.MAX_VALUE else 4096)
setMinimumTileDpi(if (config.showHighestQuality) -1 else getMinTileDpi()) setMinimumTileDpi(if (showHighestQuality) -1 else getMinTileDpi())
background = ColorDrawable(Color.TRANSPARENT) background = ColorDrawable(Color.TRANSPARENT)
bitmapDecoderFactory = bitmapDecoder bitmapDecoderFactory = bitmapDecoder
regionDecoderFactory = regionDecoder regionDecoderFactory = regionDecoder

View file

@ -5,7 +5,7 @@ import android.graphics.*
import android.net.Uri import android.net.Uri
import com.davemorrissey.labs.subscaleview.ImageRegionDecoder import com.davemorrissey.labs.subscaleview.ImageRegionDecoder
class PicassoRegionDecoder : ImageRegionDecoder { class PicassoRegionDecoder(val showHighestQuality: Boolean) : ImageRegionDecoder {
private var decoder: BitmapRegionDecoder? = null private var decoder: BitmapRegionDecoder? = null
private val decoderLock = Any() private val decoderLock = Any()
@ -20,7 +20,7 @@ class PicassoRegionDecoder : ImageRegionDecoder {
synchronized(decoderLock) { synchronized(decoderLock) {
val options = BitmapFactory.Options() val options = BitmapFactory.Options()
options.inSampleSize = sampleSize 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) val bitmap = decoder!!.decodeRegion(rect, options)
return bitmap ?: throw RuntimeException("Region decoder returned null bitmap - image format may not be supported") return bitmap ?: throw RuntimeException("Region decoder returned null bitmap - image format may not be supported")
} }