Minor improvements to EXR decoding. (#177)

See also #176.

This closes #166.
This commit is contained in:
Philip Rideout
2018-08-28 14:38:54 -07:00
committed by GitHub
parent f78a680b9c
commit 4665805d81
3 changed files with 22 additions and 1 deletions

View File

@@ -576,11 +576,13 @@ LinearImage EXRDecoder::decode() {
int ret = LoadEXRFromMemory(&rgba, &width, &height, src.data(), src.size(), &error);
if (ret != TINYEXR_SUCCESS) {
std::cerr << "Could not decode OpenEXR: " << error << std::endl;
FreeEXRErrorMessage(error);
mStream.seekg(mStreamStartPos);
return LinearImage();
}
src.resize(0);
src.clear();
src.shrink_to_fit();
LinearImage image(width, height, 3);
@@ -596,6 +598,8 @@ LinearImage EXRDecoder::decode() {
}
}
free(rgba);
return image;
} catch(std::runtime_error& e) {
// reset the stream, like we found it