From 59b968a6539c3dcdb171483d94ab51c367bcbeef Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 13:17:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/help/BlurTransformation.kt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/BlurTransformation.kt b/app/src/main/java/io/legado/app/help/BlurTransformation.kt index fec7d0eef..4493228c4 100644 --- a/app/src/main/java/io/legado/app/help/BlurTransformation.kt +++ b/app/src/main/java/io/legado/app/help/BlurTransformation.kt @@ -8,10 +8,8 @@ import android.renderscript.Allocation import android.renderscript.Element import android.renderscript.RenderScript import android.renderscript.ScriptIntrinsicBlur - import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool -import com.bumptech.glide.load.resource.bitmap.BitmapTransformation - +import com.bumptech.glide.load.resource.bitmap.CenterCrop import java.security.MessageDigest import kotlin.math.min import kotlin.math.roundToInt @@ -21,15 +19,16 @@ import kotlin.math.roundToInt * 模糊 * @radius: 0..25 */ -class BlurTransformation(context: Context, private val radius: Int) : BitmapTransformation() { +class BlurTransformation(context: Context, private val radius: Int) : CenterCrop() { private val rs: RenderScript = RenderScript.create(context) @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) override fun transform(pool: BitmapPool, toTransform: Bitmap, outWidth: Int, outHeight: Int): Bitmap { + val transform = super.transform(pool, toTransform, outWidth, outHeight) //图片缩小1/2 - val width = (min(outWidth, toTransform.width) / 2f).roundToInt() - val height = (min(outHeight, toTransform.height) / 2f).roundToInt() - val blurredBitmap = Bitmap.createScaledBitmap(toTransform, width, height, false); + val width = (min(outWidth, transform.width) / 2f).roundToInt() + val height = (min(outHeight, transform.height) / 2f).roundToInt() + val blurredBitmap = Bitmap.createScaledBitmap(transform, width, height, false); // Allocate memory for Renderscript to work with //分配用于渲染脚本的内存 val input = Allocation.createFromBitmap(