Answers for "int to RGB color in Java"

1

java rgb color to int

//If your RGB values are in form of a float percentage between 
//0 and 1 consider the following method:

public int getIntFromColor(float Red, float Green, float Blue){
    int R = Math.round(255 * Red);
    int G = Math.round(255 * Green);
    int B = Math.round(255 * Blue);

    R = (R << 16) & 0x00FF0000;
    G = (G << 8) & 0x0000FF00;
    B = B & 0x000000FF;

    return 0xFF000000 | R | G | B;
}
Posted by: Guest on January-25-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language