Jump to content
  • Advertisement

Archived

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

reaptide

Direct Draw Color Keying

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

Hello everyone, I understand that there was a similair post ealier about the same topic, but I was unable to get any help from it. I am attempting to assign a color key to a surface for transparency purposes. Unfortunalty it doesn''t seem to be having any effect. I have posted the code below for everyone to see. The program is running in 640 X 480 X 16 display mode and my transparency color in the image is cyan (0, 255, 255). << Start Code >> lpDDSHappyFace = SSCreateSurface(64, 64); SSLoadImage(lpDDSHappyFace, "HFace.bmp"); DDCOLORKEY ddck; ddck.dwColorSpaceLowValue= RGB(0,255,255); ddck.dwColorSpaceHighValue= ddck.dwColorSpaceLowValue; lpDDSHappyFace->SetColorKey(DDCKEY_SRCBLT, &ddck); int bltx, blty; bltx = 0; blty = 0; while (blty <= 576) { SSClearSurface(lpDDSBack); lpDDSBack->BltFast(bltx, blty, lpDDSHappyFace, NULL, DDBLTFAST_SRCCOLORKEY / DDBLTFAST_WAIT); lpDDSPrimary->Flip(NULL, DDFLIP_WAIT); bltx += 16; blty += 8; } << End Code >> Everything but the color keying code is working and I''m stumped as to what''s going on. Anyone have any insite? Thanks for any help, Derek

Share this post


Link to post
Share on other sites
Advertisement
Because your color will never be (0,255,255) unless you use 24 bit color. With 16 bit color your key will be something like (0,252,248). That''s a total guess, BTW. You need to figure out how many bits are being used for R G and B.

For instance, if your card is using 565 (like mine) your bits are:

Red 11111 000000 00000
Gre 00000 111111 00000
Blu 00000 000000 11111

Ok, take green (111111) now make it 8-bit (11111100). This value is 252, not 255.

Share this post


Link to post
Share on other sites
Ah I see, can''t believe I didn''t remeber that. Thank you for the answer.

You wouldn''t happend to know if there is way to recieve the maximum color possible for each color range? I suppose it is possible to look at the surface Pixel Format.

Share this post


Link to post
Share on other sites
Yes, grab the pixel format from the primary surface and analyze the bits there. If I had my code here at work, I''d show you a quick function to do it. When I get home, I''ll post it, but it''s really simple stuff if you''re in a hurry.

I believe the variables you want in the structure are:
dwRBitMask, dwGBitMask, and dwBBitMask

Share this post


Link to post
Share on other sites
like i said in the other post, the easiest way is to set your colour key to the first pixel of the image (or a pixel you want to be transparent). this way you can have any colour transparent.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!