Jump to content
  • Advertisement
Sign in to follow this  
jor1980

Directx texture format(indexed with transparency white)

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

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
Advertisement
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
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!