1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:27:35 +00:00

ICC: Implement TRC inversion in from_pcs for point curves

This allows converting to a color space that uses a non-parametric
curve, for example:

    Build/lagom/image -o foo.png \
        --convert-to-color-profile .../profiles/sRGB-v2-micro.icc \
        input.jpg

...where profiles/sRGB-v2-micro.icc is from
https://github.com/saucecontrol/Compact-ICC-Profiles/

(Parametric curves are new in ICC v4, which means all v2 profiles
use point curves.)
This commit is contained in:
Nico Weber 2023-05-01 20:52:21 -04:00 committed by Andreas Kling
parent 926c0d8676
commit 9c3e36e72c
2 changed files with 37 additions and 4 deletions

View file

@ -1570,10 +1570,8 @@ ErrorOr<void> Profile::from_pcs(FloatVector3 const& pcs, Bytes color) const
auto evaluate_curve_inverse = [this](TagSignature curve_tag, float f) {
auto const& trc = *m_tag_table.get(curve_tag).value();
VERIFY(trc.type() == CurveTagData::Type || trc.type() == ParametricCurveTagData::Type);
if (trc.type() == CurveTagData::Type) {
TODO();
return 0.f;
}
if (trc.type() == CurveTagData::Type)
return static_cast<CurveTagData const&>(trc).evaluate_inverse(f);
return static_cast<ParametricCurveTagData const&>(trc).evaluate_inverse(f);
};