From f9433c0f2838a7936eb95926fdc8b3cf20aa141f Mon Sep 17 00:00:00 2001 From: mochangsheng Date: Mon, 11 Feb 2019 09:45:34 +0800 Subject: [PATCH] fix blur RSInvalidStateException: bitmap_F16 for Samsung n9600 --- .../java/com/m4coding/coolhub/base/utils/ImageUtils.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules_base/base/src/main/java/com/m4coding/coolhub/base/utils/ImageUtils.java b/modules_base/base/src/main/java/com/m4coding/coolhub/base/utils/ImageUtils.java index 50965b7..cae61ef 100755 --- a/modules_base/base/src/main/java/com/m4coding/coolhub/base/utils/ImageUtils.java +++ b/modules_base/base/src/main/java/com/m4coding/coolhub/base/utils/ImageUtils.java @@ -10,6 +10,7 @@ import android.os.Build; import android.renderscript.Allocation; import android.renderscript.Element; +import android.renderscript.RSInvalidStateException; import android.renderscript.RenderScript; import android.renderscript.ScriptIntrinsicBlur; import android.support.annotation.FloatRange; @@ -130,6 +131,10 @@ public static Bitmap renderScriptBlur(final Bitmap src, blurScript.setRadius(radius); blurScript.forEach(output); output.copyTo(ret); + } catch (RSInvalidStateException e){ + //捕捉异常,避免Bad bitmap type: RGBA_F16 在三星 SM N9600 android9.0出现过 + e.printStackTrace(); + ret = stackBlur(src, (int) radius, recycle); } finally { if (rs != null) { rs.destroy();