Jump to content
  • Advertisement

Archived

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

guitarman

DX7 Color Keying

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

Could someone help me with how to apply a DDCOLORKEY in DrectDraw7? I don''t want to use ''ddutil.h'' from the SDK, either. I''ll get a better understanding of what is going on if I type the code. I''m VERY new to color conversion (I don''t really know anything about it). I have some functions set up to load a bitmap and draw it on screen. I need help getting started with transparency. Thanks. #define Jesus 1

Share this post


Link to post
Share on other sites
Advertisement
If I can make a suggestion....you mentioned ddutil.h so you probably know that there is a function DDSetColorKey(), if you open ddutil.cpp and look at the code I''m sure you can figure out how it works, for me the best way to learn is by myself. If you still can''t figure it out from there then maybe I can look at it myself and try to explain it, but I bet if you take a few minutes and look at it you''ll figure it out.

Share this post


Link to post
Share on other sites
I looked at the code. Everything seemed fine until I got to the part about color conversion. I don''t understand this yet. I know to use IDirectDrawSurface7::SetColorKey(), but I don''t know how to setup my surface requirements, or the DDCOLORKEY structure to use the color key. Is there a DDBLTFX structure involved?

#define Jesus 1

Share this post


Link to post
Share on other sites
I''m not at my computer right now, but when I get home I''ll post my code for you. It''s not that hard. I would post it now, but I can''t remember it all exactly and I don''t want to give you buggy code .



"We are the music makers, and we are the dreamers of the dreams."
- Willy Wonka

Share this post


Link to post
Share on other sites
Ok, here I am again as promised. This code just tests if the graphics card uses 565 format (most do) and takes the color and transforms it if necessary.

BOOL Is565()
{
DDPIXELFORMAT ddpf;

ddpf.dwSize = sizeof(ddpf);

lpDDSfront->GetPixelFormat(&ddpf);

if (ddpf.dwGBitMask==0x07E0) // it''s 565
return TRUE;

else // it''s 555
return FALSE;
}

void SetColorKey(DWORD color)
{
DDCOLORKEY ddcolorkey;

if (Is565())
{
color = ((GetBValue(color)>>3)|
((GetGValue(color)>>2)<<5)|
((GetRValue(color)>>3)<<11));
}

ddcolorkey.dwColorSpaceLowValue = color;
ddcolorkey.dwColorSpaceHighValue = color;

surf->SetColorKey(DDCKEY_SRCBLT, &ddcolorkey);
}


Boom, that''s all. just call SetColorKey() with the parameter as RGB(0,0,0) for black, or RGB(255,0,0) for red, etc. Hope that helps you.



"We are the music makers, and we are the dreamers of the dreams."
- Willy Wonka

Share this post


Link to post
Share on other sites
Off the top of my head:
color is the color you want to be transparent.

DDCOLORKEY key;
key.dwColorSpaceLowValue = color;
key.dwColorSpaceHighValue = color;

lpdds->SetColorKey(DDCKEY_SRCBLT, &key);


and to blit with a color key enabled:
lpdds is the source surface
lpddsback is the destination surface
destrect is the destination rectangle

lpddsback->Blt(&destrect, lpdds, NULL, DDBLT_KEYSRC|DDBLT_WAIT, NULL);





Just because you''re outnumbered doesn''t mean you''re wrong.


sharewaregames.20m.com

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!