diff options
author | Norbert Preining <norbert@preining.info> | 2021-12-28 03:01:00 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2021-12-28 03:01:00 +0000 |
commit | ecdf859b6ce481abfd530425dcf6f0f764bd0001 (patch) | |
tree | 13bc161dc046876ac6c92fce5f9f5034ba9aa573 /graphics/asymptote/EXRFiles.cc | |
parent | 790995b7e79697514364450bf9c04f1b8d500838 (diff) |
CTAN sync 202112280300
Diffstat (limited to 'graphics/asymptote/EXRFiles.cc')
-rw-r--r-- | graphics/asymptote/EXRFiles.cc | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/graphics/asymptote/EXRFiles.cc b/graphics/asymptote/EXRFiles.cc new file mode 100644 index 0000000000..3f16f1edc9 --- /dev/null +++ b/graphics/asymptote/EXRFiles.cc @@ -0,0 +1,49 @@ +// +// Created by jamie on 8/23/21. +// + +#include "EXRFiles.h" +#include "locate.h" + +namespace camp +{ +using std::cout; +using std::cerr; +using std::endl; + +IEXRFile::IEXRFile(const string& File) +{ + char const* err; + int ret; + string file=settings::locateFile(File); + string image=settings::getSetting<string>("image"); + if(file.empty()) { + cerr << "EXR file not found: " << File << endl + << "Precomputed image directories like ibl/" << image << " can be " + << "downloaded into the Asymptote search path like this:" + << endl << endl + << "wget -q --show-progress -nH -np -r --cut-dirs=1 " + << settings::getSetting<string>("imageURL") << "/refl.exr" << endl + << "wget -q --show-progress -nH -np -r --cut-dirs=1 " + << settings::getSetting<string>("imageURL") << "/" << image + << endl; + exit(-1); + } + const char *filename=file.c_str(); + if((ret=LoadEXR(&data,&width,&height,filename,&err)) != TINYEXR_SUCCESS) + { + cerr << "TinyEXR Error: " << err << " " << filename << endl; + FreeEXRErrorMessage(err); + exit(-1); + } +} + +IEXRFile::~IEXRFile() +{ + if(data) { + free(data); + data=nullptr; + } +} + +} |