From 6f39c4416078a1010203a1b0890fc52df4103adf Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Sun, 12 Feb 2023 11:39:53 -0500 Subject: icc: Dump embedded non-parametric curves in lutAToBType and lutAToBType --- Userland/Utilities/icc.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'Userland/Utilities') diff --git a/Userland/Utilities/icc.cpp b/Userland/Utilities/icc.cpp index b79e4d226b..99cc71fee1 100644 --- a/Userland/Utilities/icc.cpp +++ b/Userland/Utilities/icc.cpp @@ -30,6 +30,19 @@ static void out_optional(char const* label, Optional const& optional) outln("(not set)"); } +static void out_curve(Gfx::ICC::CurveTagData const& curve, int indent_amount) +{ + auto indent = MUST(String::repeated(' ', indent_amount)); + if (curve.values().is_empty()) { + outln("{}identity curve", indent); + } else if (curve.values().size() == 1) { + outln("{}gamma: {}", indent, FixedPoint<8, u16>::create_raw(curve.values()[0])); + } else { + // FIXME: Maybe print the actual points if -v is passed? + outln("{}curve with {} points", indent, curve.values().size()); + } +} + static void out_parametric_curve(Gfx::ICC::ParametricCurveTagData const& parametric_curve, int indent_amount) { auto indent = MUST(String::repeated(' ', indent_amount)); @@ -65,6 +78,8 @@ static void out_curves(Vector 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::CurveTagData::Type) + out_curve(static_cast(*curve), /*indent=*/12); if (curve->type() == Gfx::ICC::ParametricCurveTagData::Type) out_parametric_curve(static_cast(*curve), /*indent=*/12); } @@ -182,15 +197,7 @@ ErrorOr serenity_main(Main::Arguments arguments) outln(" video full range flag: {} - {}", cicp.video_full_range_flag(), Video::video_full_range_flag_to_string((Video::VideoFullRangeFlag)cicp.video_full_range_flag())); } else if (tag_data->type() == Gfx::ICC::CurveTagData::Type) { - auto& curve = static_cast(*tag_data); - if (curve.values().is_empty()) { - outln(" identity curve"); - } else if (curve.values().size() == 1) { - outln(" gamma: {}", FixedPoint<8, u16>::create_raw(curve.values()[0])); - } else { - // FIXME: Maybe print the actual points if -v is passed? - outln(" curve with {} points", curve.values().size()); - } + out_curve(static_cast(*tag_data), /*indent=*/4); } else if (tag_data->type() == Gfx::ICC::Lut16TagData::Type) { auto& lut16 = static_cast(*tag_data); outln(" input table: {} channels x {} entries", lut16.number_of_input_channels(), lut16.number_of_input_table_entries()); -- cgit v1.2.3