mayingzhen / nvidia-texture-tools

Automatically exported from code.google.com/p/nvidia-texture-tools
Other
0 stars 0 forks source link

DirectDrawSurface images don't correctly report image format #52

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Load a DXT1 image with DirectDrawSurface
2. Fill an nv::Image object with the mipmap() call.
3. Call image->getFormat().

What is the expected output? What do you see instead?
I should get Format_RGB (since DXT1 has no alpha channel) but I get
Format_ARGB.

What version of the product are you using? On what operating system?
Using texture tools 2.0.2, but the problem will also exist in 2.0.3.

Please provide any additional information below.
The problem is in DirectDrawSurface::readBlockImage.
In the beginning of the function, it checks the fourcc of the header to see
if its a format that contains an alpha channel. The list there is
incomplete. I'm not sure about all the formats, but DXT1 definitely does
NOT contain an alpha channel, so at least that one should be added.

I'm writing an app that shrinks textures by factors so I wanted to load
from the 2nd or 3rd mipmap (depending on reduction ratio) until the end,
set DXT1 or DXT5 according to the image format and recompress.

Because DXT1s get reported as Format_ARGB, everything becomes DXT5. I
implemented a workaround in my code, but this should be fixed.

Original issue reported on code.google.com by Noam...@gmail.com on 15 Jun 2008 at 8:42

GoogleCodeExporter commented 8 years ago
DXT1 does have a 1 bit alpha channel (opaque or transparent). You could esily 
detect if there are transparent 
texels, by looking for 3-color blocks and checking if any of these uses the 11b 
palette index. Hope that helps!

Closing, not a bug.

Original comment by cast...@gmail.com on 16 Jun 2008 at 5:24

GoogleCodeExporter commented 8 years ago
Are you sure? I think that the format that has a 1 bit alpha channel is DXT1a. 
Or are
DXT1 and DXT1a the same?

Original comment by Noam...@gmail.com on 17 Jun 2008 at 5:37

GoogleCodeExporter commented 8 years ago
They are the same format. DXT1a is just a way of indicating that you want DXT1 
with alpha.

Original comment by cast...@gmail.com on 17 Jun 2008 at 4:55