Created
May 2, 2013 04:47
-
-
Save dend/5500196 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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