a-b-c-d-e —-代表R—-红色
f-g-h-i-j—–代表G—-绿色
k-l-m-n-o—–代表B—-蓝色
p-q-r-s-t —–代表A—-透明
上边的最后一个字母,即ejot代表每个分量的offset,即偏移量。
调整上边的参数实在太麻烦,我们平时常用的仅3个值,色调,饱和度,亮度,so 系统有ColorMatrix 类来控制。
//色调 第二个参数为需要处理的参数
ColorMatrix hueMatrix=new ColorMatrix();
hueMatrix.setRotate(0,hue0);//0代表R
hueMatrix.setRotate(1,hue1);//1代表G
hueMatrix.setRotate(2,hue2;//2代表B
//饱和度
Colormatrix saturationMatrix =new ColorMatrix();
saturationMatrix.setSaturation(saturation);//为0时为灰度图像
//亮度
ColorMatrix lumMatrix=new ColorMatrix();
//float rScale, float gScale, float bScale,float aScale
lumMatrix.setScale(lum,lum,lum,1);//当参数为0时图像全黑
//统一处理
ColorMatrix imageMatrix = new ColorMatrix();
imageMatrix.postConcat(hueMatrix);
imageMatrix.postConcat(saturationMatrix);
imageMatrix.postConcat(lumMatrix);
//重绘此图像
paint.setColorFilter(new ColorMatrixColorFilter(imageMatrix));
canvas.drawBitmap(bm, 0, 0, paint);