[2/8] d3dx9: Check the size of a DDS file in D3DXGetImageInfoFromFileInMemory.

Józef Kucia joseph.kucia at gmail.com
Thu May 10 04:12:06 CDT 2012


On Thu, May 10, 2012 at 10:32 AM, Stefan Dösinger
<stefandoesinger at gmx.at> wrote:
> Am Mittwoch, 9. Mai 2012, 23:32:05 schrieb Józef Kucia:
>> +        *pitch = width * format_desc->bytes_per_pixel;
>> +        *size = *pitch * height;
> Usually surface pitches are either 4 or 8 byte aligned(depending on the API
> and pool). I recommend to write some tests for this. The most likely
> problematic formats are D3DFMT_P8, any 16 bit format like R5G6B5 and 24 bit
> R8G8B8. Maybe you're supposed to honor the pitch_or_linear_size member of the
> DDSURFACEDESC.

Surfaces pitches doesn't seem to be 4 or 8 byte aligned in DDS files.
MSDN recommends to not use pitch_or_linear_size and gives formulas for
computing pitches [1]. When it comes to formats mentioned by you,
D3DFMT_P8 doesn't seem to be supported in DDS files. The formula from
this patch also works for the dds_16bit file which stores pixels in
D3DFMT_X1R5G5B5 format. Besides that, the patches series seems to work
pretty well with at least two real applications.

On the other hand, writing more tests is a good idea.

[1] - http://msdn.microsoft.com/en-us/library/windows/desktop/bb943991%28v=vs.85%29.aspx



More information about the wine-devel mailing list