Java examples for 2D Graphics:Color RGB
Get 32 bit ARGB value based ints representing r,g, b, and a each in range (0-255)
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { int r = 2; int g = 2; int b = 2; int a = 2; System.out.println(getARGB(r, g, b, a)); }//from w ww .j a v a 2s . c om /** * Get 32 bit ARGB value based ints representing r,g, b, and a * each in range (0-255) * * @param r * @param g * @param b * @return */ public static int getARGB(int r, int g, int b, int a) { return (a << 24) + getRGB(r, g, b); } /** * Get 32 bit rgb value (ignoring alpha) based ints representing r,g and b * each in range (0-255) * * @param r * @param g * @param b * @return */ public static int getRGB(int r, int g, int b) { return (r << 16) + (g << 8) + b; } }