Skip to content

Instantly share code, notes, and snippets.

@dend
Created May 2, 2013 04:47
Show Gist options
  • Save dend/5500196 to your computer and use it in GitHub Desktop.
Save dend/5500196 to your computer and use it in GitHub Desktop.
using System;
namespace HEXtoARGB
{
class Program
{
static void Main(string[] args)
{
// Original ActionScript snippet from this question:
// http://stackoverflow.com/questions/2369746/actionscript-3-0-translating-hex-to-argb
// Assume this is a hex color. 0xff header block is
// standard for non-0 alpha channel values.
uint hexColor = 0xff0099ab;
uint a = (hexColor >> 0x18) & 0xff;
uint r = (hexColor >> 0x10) & 0xff;
uint g = (hexColor >> 0x08) & 0xff;
uint b = hexColor & 0xff;
Console.WriteLine("A: {0}, R: {1}, G: {2}, B: {3}",
a, r, g, b);
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment