Sign in to follow this  
jor1980

Directx texture format(indexed with transparency white)

Recommended Posts

jor1980    152
Hi, i would like to know if is there any texture format in directx with the data indexed and that makes transparent the color white. this format wwould have 8 bits per pixel and the white pixels are going to be transparents Thank´s

Share this post


Link to post
Share on other sites
Evil Steve    2017
No, there isn't. And pretty much nothing supports the D3DFMT_P8 format. You could however use D3DFMT_L8 or some other 8-bit format, and do whatever you like with it in a pixel shader.

If you don't want to have to use a pixel shader, and you have white in the texture already, use D3DFMT_A8R8G8B8 and D3DXCreateTextureFromFileEx with the ColorKey parameter set to D3DCOLOR_XRGB(255, 255, 255).

Share this post


Link to post
Share on other sites
jor1980    152
Could i do the next?

create a texture from a png file and converts the transparet pixels in the file to white pixels in the texture?

How could i do it?

Share this post


Link to post
Share on other sites
Evil Steve    2017
There's no built in functions to do that, it's a pretty specific thing to want to do.

You could load the texture with D3DXCreateTextureFromFileEx, LockRect() it, and then go through each pixel, checking the alpha value, and if it's not 255, then change that pixel to 0xffffffff, then UnlockRect().

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