Directx texture format(indexed with transparency white)

Started by
2 comments, last by Evil Steve 14 years, 1 month ago
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
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).
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?
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().

This topic is closed to new replies.

Advertisement