#### Archived

This topic is now archived and is closed to further replies.

# Color Key Error

This topic is 6073 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

  #define _RGB16BIT565(r,g,b) ((b%32) + ((g%64) << 6) + ((r%32) << 11)) color_key.dwColorSpaceLowValue = _RGB16BIT565(0,0,254) color_key.dwColorSpaceHighValue = _RGB16BIT565(0,0,254) lpddSurface->SetColorKey(DDCKEY_SRCBLT, &color_key) 
this should set the color key of lpddSurface to Blue (well almost blue) right??? it don''t work, but when I set the LowValue and HighValue to 0 and adjust my images background color to black it works?? why is this???? _RGB16BIT565(0,0,254) would be the same color value as paint shops Red - 0 Green - 0 Blue - 254 right?

##### Share on other sites
254 % 32 = 30..

Depending on your bitmap loader you could get a different result (31 would get you closer to 254 than 30 would). I think the problem lies in your macro. The % is modulo. Closer to what you want (but not quite) is :

#define _RGB16BIT565(r,g,b) ((b) / 8 + (((g) / 4) << 6) + (((r) / 8) << 11))

That way, the colourkey should give you 248, rather than 240.

-Morten-

• 17
• 11
• 15
• 9
• 49
• ### Forum Statistics

• Total Topics
631393
• Total Posts
2999774
×