Skip to content

Instantly share code, notes, and snippets.

@clooth
Created September 19, 2013 01:25
Show Gist options
  • Save clooth/6618021 to your computer and use it in GitHub Desktop.
Save clooth/6618021 to your computer and use it in GitHub Desktop.
long colorFromHexString(std::string hexString)
{
return strtol(hexString.c_str(), NULL, 16);
}
std::vector<Uint32> rgbFromColor(long colorValue)
{
std::vector<Uint32> rgb;
// Red, Green, Blue
rgb.push_back((colorValue & 0xff0000) >> 16);
rgb.push_back((colorValue & 0x00ff00));
rgb.push_back((colorValue & 0x0000ff));
for( std::vector<Uint32>::const_iterator i = rgb.begin(); i != rgb.end(); ++i)
std::cout << *i << ' ';
std::cout << std::endl;
return rgb;
}
std::vector<Uint32> rgbFromHexString(std::string hexString)
{
long color = colorFromHexString(hexString);
return rgbFromColor(color);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment