Implementation of the filter effect under Android
Filter filter color has been implemented, the simple version can be implemented by the following code 3 parameters of black and white, red, green ... 7 Kinds of filtering (7 combinations of RGB).
Theoretically, it can be filtered to any color. You can adjust the ratio of the blend results.
public void Drawbitmap (canvas canvas, Bitmap Bitmap, Boolean R, Boolean g, Boolean B) {
ColorMatrix cm = new ColorMatrix ();
float[] m = Cm.getarray ();
Setcolorfiltermatrix (M, R, G, b);
Paint pt = new paint ();
Pt.setcolorfilter (new Colormatrixcolorfilter (cm));
Canvas.drawbitmap (bitmap, 0, 0, PT);
}
public void Setcolorfiltermatrix (float[] m, Boolean R, Boolean g, Boolean B) {
Final float R = 0.213f;
Final float G = 0.715f;
Final float B = 0.072f;
M[0] = 0;
M[6] = 0;
M[12] = 0;
if (r) {
M[0] = R; M[1] = G; M[2] = B;
}
if (g) {
M[5] = R; M[6] = G; M[7] = B;
}
if (b) {
M[10] = R; M[11] = G; M[12] = B;
}
}
Implementation of the filter effect under Android