mirror of
https://github.com/microsoft/DirectXTex.git
synced 2025-07-09 11:40:14 +02:00
Add support for reading Unreal Tournament 2004 DDS files (#371)
This commit is contained in:
parent
70909fd6be
commit
83ea5ee1bc
@ -191,6 +191,22 @@ namespace
|
|||||||
|
|
||||||
constexpr size_t MAP_SIZE = sizeof(g_LegacyDDSMap) / sizeof(LegacyDDS);
|
constexpr size_t MAP_SIZE = sizeof(g_LegacyDDSMap) / sizeof(LegacyDDS);
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
|
if (ddpf.size == 0 && ddpf.flags == 0 && ddpf.fourCC != 0)
|
||||||
|
{
|
||||||
|
// Handle some DDS files where the DDPF_PIXELFORMAT is mostly zero
|
||||||
|
for (index = 0; index < MAP_SIZE; ++index)
|
||||||
|
{
|
||||||
|
const LegacyDDS* entry = &g_LegacyDDSMap[index];
|
||||||
|
|
||||||
|
if (entry->ddpf.flags & DDS_FOURCC)
|
||||||
|
{
|
||||||
|
if (ddpf.fourCC == entry->ddpf.fourCC)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
for (index = 0; index < MAP_SIZE; ++index)
|
for (index = 0; index < MAP_SIZE; ++index)
|
||||||
{
|
{
|
||||||
const LegacyDDS* entry = &g_LegacyDDSMap[index];
|
const LegacyDDS* entry = &g_LegacyDDSMap[index];
|
||||||
@ -263,6 +279,7 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (index >= MAP_SIZE)
|
if (index >= MAP_SIZE)
|
||||||
return DXGI_FORMAT_UNKNOWN;
|
return DXGI_FORMAT_UNKNOWN;
|
||||||
@ -289,7 +306,6 @@ namespace
|
|||||||
return format;
|
return format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
// Decodes DDS header including optional DX10 extended header
|
// Decodes DDS header including optional DX10 extended header
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
@ -320,8 +336,12 @@ namespace
|
|||||||
auto pHeader = reinterpret_cast<const DDS_HEADER*>(static_cast<const uint8_t*>(pSource) + sizeof(uint32_t));
|
auto pHeader = reinterpret_cast<const DDS_HEADER*>(static_cast<const uint8_t*>(pSource) + sizeof(uint32_t));
|
||||||
|
|
||||||
// Verify header to validate DDS file
|
// Verify header to validate DDS file
|
||||||
if (pHeader->size != sizeof(DDS_HEADER)
|
if (pHeader->size != sizeof(DDS_HEADER))
|
||||||
|| pHeader->ddspf.size != sizeof(DDS_PIXELFORMAT))
|
{
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pHeader->ddspf.size != 0 && pHeader->ddspf.size != sizeof(DDS_PIXELFORMAT))
|
||||||
{
|
{
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user