Created
September 19, 2013 01:25
-
-
Save clooth/6618021 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
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