Created
August 8, 2011 15:24
-
-
Save Bunkerbewohner/1131947 to your computer and use it in GitHub Desktop.
Converting Colour from four floats / bytes to one single (float)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Transforms the 4 color bytes to a single float. | |
/// The resulting float might not be a valid float number; but only the bytes | |
/// are important for usage later on the graphics card | |
/// </summary> | |
/// <param name="color">Any color</param> | |
/// <returns>The four color bytes as one float</returns> | |
Single ConvertColorToSingle(Color color) | |
{ | |
byte[] bytes = BitConverter.GetBytes(((Color)color).PackedValue); | |
return BitConverter.ToSingle(bytes, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment