LightingColorFilter笔记
来源:互联网 发布:头发定型喷雾推荐知乎 编辑:程序博客网 时间:2024/05/21 15:42
今天在http://stackoverflow.com网站上看到了别人修改button的颜色,点击效果什么的,
突然看到可以用
button.getBackground().setColorFilter(new LightingColorFilter(0xFFFFFFFF, 0xFFAA0000));
以前没用到过LightingColorFilter这个类 ,google了下,
因为是基于三基色配色方案来改的,@Override protected void onDraw(Canvas canvas) { int mul = 0xFFFFFF00; //remove BLUE component int add = 0x0000FF00; //set GREEN full LightingColorFilter lightingColorFilter = new LightingColorFilter(mul, add); Paint MyPaint_Normal = new Paint(); Paint MyPaint_Lighting = new Paint(); MyPaint_Lighting.setColorFilter(lightingColorFilter); Bitmap myBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); canvas.drawBitmap(myBitmap, 400, 100, MyPaint_Normal); canvas.drawBitmap(myBitmap, 500, 100, MyPaint_Lighting); };
而且0xFFFFFF00 0x表示16进制数,前两个ff表示的是透明度,00-ff,接下来两个ff表示红R,00-ff,后面两个ff表示绿G,00-ff,最后两个ff表示蓝B,00-ff,
所以呢
int mul = 0xFFFFFF00; //remove BLUE component 移除蓝色B部分,可以根据三基色配色图看
int add = 0x0000FF00; //set GREEN full 绿色的填满,差不多就这个意思了。。。
具体的还可以去测试下
float[] colorMatrix = { 1, 0, 0, 0, 0, //red 0, 0, 0, 0, 0, //green 0, 0, 0, 0, 0, //blue 0, 0, 0, 1, 0 //alpha }; Paint MyPaint = new Paint(); ColorFilter colorFilter = new ColorMatrixColorFilter(colorMatrix); MyPaint.setColorFilter(colorFilter); Bitmap myBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); canvas.drawBitmap(myBitmap, 100, 100, MyPaint); };
这个画出来的效果就是红色和黑色了,因为不透明,这个是color矩阵的用法,不太懂矩阵。。。。。。
- LightingColorFilter笔记
- Android LightingColorFilter 模拟简单的光照效果的
- 自定义控件(3)---LightingColorFilter光照颜色过滤器--Selector的效果
- 自定义View之RGB颜色变化Paint画笔颜色过滤器setColorFilter,LightingColorFilter光照过滤器
- 笔记
- 笔记
- 笔记
- 笔记
- 笔记
- 笔记
- 笔记
- 笔记
- 笔记
- 笔记
- 笔记
- 笔记
- 笔记
- 笔记
- flashback的用法
- java设计模式笔记之单例模式
- 优秀程序员的十个习惯
- 分分分
- oracle 一个字段做为分组条件,另一个字段的最大值为查询条件
- LightingColorFilter笔记
- ubuntu虚机安装monit和agent模块
- 【分享】Stanford Dataset全集之Social networks
- CTreeCtrl的HitTest用法
- JAVA之包装类Double详解
- wlan全解析
- ASN.1介绍
- (x)html+javascript学习笔记-[select标签]
- c语言的union和大小端模式