Skip to content

Instantly share code, notes, and snippets.

@brunodoamaral
Created March 14, 2015 21:55
Show Gist options
  • Save brunodoamaral/3b03ddd293aab96779e8 to your computer and use it in GitHub Desktop.
Save brunodoamaral/3b03ddd293aab96779e8 to your computer and use it in GitHub Desktop.
Java code to convert a float RGB to int RGB
// Convert a float RGB to int RGB. Note: does not check for floats outside range (0..1)
public static int rgbFloatToInt(float r, float g, float b) {
return ((int) (0xff * b)) | (((int) (0xff * g)) << 8 ) | (((int) (0xff * r)) << 16 ) ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment