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

LibGfx+icc: Read signatureType

This isn't used by any mandatory tags, and it's not terribly useful.
But jpegs exported by Lightroom Classic write the 'tech' tag, and
it seems nice to be able to dump its contents.

signatureType stores a single u32 which for different tags with this
type means different things.

In each case, the value is one from a short table of valid values,
suggesting this should be a per-tag enum class instead of a
per-tag DistinctFourCC, per the comment at the top of DistincFourCC.h.
On the other hand, 3 of the 4 tables have an explicit "It is possible
that the ICC will define other signature values in the future" note,
which suggests the FourCC might actually be the way to go.

For now, just punt on that and manually dump the u32 in fourcc style
in icc.cpp and don't add any to_string() methods that return a readable
string based on the contents of these tables.
This commit is contained in:
Nico Weber 2023-02-07 15:15:55 -05:00 committed by Linus Groh
parent cbcf8471a6
commit 8bd64f001c
4 changed files with 53 additions and 4 deletions

View file

@ -586,6 +586,8 @@ ErrorOr<NonnullRefPtr<TagData>> Profile::read_tag(ReadonlyBytes bytes, u32 offse
return ParametricCurveTagData::from_bytes(tag_bytes, offset_to_beginning_of_tag_data_element, size_of_tag_data_element);
case S15Fixed16ArrayTagData::Type:
return S15Fixed16ArrayTagData::from_bytes(tag_bytes, offset_to_beginning_of_tag_data_element, size_of_tag_data_element);
case SignatureTagData::Type:
return SignatureTagData::from_bytes(tag_bytes, offset_to_beginning_of_tag_data_element, size_of_tag_data_element);
case TextDescriptionTagData::Type:
return TextDescriptionTagData::from_bytes(tag_bytes, offset_to_beginning_of_tag_data_element, size_of_tag_data_element);
case TextTagData::Type:
@ -992,7 +994,8 @@ ErrorOr<void> Profile::check_tag_types()
// ICC v4, 9.2.21 colorimetricIntentImageStateTag
// "Permitted tag types: signatureType"
// FIXME
if (!has_type(colorimetricIntentImageStateTag, { SignatureTagData::Type }, {}))
return Error::from_string_literal("ICC::Profile: colorimetricIntentImageStateTag has unexpected type");
// ICC v4, 9.2.22 copyrightTag
// "Permitted tag types: multiLocalizedUnicodeType"
@ -1154,7 +1157,8 @@ ErrorOr<void> Profile::check_tag_types()
// ICC v4, 9.2.39 perceptualRenderingIntentGamutTag
// "Permitted tag types: signatureType"
// FIXME
if (!has_type(perceptualRenderingIntentGamutTag, { SignatureTagData::Type }, {}))
return Error::from_string_literal("ICC::Profile: perceptualRenderingIntentGamutTag has unexpected type");
// ICC v4, 9.2.40 preview0Tag
// "Permitted tag types: lut8Type or lut16Type or lutAToBType or lutBToAType"
@ -1220,11 +1224,13 @@ ErrorOr<void> Profile::check_tag_types()
// ICC v4, 9.2.48 saturationRenderingIntentGamutTag
// "Permitted tag types: signatureType"
// FIXME
if (!has_type(saturationRenderingIntentGamutTag, { SignatureTagData::Type }, {}))
return Error::from_string_literal("ICC::Profile: saturationRenderingIntentGamutTag has unexpected type");
// ICC v4, 9.2.49 technologyTag
// "Permitted tag types: signatureType"
// FIXME
if (!has_type(technologyTag, { SignatureTagData::Type }, {}))
return Error::from_string_literal("ICC::Profile: technologyTag has unexpected type");
// ICC v4, 9.2.50 viewingCondDescTag
// "Permitted tag types: multiLocalizedUnicodeType"