diff --git a/src/core/colorpipeline.cpp b/src/core/colorpipeline.cpp index fed8f30567..d5cea4c49e 100644 --- a/src/core/colorpipeline.cpp +++ b/src/core/colorpipeline.cpp @@ -225,6 +225,23 @@ ColorPipeline ColorPipeline::merge(const ColorPipeline &onTop) return ret; } +QVector3D ColorPipeline::evaluate(const QVector3D &input) const +{ + QVector3D ret = input; + for (const auto &op : ops) { + if (const auto mat = std::get_if(&op.operation)) { + ret = mat->mat * ret; + } else if (const auto mult = std::get_if(&op.operation)) { + ret *= mult->factors; + } else if (const auto tf = std::get_if(&op.operation)) { + ret = tf->tf.encodedToNits(ret, tf->referenceLuminance); + } else if (const auto tf = std::get_if(&op.operation)) { + ret = tf->tf.nitsToEncoded(ret, tf->referenceLuminance); + } + } + return ret; +} + ColorTransferFunction::ColorTransferFunction(TransferFunction tf, double referenceLLuminance) : tf(tf) , referenceLuminance(referenceLLuminance) diff --git a/src/core/colorpipeline.h b/src/core/colorpipeline.h index d2252b75f4..d3305f6670 100644 --- a/src/core/colorpipeline.h +++ b/src/core/colorpipeline.h @@ -88,6 +88,7 @@ public: bool isIdentity() const; bool operator==(const ColorPipeline &other) const = default; const ValueRange ¤tOutputRange() const; + QVector3D evaluate(const QVector3D &input) const; void addMultiplier(double factor); void addMultiplier(const QVector3D &factors);