1

Closed

How to convert dds to bitmap and vice verca?

description

here is the changed file which was saved using the library.

file attachments

Closed Feb 13, 2013 at 12:37 AM by walbourn
I believe this is By Design. The original image is lossy compressed using a different algorithm or implementation.

comments

walbourn wrote Feb 13, 2013 at 12:37 AM

DDS c:a_m.dds
Flags 000a1007: CAPS HEIGHT WIDTH PIXELFORMAT MIPMAPCOUNT LINEARSIZE
1024 x 1024
Linear Size: 524288
Mipmap count: 11
Surface flags: 00401008: COMPLEX TEXTURE MIPMAP
PIXELFORMAT: 00000004: FOURCC
FourCC = 827611204 'DXT1'
DXGI_FORMAT_BC1_UNORM

Your original file here is already 'lossy 'compressed (it's using DXT1 / BC1 ).

What format are you decompressing TO for your BMP? What format are you converting it back TO for your modified .DDS file?

If I decompress the original DDS BC1 -> BMP R8G8B8A8_UNORM, then convert BMP R8G8B8A8_UNORM back to a DDS R8G8B8A8_UNORM the bits are identical. The initial expansion of BC1 to R8G8B8A8_UNORM is 'lossless', but the original conversion to DDS BC1 was 'lossy'.

Now, if I decompress the original DDS BC1 -> BMP R8G8B8A8_UNORM, then convert BMP R8G8B8A8_UNORM back to a DDS BC1_UNORM then the bits are different. Again the initial expansion of BC1 to R8G8B8A8_UNORM is 'lossless', but the recompression back to BC1 is again 'lossy'. The primary contribution to the differences is that the original DDS BC1 file was not compressed with DirectXTex, but with some other compressor (some version of D3DX or 3rd party code).

This is borne out by doing this process again. If you again decompress the expanded DDS R8G8B8A8 'new' file, then compress it again to a new BC1 DDS, the resulting image is actually pretty close (less error than in the first pass of recompression). That's because the third round of compression is done with the same implementation as the second.

walbourn wrote Feb 13, 2013 at 12:40 AM

Of course, you shouldn't be decompressing and recompressing images using a lossy scheme anyhow as you will of course continue to lose image fidelity.