【发布时间】:2016-04-14 21:00:59
【问题描述】:
对于我的项目,我想使用模糊背景。当我使用以下方法时,它会模糊我的背景,但它对我来说不够模糊,我想做更多模糊的背景。我将半径设置为其最大值25.有人可以帮帮我吗?
private static final float BITMAP_SCALE = 0.9f;
private static final float BLUR_RADIUS = 25.0f;
public static Bitmap blur(Context context, Bitmap image) {
int width = Math.round(image.getWidth() * BITMAP_SCALE);
int height = Math.round(image.getHeight() * BITMAP_SCALE);
Bitmap inputBitmap = Bitmap.createScaledBitmap(image, width, height, false);
Bitmap outputBitmap = Bitmap.createBitmap(inputBitmap);
RenderScript rs = RenderScript.create(context);
ScriptIntrinsicBlur theIntrinsic = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
Allocation tmpIn = Allocation.createFromBitmap(rs, inputBitmap);
Allocation tmpOut = Allocation.createFromBitmap(rs, outputBitmap);
theIntrinsic.setRadius(BLUR_RADIUS);
theIntrinsic.setInput(tmpIn);
theIntrinsic.forEach(tmpOut);
tmpOut.copyTo(outputBitmap);
return outputBitmap;
}
【问题讨论】:
-
你有什么解决办法吗?
标签: android background android-drawable blur blurry