! store PFM file to disk */
| 49 | |
| 50 | /*! store PFM file to disk */ |
| 51 | void storeEXR(const Ref<Image>& img, const FileName& fileName) |
| 52 | { |
| 53 | std::vector<Col3f> rgb(img->width * img->height); |
| 54 | for (size_t y=0; y<img->height; ++y) { |
| 55 | for (size_t x=0; x<img->width; ++x) { |
| 56 | Color4 c = img->get(x, y); |
| 57 | rgb[y * img->width + x] = Col3f(c.r, c.g, c.b); |
| 58 | } |
| 59 | } |
| 60 | const char* err = NULL; |
| 61 | int ret = SaveEXR((float*)rgb.data(), img->width, img->height, 3, 0, fileName.str().c_str(), &err); |
| 62 | if (ret != TINYEXR_SUCCESS) { |
| 63 | if (err) { |
| 64 | std::cerr << "ERR: " << err; |
| 65 | FreeEXRErrorMessage(err); |
| 66 | } |
| 67 | THROW_RUNTIME_ERROR("Could not save image " + fileName.str()) |
| 68 | } |
| 69 | } |
| 70 | } |
no test coverage detected