国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android RenderScript高斯模糊

2019-12-12 04:34:59
字體:
來源:轉載
供稿:網友

看代碼的時候,看到了其中有.rs結尾的文件,不是很明白,還有RenderScript類,看的一臉蒙蔽,不知所云,然后百度了一下,收貨還真不少,這東西在圖形處理這塊用處挺大的。

今天先說說ScriptIntrinsicBlur,這個類不需要定義rs文件,從這個Intrinsic單詞可以看的出來,它是API17以后內置的類,專門用來處理圖像的,讓圖片變模糊。

public static Bitmap blurBitmap(Bitmap bitmap, float radius, Context context) {     //創建渲染腳本上下文     RenderScript rs = RenderScript.create(context);      //為位圖分配內存     Allocation allocation = Allocation.createFromBitmap(rs, bitmap);      Type t = allocation.getType();      //用同樣的類型創建內存,一般用這兩種方式創建 <span style="font-family: Arial, Helvetica, sans-serif;">Allocation</span>     Allocation blurredAllocation = Allocation.createTyped(rs, t);      //創建高斯渲染腳本      ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));     //設置模糊半徑 (maximum 25.0)     blurScript.setRadius(radius);     //為腳本設置輸入參數      blurScript.setInput(allocation);     //調用腳本 結果存入 <span style="font-family: Arial, Helvetica, sans-serif;">blurredAllocation中</span>     blurScript.forEach(blurredAllocation);      //把腳本結果存入位圖中 因為為native層渲染,所以結果需要復制到上層     blurredAllocation.copyTo(bitmap);      //Destroy everything to free memory     allocation.destroy();     blurredAllocation.destroy();     blurScript.destroy();     t.destroy();      return bitmap;   } 

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 邢台市| 曲靖市| 南江县| 保亭| 五常市| 桐城市| 乐亭县| 林州市| 彭州市| 辽宁省| 乡宁县| 红桥区| 曲阳县| 通化县| 阳高县| 班戈县| 德江县| 正蓝旗| 东乡族自治县| 潜江市| 侯马市| 蒙阴县| 岗巴县| 迭部县| 榆林市| 九龙城区| 西峡县| 常德市| 景泰县| 南宫市| 雷山县| 江孜县| 兴国县| 扎鲁特旗| 崇文区| 沙洋县| 合作市| 定州市| 鄂托克旗| 乐清市| 建湖县|