views:

169

answers:

2

In my engine I have a need to be able to detect DXT1 textures that have texels with 0 alpha (e.g. a cutout for a window frame). This is easy for textures I compress myself, but I'm not sure about textures that are already compressed.

Is there an easy way to tell from the header whether a DDS image contains alpha?

+1  A: 

As far as I know, there's no way to tell from the header. There's a DDPF_ALPHAPIXELS flag, but I don't think that will get set based on what's in the pixel data. You'd need to parse the DXT1 blocks, and look for colours that have 0 alpha in them (making sure to check that the colour is actually used in the block, too, I suppose).

James Sutherland
A: 

I agree with the accepted answer. Your job may be made a bit easier by using the "squish" library to decompress the blocks for you.

http://www.sjbrown.co.uk/?code=squish

Chris Blackwell