Website may be up and down over next few months. I'm currently doing a complete overhaul of everything. Going back to simple individual .htm pages, new overall site theme, sanitizing and cleaning up html of all pages and blog posts, attempting to implement a new tooling and publishing system etc etc.

/// <summary>
/// Packs color components into a <see cref="uint"/> type.
/// </summary>
/// <param name="r">The red component.</param>
/// <param name="g">The green component.</param>
/// <param name="b">The blue component.</param>
/// <param name="a">The alpha component.</param>
/// <returns>Returns a uint representing the color.</returns>
public static uint Pack(int r, int g, int b, int a)
{
    return (((uint)r & 0xff)) | (((uint)g & 0xff) << 8) | (((uint)b & 0xff) << 16) | (((uint)a & 0xff) << 24);
}

/// <summary>
/// Unpacks a <see cref="uint"/> type into a color type.
/// </summary>
/// <param name="value">The packed color value to unpack.</param>
/// <returns>Returns a color type from the unpacked values.</returns>
public static Color Unpack(uint value)
{
    var r = (byte)(value);
    var g = (byte)(value >> 8);
    var b = (byte)(value >> 16);
    var a = (byte)(value >> 24);

    return new Color(r, g, b, a);
}

Created by: X

Just another personal website in this crazy online world

Name of author Dean Lunz (aka Created by: X)
Computer programming nerd, and tech geek.
About Me -- Resume