diff options
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> |