Android 图片高期模糊处理

来源:互联网 发布:软件测试的主要内容 编辑:程序博客网 时间:2024/05/01 18:55
调这一个方法搞定:::
/** * 图片模糊 * * @param bitmap * @return */@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)public Bitmap blurBitmap(Bitmap bitmap) {    //Let's create an empty bitmap with the same size of the bitmap we want to blur    Bitmap outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);    //Instantiate a new Renderscript    RenderScript rs = RenderScript.create(getActivity());    //Create an Intrinsic Blur Script using the Renderscript    ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));    //Create the Allocations (in/out) with the Renderscript and the in/out bitmaps    Allocation allIn = Allocation.createFromBitmap(rs, bitmap);    Allocation allOut = Allocation.createFromBitmap(rs, outBitmap);    //Set the radius of the blur    blurScript.setRadius(25.f);    //Perform the Renderscript    blurScript.setInput(allIn);    blurScript.forEach(allOut);    //Copy the final bitmap created by the out Allocation to the outBitmap    allOut.copyTo(outBitmap);    //recycle the original bitmap    bitmap.recycle();    //After finishing everything, we destroy the Renderscript.    rs.destroy();    return outBitmap;}
0 0
原创粉丝点击