ComposeShader组合渲染
来源:互联网 发布:赈灾晚会的数据统计 编辑:程序博客网 时间:2024/04/30 11:03
public ComposeShader(Shader shaderA,Shader shaderB, Xfermode mode)
Parameters
public ComposeShader(Shader shaderA,Shader shaderB, PorterDuff.Mode mode)
Parameters
主要代码:
public class ComposeShaderActivity extends Activity { ImageView image,image2,image3,image4; int width,height; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); image = (ImageView) findViewById(R.id.image); image2 = (ImageView) findViewById(R.id.image2); image3 = (ImageView) findViewById(R.id.image3); image4 = (ImageView) findViewById(R.id.image4); width = ValueUtil.dp2px(this, 120); height = ValueUtil.dp2px(this, 120); Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.tupian); Bitmap bitmapTemp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmapTemp); // 创建BitmapShader对象 BitmapShader mBitmapShader = new BitmapShader(bitmap, Shader.TileMode.MIRROR, Shader.TileMode.MIRROR); // 创建LinearGradient并设置渐变颜色数组,平铺效果为镜像 LinearGradient mLinearGradient = new LinearGradient(0, 0, 0, height, new int[] { Color.WHITE, Color.LTGRAY, Color.TRANSPARENT, Color.GREEN }, null, Shader.TileMode.MIRROR); // 混合渲染 将两个效果叠加,使用PorterDuff叠加模式 ComposeShader mComposeShader = new ComposeShader(mBitmapShader, mLinearGradient, PorterDuff.Mode.MULTIPLY); Paint paint = new Paint(); paint.setShader(mComposeShader); canvas.drawRect(new RectF(0, 0, width, height), paint); image.setImageBitmap(bitmapTemp); }}
效果图:
参考资料:http://blog.csdn.net/t12x3456/article/details/10366131
源码:http://yunpan.cn/c3f2qgcVtNSwP (提取码:2ccf)
0 0
- ComposeShader组合渲染
- Android 颜色渲染(十) ComposeShader组合渲染
- Android 颜色渲染(十) ComposeShader组合渲染
- Android 颜色渲染(十) ComposeShader组合渲染
- Android 颜色渲染(十) ComposeShader组合渲染
- ComposeShader混合渲染
- Android中的自绘View的那些事儿(四)之 ComposeShader组合渲染器的简介
- Android Paint 之 ComposeShader 组合图片
- JComboBox 组合框条目渲染(JComboBox添加对象选项)
- JComboBox 组合框条目渲染(JComboBox添加对象选项)
- 渲染
- 渲染
- 渲染
- 渲染
- 组合
- 组合
- 组合
- 组合
- 简单理解Java异常处理机制
- PHP的常量及变量
- [LeetCode-88] Merge Sorted Array(合并有序数组)
- KNN的MATLAB实现
- 【LeetCode从零单刷】Gray Code
- ComposeShader组合渲染
- android入门(八) 状态栏通知(消息推送) Notification
- GIT问题,error:src refspec master does not match any
- Apache CXF 学习资料整理
- 注册5年了,第一次写博客。
- hdu 5446 Unknown Treasure 2015 长春网络赛 组合数对大合数取模 数论
- 关系代数基本运算
- HDU-2955 Robberies
- STL之set_union、set_intersection、set_difference、set_symmetric_difference