Skip to content

Instantly share code, notes, and snippets.

View Bunkerbewohner's full-sized avatar

Mathias Kahl Bunkerbewohner

View GitHub Profile
@Bunkerbewohner
Bunkerbewohner / convert-color-to-single.cs
Created August 8, 2011 15:24
Converting Colour from four floats / bytes to one single (float)
/// <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);