lets use Glide for Subsampling image decoding, keep Picasso only at regions
This commit is contained in:
parent
ec89f03c20
commit
9b0567e7bc
|
@ -464,7 +464,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
val minTileDpi = if (showHighestQuality) -1 else getMinTileDpi()
|
val minTileDpi = if (showHighestQuality) -1 else getMinTileDpi()
|
||||||
|
|
||||||
val bitmapDecoder = object : DecoderFactory<ImageDecoder> {
|
val bitmapDecoder = object : DecoderFactory<ImageDecoder> {
|
||||||
override fun make() = PicassoDecoder(mMedium.path, Picasso.get(), rotation)
|
override fun make() = MyGlideImageDecoder(rotation, mScreenWidth, mScreenHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
val regionDecoder = object : DecoderFactory<ImageRegionDecoder> {
|
val regionDecoder = object : DecoderFactory<ImageRegionDecoder> {
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.simplemobiletools.gallery.pro.helpers
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.graphics.Bitmap
|
||||||
|
import android.net.Uri
|
||||||
|
import com.bumptech.glide.Glide
|
||||||
|
import com.bumptech.glide.load.DecodeFormat
|
||||||
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
|
import com.bumptech.glide.request.RequestOptions
|
||||||
|
import com.davemorrissey.labs.subscaleview.ImageDecoder
|
||||||
|
|
||||||
|
class MyGlideImageDecoder(val degrees: Int, val width: Int, val height: Int) : ImageDecoder {
|
||||||
|
|
||||||
|
override fun decode(context: Context, uri: Uri): Bitmap {
|
||||||
|
val options = RequestOptions()
|
||||||
|
.format(DecodeFormat.PREFER_ARGB_8888)
|
||||||
|
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||||
|
.fitCenter()
|
||||||
|
|
||||||
|
val builder = Glide.with(context)
|
||||||
|
.asBitmap()
|
||||||
|
.load(uri)
|
||||||
|
.apply(options)
|
||||||
|
.transform(RotateTransformation(-degrees))
|
||||||
|
.into(width, height)
|
||||||
|
|
||||||
|
return builder.get()
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,21 +0,0 @@
|
||||||
package com.simplemobiletools.gallery.pro.helpers
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.graphics.Bitmap
|
|
||||||
import android.net.Uri
|
|
||||||
import com.davemorrissey.labs.subscaleview.ImageDecoder
|
|
||||||
import com.squareup.picasso.MemoryPolicy
|
|
||||||
import com.squareup.picasso.Picasso
|
|
||||||
|
|
||||||
class PicassoDecoder(val tag: String, val picasso: Picasso, val degrees: Int) : ImageDecoder {
|
|
||||||
|
|
||||||
override fun decode(context: Context, uri: Uri): Bitmap {
|
|
||||||
return picasso
|
|
||||||
.load(uri)
|
|
||||||
.tag(tag)
|
|
||||||
.config(Bitmap.Config.ARGB_8888)
|
|
||||||
.memoryPolicy(MemoryPolicy.NO_CACHE)
|
|
||||||
.rotate(-degrees.toFloat())
|
|
||||||
.get()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.simplemobiletools.gallery.pro.helpers
|
||||||
|
|
||||||
|
import android.graphics.Bitmap
|
||||||
|
import android.graphics.Matrix
|
||||||
|
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool
|
||||||
|
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation
|
||||||
|
import java.security.MessageDigest
|
||||||
|
|
||||||
|
class RotateTransformation(var degrees: Int) : BitmapTransformation() {
|
||||||
|
override fun updateDiskCacheKey(messageDigest: MessageDigest) {}
|
||||||
|
|
||||||
|
override fun transform(pool: BitmapPool, toTransform: Bitmap, outWidth: Int, outHeight: Int): Bitmap {
|
||||||
|
val matrix = Matrix()
|
||||||
|
matrix.postRotate(degrees.toFloat())
|
||||||
|
return Bitmap.createBitmap(toTransform, 0, 0, toTransform.width, toTransform.height, matrix, true)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue