0

I am using DirectDraw to make a game and I am running it in 8-bit color mode. What I am having a problem with is making a macro to convert RGB values into a single 8-bit color.
Here is the macro:

#define RGB_8BIT(r, g, b) ((r & 224) + ((g & 224) >> 3) + (b >> 6))

Here's my setPixel function:

VOID setPixel(INT x, INT y, BYTE color)
{
	lpScreen[x + y * lPitch] = color;
}

lpScreen is defined as an array of BYTEs.
And here is the implementation in WinMain:

setPixel(0, 0, RGB_8BIT(255, 0, 0));

For some reason, this comes out as a greenish-blue when it should be pure red.

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by chaosprime
0

Ooops, I just found out that 8-bit mode has to be palletized, so the macro is actually coming up with an arbitrary index to a color in the default pallet.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.