1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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;
};
|