Jump to content
  • Advertisement


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


ColorKeying in 24bit

This topic is 6189 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

TheSprite->SetColorKey(DDCKEY_SRCBLT ,NULL);
TheSprite->SetColorKey(DDCKEY_SRCBLT ,&clrkey);

i tried every combination of rgb, but it wont work

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:


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.

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

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!