Advertisement Jump to content
Sign in to follow this  


This topic is 4981 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've been doing some 2D programming lately working with surfaces (IDirect3DSurface9*). I've been loading these surfaces in from bitmap (.bmp) files using the D3DXLoadSurfaceFromFile call, and blitting these surfaces to the backbuffer with StretchRect. This has all worked fine, except that I can't figure out how to mask bits and as a result all of my images have black boxes surrounding them. The D3DLoadSurfaceFromFile has a parameter--ColorKey--that looks like what I want. I'm passing ColorKey D3DCOLOR_ARGB(255, 0, 0, 0), which should replace opaque black with transparent black, but the black box is still there. Does StretchRect not use alpha values? Or am I going about this masking in the wrong manner?

Share this post

Link to post
Share on other sites
Colorkey should be a color, the alpha channel should have no effect IIRC. I ussually use hot pink 255r, 0g, 255b. Also its called a masked blit. bitmasking is another subject.

Share this post

Link to post
Share on other sites
Original post by Boku San
Got my hopes up and everything...

I wanted to explain bitmasking [cool]. Oh well.

If you know what you're talking about, explain it here: NeXe [smile]

Anyway, for the original poster... classic mistake - two common reasons:

1. Check your texture has an alpha component, in your D3DFMT_, make sure that you have an "A" something... e.g. D3FMT_A8R8G8B8 instead of D3FMT_X8R8G8B8.

2. Make sure that you're enabling alpha blending. You have to set three render states:


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!