//加法 // 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));
android颜色矩阵的使用
最新推荐文章于 2022-03-27 19:17:16 发布