Code example for ColorMatrix

Methods: getArray, postConcat, setRGB2YUV

0
 
        int r = Color.red(color);
        int g = Color.green(color);
        int b = Color.blue(color);
 
        ColorMatrix cm = new ColorMatrix();
        ColorMatrix tmp = new ColorMatrix();
 
        cm.setRGB2YUV();
        tmp.setRotate(0, deg);
        cm.postConcat(tmp);
        tmp.setYUV2RGB();
        cm.postConcat(tmp);
 
        final float[] a = cm.getArray();
 
        int ir = Math.round(a[0] * r +  a[1] * g +  a[2] * b);
        int ig = Math.round(a[5] * r +  a[6] * g +  a[7] * b);
        int ib = Math.round(a[10] * r + a[11] * g + a[12] * b);
 
        return Color.argb(Color.alpha(color), pinToByte(ir),pinToByte(ig), pinToByte(ib));