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;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-3 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2026 源码网商城 (www.yuanmawang.com) 版权所有