Create color from argb - Android Graphics

Android examples for Graphics:Color RGB Value

Description

Create color from argb

Demo Code


//package com.java2s;

public class Main {
    public static int argb(int R, int G, int B) {
        return argb(Byte.MAX_VALUE, R, G, B);
    }//from   www.j a  v a  2 s .  co m

    public static int argb(int A, int R, int G, int B) {
        byte[] colorByteArr = { (byte) A, (byte) R, (byte) G, (byte) B };
        return byteArrToInt(colorByteArr);
    }

    public static int byteArrToInt(byte[] colorByteArr) {
        return (colorByteArr[0] << 24) + ((colorByteArr[1] & 0xFF) << 16)
                + ((colorByteArr[2] & 0xFF) << 8)
                + (colorByteArr[3] & 0xFF);
    }
}

Related Tutorials