I want to write a console-like gui for a game, and I start with a real console. So I have a class that specifies the colors. Now I want to convert consolecolor to rgb (24-bit) and the other way round. I have tried this:
int d = (((int)col & 8) != 0) ? 255 : 128;
r = (((int)col & 4) != 0) ? d : 0;
g = (((int)col & 2) != 0) ? d : 0;
b = (((int)col & 1) != 0) ? d : 0;
4-Bit colors have this bit-scheme: drgb. When d is 0, the color will be dark; if it's 1, the color will be bright and the rgb values will be 255. My problem is: Color 1000 (bright black) and Color 0111 (dark white) are black and gray in my program. They should be darkgray and lightgray. And how to convert the colors back with rounding and not just converting specific colors back?