Archived

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

ColorKeying in 24bit

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

i''m trying to blit w/a color key, black works fine, i know its 0 on my palette
  
//TheSprite is my loaded sprite in a ddsurface


DDCOLORKEY clrkey;
clrkey.dwColorSpaceHighValue=255127000;
clrkey.dwColorSpaceLowValue=255127000;
TheSprite->SetColorKey(DDCKEY_SRCBLT ,NULL);
TheSprite->SetColorKey(DDCKEY_SRCBLT ,&clrkey);
[source]

i tried every combination of rgb, but it wont work

help?
Gil  
Micro$oft beta testing: "Does the splash screen works? SHIP IT!!!"

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

You are working in 24 bit?

Try this:



clrkey.dwColorSpaceHighValue=(255<<16)|(127<<8)|(0);
clrkey.dwColorSpaceLowValue=(255<<16)|(127<<8)|(0);



You can''t just put RRRGGGBBB. You have to convert your red, green, and blue values to an int, like this:


int colorcode = (red<<16)|(green<<8)|(blue);


This only works in 24 bit mode. You''ll need different formula for different bit depths.




Share this post


Link to post
Share on other sites
In the directx8 SDK you can also find the ddutil.cpp file (in duel, or in duelvoice) which has a function implemented called DDUtil_ColorMatch which will, (given a surface), determine the representation of a given color. It''s not terribly fast, so cache the value.

So:
  
DWORD dwColorKey = DDUtil_ColorMatch( pdds, RGB(255, 0, 255));

Share this post


Link to post
Share on other sites