Created
February 26, 2015 19:58
-
-
Save peteristhegreat/0f0870497eda68bc99a4 to your computer and use it in GitHub Desktop.
Convert to and from 32 bit color to the Microsoft Safety Pallete (216) indexed colors.
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
// Generating a CLUT of the Microsoft Safety Pallete | |
// https://www.gidforums.com/t-21296.html | |
// Microsoft Safety Pallete | |
// https://msdn.microsoft.com/en-us/library/bb250466(VS.85).aspx | |
// Convert to indexed color | |
int index = (color.red()/51)*36 | |
+ (color.green()/51)*6 | |
+ color.blue()/51 | |
+ 20; | |
///////////////////////////////////// | |
// convert from indexed color | |
int r, g, b, temp; | |
temp = index - 20; | |
g = (temp%6)*51; | |
b = ((temp/6)%6)*51; | |
r = ((temp/36)%6)*51; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment