PoL0 / crunch

Automatically exported from code.google.com/p/crunch
Other
0 stars 0 forks source link

Wrong size of structure DDSURFACEDESC2 #3

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I noticed that in inc/dds_defs.h the sizeof structure DDSURFACEDESC2 is 124 
bytes, by calculating that with sizeof(). However, in my DDS tests, where I try 
to load a single DDS file, I see a DDS header length of 120 bytes, which does 
not match the above mentioned structure.

My loader works, if I calculate fileoffsets with 120 bytes, instead of the 
mentioned 124 bytes. Hence, the question is, is the definition of 
DDSURFACEDESC2 correct, or should it be instead 120 bytes?

A sample DDS attached in this issue, what I used for testing.

Original issue reported on code.google.com by jvatjusa...@gmail.com on 7 Aug 2012 at 11:24

Attachments:

GoogleCodeExporter commented 9 years ago
The header consists of a DWORD identifier, followed by 124 bytes, or 128 bytes 
total, see this link for more info:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb943982(v=vs.85).aspx

Here's the header from your sample file:

        dwSize  124 unsigned int
        dwFlags 528391  unsigned int
        dwHeight    128 unsigned int
        dwWidth 128 unsigned int
        lPitch  8192    int
        dwLinearSize    8192    unsigned int

DDSURFACEDESC2 should be 124 bytes total.

Hope that helps,
-Rich

Original comment by richge...@gmail.com on 11 Aug 2012 at 8:09

GoogleCodeExporter commented 9 years ago
Yes, that is right. I missed the single DWORD identifier, which makes the 
header in total 128 bytes. Now, this explains the offset I need to add to the 
data, to get the correct data out from the file. Thank you for pointing that 
out, and apologizes for the invalid issue :)

Original comment by jvatjusa...@gmail.com on 14 Aug 2012 at 11:49

GoogleCodeExporter commented 9 years ago

Original comment by richge...@gmail.com on 17 Sep 2012 at 5:21