Handle images with invalid resolution

This commit is contained in:
Georg Hagen
2025-03-03 18:51:06 +01:00
parent b1c1697def
commit 21c5f26869
2 changed files with 15 additions and 0 deletions

View File

@@ -94,6 +94,14 @@ namespace OpenVulkano
void Read(std::istream& inStream)
{
inStream >> header;
if (header.width == UINT32_MAX || header.height == UINT32_MAX)
{
header.width = header.height = 0;
image = nullptr;
return;
}
size_t size = header.GetElementCount();
image = std::make_unique<float[]>(size);

View File

@@ -139,6 +139,13 @@ namespace OpenVulkano
// TODO handle ascii mode
if (header.ascii) throw std::runtime_error("ascii mode not supported!");
if (header.width == UINT32_MAX || header.height == UINT32_MAX)
{
header.width = header.height = 0;
image = nullptr;
return;
}
size_t size = header.GetImageSize();
image = std::make_unique<char[]>(size);
inStream.read(image.get(), size);