diff options
Diffstat (limited to 'Build/source/utils/asymptote/cudareflect/EXRFiles.h')
-rw-r--r-- | Build/source/utils/asymptote/cudareflect/EXRFiles.h | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/Build/source/utils/asymptote/cudareflect/EXRFiles.h b/Build/source/utils/asymptote/cudareflect/EXRFiles.h new file mode 100644 index 00000000000..75a69cb6abf --- /dev/null +++ b/Build/source/utils/asymptote/cudareflect/EXRFiles.h @@ -0,0 +1,71 @@ +#pragma once + +#include "common.h" +#include <cuda_runtime.h> + +class EXRFile +{ +public: + EXRFile(std::string const& input); + + float const* getData() const + { + return flt; + } + + ~EXRFile() + { + free(flt); + } + + int getWidth() const + { + return width; + } + + int getHeight() const + { + return height; + } + + float4 getPixel4(size_t const& x, size_t const& y) + { + size_t base = 4 * (y * width + x); + return make_float4(flt[base], flt[base + 1], flt[base + 2], flt[base + 3]); + } + + float3 getPixel3(size_t const& x, size_t const& y) + { + size_t base = 4 * (y * width + x); + return make_float3(flt[base], flt[base + 1], flt[base + 2]); + } + +private: + int width, height; + float* flt; +}; + +class OEXRFile +{ +public: + OEXRFile(std::vector<float3> const& dat, int width, int height, int compressionType=TINYEXR_COMPRESSIONTYPE_PIZ); + OEXRFile(std::vector<float2> const& dat, int width, int height, int compressionType=TINYEXR_COMPRESSIONTYPE_PIZ); + void write(std::string const& filename); + ~OEXRFile() = default; + +protected: + void initChannelInfo(); + void initHeader(); +private: + int width, height; + int compressionType; + + std::vector<EXRChannelInfo> infos; + EXRHeader hd; + + std::vector<int> pixelType; + std::vector<int> reqPixelType; + + std::vector<float> r, g, b, a; + +};
\ No newline at end of file |