diff options
author | Keuin <[email protected]> | 2022-04-14 14:31:58 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2022-04-14 14:31:58 +0800 |
commit | 92a1095ca8b9cd13f233e26a5e1f70518663806e (patch) | |
tree | b29bf86817fbe8beb5893d453397c3bbf9f82efb /bitmap.h | |
parent | 977490e2b3a181796348ab1853a87cde7c92f676 (diff) |
Add gamma2 correction.
Diffstat (limited to 'bitmap.h')
-rw-r--r-- | bitmap.h | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -71,6 +71,14 @@ struct pixel { static inline T max_value() { return mod; // FIXME } + + inline pixel<T> gamma2() const { + const auto max = max_value(); + const double r_ = sqrt(1.0 * this->r / max); + const double g_ = sqrt(1.0 * this->g / max); + const double b_ = sqrt(1.0 * this->b / max); + return pixel<T>::from_normalized(r_, g_, b_); + } }; template< @@ -215,6 +223,15 @@ public: return out; } + bitmap<T> gamma2() const { + std::vector<pixel<T>> out; + out.reserve(content.size()); + for (const auto &pix: content) { + out.push_back(pix.gamma2()); + } + return bitmap<T>{width, height, std::move(out)}; + } + }; template<typename T> |