- Fixing DDS reader so it doesn't require the source pitch/linear size field to be divisible by 4

- Fixing DDS writer so it writes a non-zero pitch/linearsize field (a few DDS readers in the wild require this field to be set)
- Fixing example2.cpp and example3.cpp so they write non-zero pitch/linearsize fields.
- Misc merges from the ddsexport branch
- Adding -usesourceformat command line option, useful when reprocessing a lot of existing DDS files.
This commit is contained in:
richgel99@gmail.com
2012-04-16 00:58:38 +00:00
parent d96d9807b1
commit 45901c935c
9 changed files with 179 additions and 16 deletions
+5
View File
@@ -260,6 +260,11 @@ int main(int argc, char *argv[])
dds_desc.ddpfPixelFormat.dwFourCC = crn_get_format_fourcc(fmt);
dds_desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
// Set pitch/linearsize field (some DDS readers require this field to be non-zero).
uint bits_per_pixel = crn_get_format_bits_per_texel(fmt);
dds_desc.lPitch = (((dds_desc.dwWidth + 3) & ~3) * ((dds_desc.dwHeight + 3) & ~3) * bits_per_pixel) >> 3;
dds_desc.dwFlags |= DDSD_LINEARSIZE;
// Write the DDS header to the output file.
fwrite(&dds_desc, sizeof(dds_desc), 1, pDDS_file);