Add PfmImage and PnmImage classes

This commit is contained in:
2020-12-25 00:24:25 +01:00
parent af8bd16e51
commit b14f691466
2 changed files with 29 additions and 17 deletions

View File

@@ -103,19 +103,25 @@ namespace openVulkanoCpp
}
return size;
}
};
static std::pair<PnmHeader, std::unique_ptr<char[]>> ReadImage(std::istream& inStream)
struct PnmImage
{
PnmHeader header;
std::unique_ptr<char[]> image;
static PnmImage ReadImage(std::istream& inStream)
{
std::pair<PnmHeader, std::unique_ptr<char[]>> image;
inStream >> image.first;
PnmImage image;
inStream >> image.header;
// TODO handle ascii mode
if (image.first.ascii) throw std::runtime_error("ascii mode not supported!");
if (image.header.ascii) throw std::runtime_error("ascii mode not supported!");
size_t size = image.first.GetImageSize();
image.second = std::make_unique<char[]>(size);
inStream.read(image.second.get(), size);
size_t size = image.header.GetImageSize();
image.image = std::make_unique<char[]>(size);
inStream.read(image.image.get(), size);
return image;
};
}
};
}