예제 #1
0
 /*
 本程序中大概耗时为20-30毫秒
  */
 private Bitmap blurBitmap(Bitmap bitmap, int radius) {
   RenderScript rs = RenderScript.create(this);
   Allocation overlayAlloc = Allocation.createFromBitmap(rs, bitmap);
   ScriptIntrinsicBlur blur = ScriptIntrinsicBlur.create(rs, overlayAlloc.getElement());
   blur.setInput(overlayAlloc);
   blur.setRadius(radius);
   blur.forEach(overlayAlloc);
   overlayAlloc.copyTo(bitmap);
   rs.destroy();
   return bitmap;
 }
예제 #2
0
  @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
  @Override
  protected Bitmap blur(Bitmap bitmap, int radius) {
    RenderScript rs = RenderScript.create(getActivity());
    Allocation overlayAlloc = Allocation.createFromBitmap(rs, bitmap);
    ScriptIntrinsicBlur blur = ScriptIntrinsicBlur.create(rs, overlayAlloc.getElement());

    blur.setInput(overlayAlloc);
    blur.setRadius(radius);
    blur.forEach(overlayAlloc);

    overlayAlloc.copyTo(bitmap);
    rs.destroy();
    return bitmap;
  }