~ 2 min read

Convert ARGB to Int Value (Java)

In some Java implementations/SDKs the Color class does not have the

int Color.argb(int, int, int, int)


One SDK that, as far as I know, does not have this method is the [link id='75' text='BlackBerry SDK'].

This code snippet can be used to perform just that:

public final class ColorBB {

    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 final int byteArrToInt(byte[] colorByteArr) {
        return (colorByteArr[0] << 24) + ((colorByteArr[1] & 0xFF) << 16) + ((colorByteArr[2] & 0xFF) << 8) + (colorByteArr[3] & 0xFF);

Let me know in the comments if you have any improvement/modification ideas.