MCPcopy Create free account
hub / github.com/RenderKit/embree / loadEXR

Function loadEXR

tutorials/common/image/exr.cpp:21–48  ·  view source on GitHub ↗

! read PFM file from disk */

Source from the content-addressed store, hash-verified

19{
20 /*! read PFM file from disk */
21 Ref<Image> loadEXR(const FileName& fileName)
22 {
23 float* rgba; // width * height * RGBA
24 int width;
25 int height;
26 const char* err = NULL; // or nullptr in C++11
27
28 int ret = LoadEXR(&rgba, &width, &height, fileName.str().c_str(), &err);
29 if (ret != TINYEXR_SUCCESS) {
30 if (err) {
31 std::cerr << "ERR: " << err;
32 FreeEXRErrorMessage(err);
33 }
34 THROW_RUNTIME_ERROR("Could not load image " + fileName.str())
35 }
36
37 /* create image and fill with data */
38 Ref<Image> img = new Image4f(width,height,fileName);
39
40 for (ssize_t y=0; y<height; y++) {
41 for (ssize_t x=0; x<width; x++) {
42 float* pix = rgba + (y * width + x) * 4;
43 img->set(x,y,Color4(pix[0],pix[1],pix[2],1.0f));
44 }
45 }
46 free(rgba);
47 return img;
48 }
49
50 /*! store PFM file to disk */
51 void storeEXR(const Ref<Image>& img, const FileName& fileName)

Callers 1

loadImageFromDiskFunction · 0.85

Calls 6

LoadEXRFunction · 0.85
FreeEXRErrorMessageFunction · 0.85
Color4Class · 0.50
c_strMethod · 0.45
strMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected