Jump to content
  • Advertisement

Archived

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

Moe

can't get color keying to work

This topic is 6564 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 have a simple direct draw 800*600 32bpp app running in fullscreen exclusive mode. I have bitmaps loaded onto 2 surfaces, one as a background and one as a cursor. I have the code for making the cursor bitmap appear at the correct mouse location, but I can''t get the color keying for the cursor to work. I want it so that the black square around the cursor isn''t there. I figured I would use source colro keying. Here is the code I am using to set the color key: //****do color keying here**** // get the pixel format DDPIXELFORMAT ddpf; ddpf.dwSize=sizeof(ddpf); lpddsprimary->GetPixelFormat(&ddpf); KeyColor = ddpf.dwGBitMask; // set color keys DDCOLORKEY key; key.dwColorSpaceLowValue = KeyColor; key.dwColorSpaceHighValue = KeyColor; lpcursor->SetColorKey(DDCKEY_SRCBLT, &key); lpddsback->SetColorKey(DDCKEY_SRCBLT, &key); Here is the code I use to blit the cursor: lpddsback->Blt(&cursor,lpcursor,NULL,DDBLT_WAIT | DDCKEY_SRCBLT,NULL); Now for some stupid wierd reason, the cursor bitmap doesn''t even appear. I have no idea and I am sick and tired of trying to make this stupid thing work. Can anyone here help me? Shrapnel Games

Share this post


Link to post
Share on other sites
Advertisement
key.dwColorSpaceLowValue = KeyColor;
key.dwColorSpaceHighValue = KeyColor;

I don''t remember at all. But you must specified only one (low or high), because if you give two value, this is only applied for chroma-key (many colors key).

So you code can be :
key.dwColorSpaceLowValue = KeyColor;

OR the next: (XOR)

key.dwColorSpaceHighValue = KeyColor;



-eng3d.softhome.net-

Share this post


Link to post
Share on other sites
hi -

I think you can try this and it may help

first:
DDCOLORKEY ddck;
// black color key
ddck.dwColorSpaceLowValue = RGB( 255, 255, 255 );
ddck.dwColorSpaceHighValue = RGB( 255, 255, 255 );
hret = DDSURFACE[numsurf]->SetColorKey( DDCKEY_SRCBLT, &ddck );
if ( FAILED( hret ) )
return Fail( hwnd, hret, "SetColorKey Failed" );

second:
lpddsback->Blt(&cursor,lpcursor,NULL,DDBLT_WAIT | DDBLT_KEYSRC,NULL);

I hope that helps

Share this post


Link to post
Share on other sites
Nope. Nothing there helped. How about someone post some source code (that works) of thiers on here. Maybe that could help. The DX SDK isn''t much help on this either.

Shrapnel Games

Share this post


Link to post
Share on other sites
The best way is to load your bitmap to a surface. Then lock the surface and read in the first value (which is normally the colour to be transparent) to a DWORD ''colour''(or whatever). Then just

key.dwColorSpaceLowValue = colour;
key.dwColorSpaceHighValue = colour;

Then set the colour key.

I think the problem is that your ''black'' may not be exactly 0,0,0. And yes, you do have to specify the low and high value.

Share this post


Link to post
Share on other sites
I don''t think that is the problem. Whenever I add the DDCKEY_SRCBLT to my Blt() function for the cursor bitmap, it disappears entirely.
Besides, I am pretty sure that my black is RGB(0,0,0). I used paint and took the black color in it and flood filled the areas I want keyed out. Not to mention I am using 32 bit color.

Shrapnel Games

Share this post


Link to post
Share on other sites
I don''t remember why but I create the (fullscreen) primary with:

ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT | DDSD_CKSRCBLT;

Maybe it''s the DDSD_CKSRCBLT flag...I think I had the same problem some time ago...

Share this post


Link to post
Share on other sites
I don' suppose you have the full source for the initialization of that program that you made that used that extra flag?
It still doesn't want to work properly. I see the background bitmap but not the cursor bitmap (again!!).
Shrapnel Games

Edited by - Moe on July 26, 2000 9:00:52 PM

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!