Android中实现毛玻璃效果的3种方法
最近在做一款叫叽叽的App(男银懂的),其中有一个功能需要对图片处理实现毛玻璃的特效
进过一番预研,找到了3中实现方案,其中各有优缺点:
1、如果系统的api在16以上,可以使用系统提供的方法直接处理图片
if(VERSION.SDK_INT>16){
Bitmapbitmap=sentBitmap.copy(sentBitmap.getConfig(),true);
finalRenderScriptrs=RenderScript.create(context); finalAllocationinput=Allocation.createFromBitmap(rs,sentBitmap,Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT); finalAllocationoutput=Allocation.createTyped(rs,input.getType()); finalScriptIntrinsicBlurscript=ScriptIntrinsicBlur.create(rs,Element.U8_4(rs)); script.setRadius(radius/*e.g.3.f*/); script.setInput(input); script.forEach(output); output.copyTo(bitmap); returnbitmap; }
热门推荐
10 广西考试祝福语结婚简短
11 猪年祝福语简短小孩
12 元旦祝福语送长辈简短
13 恭喜二宝祝福语简短
14 祝福语暖心话简短
15 国庆中秋祝福语简短兄弟
16 朋友订婚的祝福语简短
17 送弟弟中秋祝福语简短
18 爱生日祝福语简短独特