Color Key Error

Started by
0 comments, last by Nullio 22 years, 5 months ago
  
#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?
Advertisement
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-

This topic is closed to new replies.

Advertisement