Vin*_*y99 7 android android-activity android-blur-effect android-renderscript
当我启动我的应用程序时,它会启动一个Activity应该有透明标题,并且背景中当前显示的任何内容都应该模糊.
我能够获得透明度.但我无法弄清楚如何模糊背景.例如,如果我从主屏幕启动应用程序,那么主屏幕应该是可见的但模糊了.
我有一个想法是使用Framebuffer来获取当前显示的数据,但是如何将其转换为位图,我可以使用它来绘制图像而不保存图像并直接使用数据.
我也知道我们可以通过按电源和音量按钮来截取屏幕截图.有没有人知道android中的代码在哪里?我的应用程序将具有系统访问权
如何模糊背景?
您可以使用RenderScript支持库中的可用
public class BlurBuilder {
private static final float BITMAP_SCALE = 0.4f;
private static final float BLUR_RADIUS = 7.5f;
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;
}
}
Run Code Online (Sandbox Code Playgroud)
查看此链接以获取更多详细信息
或者您可以使用模糊
有没有人知道android中的代码在哪里执行此操作?
有关拍摄应用程序屏幕截图的信息,请参见此链接