Get 32 bit rgb value (ignoring alpha) based ints representing r,g and b each in range (0-255) - Java 2D Graphics

Java examples for 2D Graphics:Color RGB

Description

Get 32 bit rgb value (ignoring alpha) based ints representing r,g and b each in range (0-255)

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        int r = 2;
        int g = 2;
        int b = 2;
        System.out.println(getRGB(r, g, b));
    }//from  www  . ja v  a 2 s  . c  o  m

    /**
     * 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;
    }
}

Related Tutorials