• Advertisement
Sign in to follow this  

want to achieve transparency in sprite

This topic is 4273 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 want to achieve transparency with my sprite imgae which is having backgrnd color pink(255,0,255).I'm using directx9 and "D3DXLoadSurfaceFromFile" function to load my bitmap image. Pls give me solution for this.

Share this post


Link to post
Share on other sites
Advertisement
In order to get your sprite to be transparent you need to apply a color-key to the pink color you are using as a background. Look in your DirectX documentation for the term "color-key" and it should be there somewhere. If not, you may have to manually convert all of the pink pixels into alpha-blended 0 if you are using 32-bit color. I'm sorry I can't point you to the exact functions to do what you want but I never use DirectX for portability reasons.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Here is the function you are using.

HRESULT D3DXLoadSurfaceFromFile(
LPDIRECT3DSURFACE9 pDestSurface,
CONST PALETTEENTRY* pDestPalette,
CONST RECT* pDestRect,
LPCTSTR pSrcFile,
CONST RECT* pSrcRect,
DWORD Filter,
D3DCOLOR ColorKey,
D3DXIMAGE_INFO* pSrcInfo
);

According to documentation...

ColorKey
[in] D3DCOLOR value to replace with transparent black, or 0 to disable the colorkey. This is always a 32-bit ARGB color, independent of the source image format. Alpha is significant and should usually be set to FF for opaque color keys Thus, for opaque black, the value would be equal to 0xFF000000.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
Here is the function you are using.

HRESULT D3DXLoadSurfaceFromFile(
LPDIRECT3DSURFACE9 pDestSurface,
CONST PALETTEENTRY* pDestPalette,
CONST RECT* pDestRect,
LPCTSTR pSrcFile,
CONST RECT* pSrcRect,
DWORD Filter,
D3DCOLOR ColorKey,
D3DXIMAGE_INFO* pSrcInfo
);

According to documentation...

ColorKey
[in] D3DCOLOR value to replace with transparent black, or 0 to disable the colorkey. This is always a 32-bit ARGB color, independent of the source image format. Alpha is significant and should usually be set to FF for opaque color keys Thus, for opaque black, the value would be equal to 0xFF000000.


this is just a copy paste from Directx documentation,i knw wht function do and wht are the parameters.Pls read my query once again.Can u tell me what will be the value of D3DCOLOR_ARGB(a,r,b,g) for my image. should i use float value or 0 to 255.wht is the value of "a".
Thanx for trying

Share this post


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

  • Advertisement