Archived

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

Nullio

Color Key Error

Recommended Posts

Nullio    122
  
#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 this post


Link to post
Share on other sites
Morten    139
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-

Share this post


Link to post
Share on other sites