java rgb color to int

Solutions on MaxInterview for java rgb color to int by the best coders in the world

showing results for - "java rgb color to int"
Vincenzo
04 Oct 2017
1//If your RGB values are in form of a float percentage between 
2//0 and 1 consider the following method:
3
4public int getIntFromColor(float Red, float Green, float Blue){
5    int R = Math.round(255 * Red);
6    int G = Math.round(255 * Green);
7    int B = Math.round(255 * Blue);
8
9    R = (R << 16) & 0x00FF0000;
10    G = (G << 8) & 0x0000FF00;
11    B = B & 0x000000FF;
12
13    return 0xFF000000 | R | G | B;
14}