ae27f89fa6c0530bb0a1f13d511c85837f10d4f4
[vrfileman] / src / color.cc
1 #include "color.h"
2 #include "opt.h"
3
4 Color color(float r, float g, float b)
5 {
6         return opt.srgb ? Color(r, g, b) : linear_to_srgb(Color(r, g, b));
7 }
8
9 Color linear_to_srgb(const Color &c)
10 {
11         const float inv_gamma = 1.0f / 2.2f;
12         return Color(pow(c.x, inv_gamma), pow(c.y, inv_gamma), pow(c.z, inv_gamma));
13 }
14
15 Color srgb_to_linear(const Color &c)
16 {
17         const float gamma = 2.2f;
18         return Color(pow(c.x, gamma), pow(c.y, gamma), pow(c.z, gamma));
19 }