android 颜色叠加

颜色叠加

/**lmjssjj:add*/
    public static int creatANewColor(int color, int overlayColor, int alpha) {

        int r = Color.red(color);
        int g = Color.green(color);
        int b = Color.blue(color);

        int ovR = Color.red(overlayColor);
        int ovG = Color.green(overlayColor);
        int ovB = Color.blue(overlayColor);

        int newR = createColor(r, ovR, alpha);
        int newG = createColor(g, ovG, alpha);
        int newB = createColor(b, ovB, alpha);

        return Color.rgb(newR, newG, newB);
    }

    static int createColor(int color, int overlay, int alpha) {

        int newcolor = (int) (color * (1 - alpha) + overlay * alpha);

        return newcolor;
    }

你可能感兴趣的:(android)