summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2023-02-12 11:34:24 -0500
committerLinus Groh <mail@linusgroh.de>2023-02-13 00:15:02 +0000
commit7929f8fef9b116c617712a6e84d75ebd86fcab93 (patch)
tree971531bafe83a916950b052d22ee0e077e051c37 /Userland
parented8bd3a7927ef6ca037e0571b545af59b39a1d03 (diff)
downloadserenity-7929f8fef9b116c617712a6e84d75ebd86fcab93.zip
icc: Dump embedded parametric curves in lutAToBType and lutAToBType
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Utilities/icc.cpp59
1 files changed, 33 insertions, 26 deletions
diff --git a/Userland/Utilities/icc.cpp b/Userland/Utilities/icc.cpp
index 51ecc2886c..b79e4d226b 100644
--- a/Userland/Utilities/icc.cpp
+++ b/Userland/Utilities/icc.cpp
@@ -30,11 +30,43 @@ static void out_optional(char const* label, Optional<T> const& optional)
outln("(not set)");
}
+static void out_parametric_curve(Gfx::ICC::ParametricCurveTagData const& parametric_curve, int indent_amount)
+{
+ auto indent = MUST(String::repeated(' ', indent_amount));
+ switch (parametric_curve.function_type()) {
+ case Gfx::ICC::ParametricCurveTagData::FunctionType::Type0:
+ outln("{}Y = X**{}", indent, parametric_curve.g());
+ break;
+ case Gfx::ICC::ParametricCurveTagData::FunctionType::Type1:
+ outln("{}Y = ({}*X + {})**{} if X >= -{}/{}", indent,
+ parametric_curve.a(), parametric_curve.b(), parametric_curve.g(), parametric_curve.b(), parametric_curve.a());
+ outln("{}Y = 0 else", indent);
+ break;
+ case Gfx::ICC::ParametricCurveTagData::FunctionType::Type2:
+ outln("{}Y = ({}*X + {})**{} + {} if X >= -{}/{}", indent,
+ parametric_curve.a(), parametric_curve.b(), parametric_curve.g(), parametric_curve.c(), parametric_curve.b(), parametric_curve.a());
+ outln("{}Y = {} else", indent, parametric_curve.c());
+ break;
+ case Gfx::ICC::ParametricCurveTagData::FunctionType::Type3:
+ outln("{}Y = ({}*X + {})**{} if X >= {}", indent,
+ parametric_curve.a(), parametric_curve.b(), parametric_curve.g(), parametric_curve.d());
+ outln("{}Y = {}*X else", indent, parametric_curve.c());
+ break;
+ case Gfx::ICC::ParametricCurveTagData::FunctionType::Type4:
+ outln("{}Y = ({}*X + {})**{} + {} if X >= {}", indent,
+ parametric_curve.a(), parametric_curve.b(), parametric_curve.g(), parametric_curve.e(), parametric_curve.d());
+ outln("{}Y = {}*X + {} else", indent, parametric_curve.c(), parametric_curve.f());
+ break;
+ }
+}
+
static void out_curves(Vector<Gfx::ICC::LutCurveType> const& curves)
{
for (auto const& curve : curves) {
VERIFY(curve->type() == Gfx::ICC::CurveTagData::Type || curve->type() == Gfx::ICC::ParametricCurveTagData::Type);
outln(" type {}, relative offset {}, size {}", curve->type(), curve->offset(), curve->size());
+ if (curve->type() == Gfx::ICC::ParametricCurveTagData::Type)
+ out_parametric_curve(static_cast<Gfx::ICC::ParametricCurveTagData&>(*curve), /*indent=*/12);
}
}
@@ -295,32 +327,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (named_colors.size() > 5u)
outln(" ...");
} else if (tag_data->type() == Gfx::ICC::ParametricCurveTagData::Type) {
- auto& parametric_curve = static_cast<Gfx::ICC::ParametricCurveTagData&>(*tag_data);
- switch (parametric_curve.function_type()) {
- case Gfx::ICC::ParametricCurveTagData::FunctionType::Type0:
- outln(" Y = X**{}", parametric_curve.g());
- break;
- case Gfx::ICC::ParametricCurveTagData::FunctionType::Type1:
- outln(" Y = ({}*X + {})**{} if X >= -{}/{}",
- parametric_curve.a(), parametric_curve.b(), parametric_curve.g(), parametric_curve.b(), parametric_curve.a());
- outln(" Y = 0 else");
- break;
- case Gfx::ICC::ParametricCurveTagData::FunctionType::Type2:
- outln(" Y = ({}*X + {})**{} + {} if X >= -{}/{}",
- parametric_curve.a(), parametric_curve.b(), parametric_curve.g(), parametric_curve.c(), parametric_curve.b(), parametric_curve.a());
- outln(" Y = {} else", parametric_curve.c());
- break;
- case Gfx::ICC::ParametricCurveTagData::FunctionType::Type3:
- outln(" Y = ({}*X + {})**{} if X >= {}",
- parametric_curve.a(), parametric_curve.b(), parametric_curve.g(), parametric_curve.d());
- outln(" Y = {}*X else", parametric_curve.c());
- break;
- case Gfx::ICC::ParametricCurveTagData::FunctionType::Type4:
- outln(" Y = ({}*X + {})**{} + {} if X >= {}",
- parametric_curve.a(), parametric_curve.b(), parametric_curve.g(), parametric_curve.e(), parametric_curve.d());
- outln(" Y = {}*X + {} else", parametric_curve.c(), parametric_curve.f());
- break;
- }
+ out_parametric_curve(static_cast<Gfx::ICC::ParametricCurveTagData&>(*tag_data), /*indent=*/4);
} else if (tag_data->type() == Gfx::ICC::S15Fixed16ArrayTagData::Type) {
// This tag can contain arbitrarily many fixed-point numbers, but in practice it's
// exclusively used for the 'chad' tag, where it always contains 9 values that