icc: Print each tag signature's spec name

The spec names are still a bit cryptic ("deviceMfgDescTag"
for "device manufacturer description"), but less cryptic than
just the fourcc.

There's a private tag area, so this will only print the spec name
of tags in the current spec. Private tags are in active use, e.g.:

    $ icc /Library/ColorSync/Profiles/WebSafeColors.icc
    ...
    Unknown tag ('dscm'): type 'mluc', offset 312, size 1490

(That's a v2 file. In v2, 'desc' has that strange textDescriptionType.
In v4, 'desc' has type 'mluc' -- but in v2, it didn't yet, so Apple
invented the private 'dscm' tag which has the description as an 'mluc'.)
This commit is contained in:
Nico Weber 2023-01-24 15:24:39 -05:00 committed by Andreas Kling
parent 2e315757b1
commit 2095e2529f
Notes: sideshowbarker 2024-07-17 01:17:06 +09:00
2 changed files with 6 additions and 2 deletions

View file

@ -114,7 +114,7 @@ URL device_model_url(DeviceModel);
TAG(viewingCondDescTag, 0x76756564 /* 'vued' */) \
TAG(viewingConditionsTag, 0x76696577 /* 'view' */)
#define TAG(name, id) constexpr TagSignature name { id };
#define TAG(name, id) constexpr inline TagSignature name { id };
ENUMERATE_TAG_SIGNATURES(TAG)
#undef TAG

View file

@ -93,7 +93,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
outln("tags:");
HashMap<Gfx::ICC::TagData*, Gfx::ICC::TagSignature> tag_data_to_first_signature;
profile->for_each_tag([&tag_data_to_first_signature](auto tag_signature, auto tag_data) {
outln("{}: {}, offset {}, size {}", tag_signature, tag_data->type(), tag_data->offset(), tag_data->size());
if (auto name = tag_signature_spec_name(tag_signature); name.has_value())
out("{} ({}): ", *name, tag_signature);
else
out("Unknown tag ({}): ", tag_signature);
outln("type {}, offset {}, size {}", tag_data->type(), tag_data->offset(), tag_data->size());
// Print tag data only the first time it's seen.
// (Different sigatures can refer to the same data.)