summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Libraries/LibGfx/ICC/Profile.cpp14
-rw-r--r--Userland/Libraries/LibGfx/ICC/TagTypes.cpp14
-rw-r--r--Userland/Libraries/LibGfx/ICC/TagTypes.h19
-rw-r--r--Userland/Utilities/icc.cpp10
4 files changed, 53 insertions, 4 deletions
diff --git a/Userland/Libraries/LibGfx/ICC/Profile.cpp b/Userland/Libraries/LibGfx/ICC/Profile.cpp
index b3f96177e8..f4d5a8cedc 100644
--- a/Userland/Libraries/LibGfx/ICC/Profile.cpp
+++ b/Userland/Libraries/LibGfx/ICC/Profile.cpp
@@ -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"
diff --git a/Userland/Libraries/LibGfx/ICC/TagTypes.cpp b/Userland/Libraries/LibGfx/ICC/TagTypes.cpp
index 7ddf2db61d..d29321a7ea 100644
--- a/Userland/Libraries/LibGfx/ICC/TagTypes.cpp
+++ b/Userland/Libraries/LibGfx/ICC/TagTypes.cpp
@@ -530,6 +530,20 @@ ErrorOr<NonnullRefPtr<TextDescriptionTagData>> TextDescriptionTagData::from_byte
return adopt_ref(*new TextDescriptionTagData(offset, size, TRY(String::from_utf8(ascii_description)), unicode_language_code, move(unicode_description), move(macintosh_description)));
}
+ErrorOr<NonnullRefPtr<SignatureTagData>> SignatureTagData::from_bytes(ReadonlyBytes bytes, u32 offset, u32 size)
+{
+ // ICC v4, 10.23 signatureType
+ VERIFY(tag_type(bytes) == Type);
+ TRY(check_reserved(bytes));
+
+ if (bytes.size() < 3 * sizeof(u32))
+ return Error::from_string_literal("ICC::Profile: signatureType has not enough data");
+
+ u32 signature = *bit_cast<BigEndian<u32> const*>(bytes.data() + 8);
+
+ return adopt_ref(*new SignatureTagData(offset, size, signature));
+}
+
ErrorOr<NonnullRefPtr<TextTagData>> TextTagData::from_bytes(ReadonlyBytes bytes, u32 offset, u32 size)
{
// ICC v4, 10.24 textType
diff --git a/Userland/Libraries/LibGfx/ICC/TagTypes.h b/Userland/Libraries/LibGfx/ICC/TagTypes.h
index 9fd56484c0..9c3b3969a4 100644
--- a/Userland/Libraries/LibGfx/ICC/TagTypes.h
+++ b/Userland/Libraries/LibGfx/ICC/TagTypes.h
@@ -464,6 +464,25 @@ private:
Optional<String> m_macintosh_description;
};
+// ICC v4, 10.23 signatureType
+class SignatureTagData : public TagData {
+public:
+ static constexpr TagTypeSignature Type { 0x73696720 }; // 'sig '
+
+ static ErrorOr<NonnullRefPtr<SignatureTagData>> from_bytes(ReadonlyBytes, u32 offset, u32 size);
+
+ SignatureTagData(u32 offset, u32 size, u32 signature)
+ : TagData(offset, size, Type)
+ , m_signature(signature)
+ {
+ }
+
+ u32 signature() const { return m_signature; }
+
+private:
+ u32 m_signature;
+};
+
// ICC v4, 10.24 textType
class TextTagData : public TagData {
public:
diff --git a/Userland/Utilities/icc.cpp b/Userland/Utilities/icc.cpp
index 3f3f67107a..e0c43c68b5 100644
--- a/Userland/Utilities/icc.cpp
+++ b/Userland/Utilities/icc.cpp
@@ -229,6 +229,16 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
i++;
}
outln(" ]");
+ } else if (tag_data->type() == Gfx::ICC::SignatureTagData::Type) {
+ auto& signature = static_cast<Gfx::ICC::SignatureTagData&>(*tag_data);
+
+ // FIXME: For colorimetricIntentImageStateTag, interpret signature according to ICC v4 Table 26
+ // FIXME: For perceptualRenderingIntentGamutTag, interpret signature according to ICC v4 Table 27
+ // FIXME: For saturationRenderingIntentGamutTag, interpret signature according to ICC v4 Table 28
+ // FIXME: For technologyTag, interpret signature according to ICC v4 Table 29
+ outln(" signature: '{:c}{:c}{:c}{:c}' / 0x{:08x}",
+ signature.signature() >> 24, (signature.signature() >> 16) & 0xff, (signature.signature() >> 8) & 0xff, signature.signature() & 0xff,
+ signature.signature());
} else if (tag_data->type() == Gfx::ICC::TextDescriptionTagData::Type) {
auto& text_description = static_cast<Gfx::ICC::TextDescriptionTagData&>(*tag_data);
outln(" ascii: \"{}\"", text_description.ascii_description());