用 Renderscript 实现高效率的图片模糊效果
来源:互联网 发布:屏幕修复软件 编辑:程序博客网 时间:2024/06/08 03:03
转自:http://blog.chengyunfeng.com/?p=596
Android Api 11 中 引入的 Renderscript 可以用 GPU 来提高图片处理的速度,而在 API 17(4.2.1) 中,Renderscript 把一些常用的图片处理功能添加到系统中了,这些功能被称之为 Intrinsics 。包含 图片 模糊、混合、Matrix Convolution (矩阵卷积) 等常用操作。
下面是一个使用 ScriptIntrinsicBlur 来实现图片模糊的示例:
public Bitmap blurBitmap(Bitmap bitmap){//Let's create an empty bitmap with the same size of the bitmap we want to blurBitmap outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);//Instantiate a new RenderscriptRenderScript rs = RenderScript.create(getApplicationContext());//Create an Intrinsic Blur Script using the RenderscriptScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));//Create the Allocations (in/out) with the Renderscript and the in/out bitmapsAllocation allIn = Allocation.createFromBitmap(rs, bitmap);Allocation allOut = Allocation.createFromBitmap(rs, outBitmap);//Set the radius of the blurblurScript.setRadius(25.f);//Perform the RenderscriptblurScript.setInput(allIn);blurScript.forEach(allOut);//Copy the final bitmap created by the out Allocation to the outBitmapallOut.copyTo(outBitmap);//recycle the original bitmapbitmap.recycle();//After finishing everything, we destroy the Renderscript.rs.destroy();return outBitmap;}
效果:
Intrinsic 包含的功能列表:
Table 1. RenderScript intrinsics and the operations they provide.
ScriptIntrinsicConvolve3x3
,ScriptIntrinsicConvolve5x5
执行 3×3 或者 5×5 convolution(卷积)ScriptIntrinsicBlur
执行高斯模糊。支持 grayscale (灰度) 和 RGBA 缓冲,系统也使用该功能来绘制图形的阴影。ScriptIntrinsicYuvToRGB
把 YUV 缓冲 内容 转换为 RGB。通常用来处理相机数据ScriptIntrinsicColorMatrix
在缓冲中应用一个 4×4 颜色矩阵(color matrix)ScriptIntrinsicBlend
有多种方式来可以来混个两个图片ScriptIntrinsicLUT
Applies a per-channel lookup table to a buffer.ScriptIntrinsic3DLUT
Applies a color cube with interpolation to a buffer.参考内容
https://gist.github.com/Mariuxtheone/903c35b4927c0df18cf8
http://android-developers.blogspot.it/2013/08/renderscript-intrinsics.html
http://android-developers.blogspot.it/2011/02/introducing-renderscript.html
http://android-developers.blogspot.it/2011/03/renderscript.html
advance:
http://trickyandroid.com/advanced-blurring-techniques/
https://github.com/PomepuyN/BlurEffectForAndroidDesign
- 用 Renderscript 实现高效率的图片模糊效果
- RenderScript----Android图片模糊效果的简单实现
- Android:用RenderScript实现模糊效果
- Android RenderScript 简单高效实现图片的高斯模糊效果
- Android利用RenderScript对图片处理实现高斯模糊效果。
- RenderScript-图片的高斯模糊
- RenderScript模糊图片
- 使用RenderScript实现高斯模糊(毛玻璃/磨砂)效果
- 使用RenderScript实现高斯模糊(毛玻璃/磨砂)效果
- RenderScript应用(四)实现相机模糊切换效果
- RenderScript对图片模糊处理
- renderScript实现图片处理雾化效果 浮雕效果
- 图片高斯模糊效果的实现
- IOS实现图片的模糊效果
- Android模糊一张图片的简单方法之RenderScript
- Android磨皮算法的实现 renderScript实现表面模糊
- 用javascript怎样实现图片模糊效果
- 动态实现图片模糊效果
- Scheme 48 Development Tools (SDT)
- 环境: Ubuntu下 Cesiumjs 调试环境配置 (著名的三维虚拟地球开源项目)
- hdu2018母牛的故事
- [Linux] 在 Linux CLI 使用 ssh-keygen 生成 RSA 密钥
- bash,awk,sed
- 用 Renderscript 实现高效率的图片模糊效果
- hdu5025 状态压缩广搜
- Wi-Fi Direct ,让 DLNA 如虎添翼
- 2015阿里巴巴校招杭州java研发面经(初面)
- [Linux] 在 Linux CLI 使用 ssh-keygen 生成 RSA 密钥
- android快速开发xUtils框架
- JavaScript中 属性
- JAVA连接MYSQL,查询 ,添加,删除,语句
- python 2.5版yield之学习心得