Sign in to follow this  
john_t

Bitmasking

Recommended Posts

john_t    122
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
chad_420    290
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
jollyjeffers    1570
Quote:
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:
D3DRS_SRCBLEND = D3DBLEND_SRCALPHA
D3DRS_DESTBLEND = D3DBLEND_INVSRCALPHA
D3DRS_ALPHABLENDENABLE = TRUE

hth
Jack

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this