android颜色矩阵的使用

 //加法
//        ColorMatrix colorMatrix=new ColorMatrix(
//                new float[]{
//                        1,0,0,0,0,
//                        0,1,0,0,100,
//                        0,0,1,0,0,
//                        0,0,0,1,0,
//                }
//        );

//        //乘法---颜色增强
//        ColorMatrix colorMatrix=new ColorMatrix(
//                new float[]{
//                        1.2f,0,0,0,0,
//                        0,1.2f,0,0,0,
//                        0,0,1.2f,0,0,
//                        0,0,0,1.2f,0,
//                }
//        );

//        //反向效果
//        ColorMatrix colorMatrix=new ColorMatrix(
//                new float[]{
//                        -1,0,0,0,255,
//                        0,-1,0,0,255,
//                        0,0,-1,0,255,
//                        0,0,0,1,0,
//                }
//        );

        //黑白照片
//        去色原理:只要把RGB 三通道的色彩设置成一样,那么就会变成灰色
//        同时为了保存图像亮度不变,同一个通道里的R+G+B=1

//        ColorMatrix colorMatrix=new ColorMatrix(
//                new float[]{
//                        0.213f,0.715f,0.072f,0,0,
//                        0.213f,0.715f,0.072f,0,0,
//                        0.213f,0.715f,0.072f,0,0,
//                        0,0,0,1,0,
//                }
//        );

//发色效果---(比如红色和绿色调换)
//       ColorMatrix colorMatrix=new ColorMatrix(
//                new float[]{
//                        0,1,0,0,0,
//                        1,0,0,0,0,
//                        0,0,1,0,0,
//                        0,0,0,1,0,
//                }
//        );

//        复古效果
//        ColorMatrix colorMatrix=new ColorMatrix(
//                new float[]{
//                        1/2f,1/2f,1/2f,0,0,
//                        1/3f,1/3f,1/3f,0,0,
//                        1/4f,1/4f,1/4f,0,0,
//                        0,0,0,1,0,
//                }
//        );

//颜色通道过滤
//               ColorMatrix colorMatrix=new ColorMatrix(
//                new float[]{
//                        1,0,0,0,0,
//                        0,0,0,0,0,
//                        0,0,0,0,0,
//                        0,0,0,1,0,
//                }
//        );

        ColorMatrix colorMatrix=new ColorMatrix();
        //颜色增强
//        colorMatrix.setScale(1.2f,1.2f,1.2f,1.2f);
//         增加饱合度
//        colorMatrix.setSaturation(progress);
        //颜色旋转 0红色轴,1绿色轴,2蓝色轴,
          colorMatrix.setRotate(0,progress);
//        colorMatrix.setConcat();
//        mPaint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));


        //LightingColorFilter只修改RGB值,不会修改透明度
        mPaint.setColorFilter(new LightingColorFilter(0x00ff00,0xff0000));

        //mPaint.setColorFilter(new PorterDuffColorFilter(Color.argb(255,140,90,200), PorterDuff.Mode.MULTIPLY));
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值