1.build.gradle 配置:

android {    defaultConfig {        renderscriptTargetApi 19        renderscriptSupportModeEnabled true    }}

2.使用如下代码:

public class BlurBuilder {    private static final float BITMAP_SCALE = 0.2f;    private static final float BLUR_RADIUS = 15f;    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;    }}

更多相关文章

  1. Android(安卓)获取屏幕分辨率
  2. Failed to install the following Android(安卓)SDK packages as
  3. android mvvm databinding在dialog中的使用
  4. Android(安卓)Studio AIDL进行IPC通信的使用步骤
  5. Android(安卓)AsyncTask 异步任务取消
  6. Android中MAC地址获取代码
  7. 箭头函数的基础使用
  8. NPM 和webpack 的基础使用
  9. Python list sort方法的具体使用

随机推荐

  1. 用JavaScript实现两种功能:1、切换全选/全
  2. 用jquery方法实现和并单元格
  3. 一天搞定HTML----标签类型与类型转换05
  4. 10段实用的HTML5代码
  5. 【HTML5】H5新标签大实例 可直接运行
  6. JAVA中JSP应用导出Excel报表的简单实现以
  7. 我似乎无法正确对齐这些图像
  8. 请问各位大牛,如何在html网页中插入统一的
  9. {{content}}液体标签未显示博客帖子
  10. CSS:浮动时忽略div高度