转自:http://blog.chengyunfeng.com/?p=596
Android Api 11 中 引入的 Renderscript 可以用 GPU 来提高图片处理的速度,而在 API 17(4.2.1) 中,Renderscript 把一些常用的图片处理功能添加到系统中了,这些功能被称之为 Intrinsics 。包含 图片 模糊、混合、Matrix Convolution (矩阵卷积) 等常用操作。
下面是一个使用 ScriptIntrinsicBlur 来实现图片模糊的示例:
1234567891011121314151617181920212223242526272829303132333435 |
|
效果:
Intrinsic 包含的功能列表:
Table 1. RenderScript intrinsics and the operations they provide.
Name | Operation |
---|---|
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