summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2023-02-17 21:30:43 -0500
committerAndreas Kling <kling@serenityos.org>2023-02-19 00:01:44 +0100
commit3690305794de2f9a8ed51fa71f3201ccf41efabb (patch)
treef8034f6b64e52a66e25c25541539c3c5fef71ab5 /Userland
parent1ca7f109a17141badffe3c84e2d6830664da5e7a (diff)
downloadserenity-3690305794de2f9a8ed51fa71f3201ccf41efabb.zip
LibGfx: Implement serialization of CurveTagData
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibGfx/ICC/BinaryWriter.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGfx/ICC/BinaryWriter.cpp b/Userland/Libraries/LibGfx/ICC/BinaryWriter.cpp
index a6d23d5f9f..02c4d0c7be 100644
--- a/Userland/Libraries/LibGfx/ICC/BinaryWriter.cpp
+++ b/Userland/Libraries/LibGfx/ICC/BinaryWriter.cpp
@@ -47,6 +47,21 @@ static ErrorOr<ByteBuffer> encode_cipc(CicpTagData const& tag_data)
return bytes;
}
+static ErrorOr<ByteBuffer> encode_curve(CurveTagData const& tag_data)
+{
+ // ICC v4, 10.6 curveType
+ auto bytes = TRY(ByteBuffer::create_uninitialized(3 * sizeof(u32) + tag_data.values().size() * sizeof(u16)));
+ *bit_cast<BigEndian<u32>*>(bytes.data()) = (u32)CurveTagData::Type;
+ *bit_cast<BigEndian<u32>*>(bytes.data() + 4) = 0;
+ *bit_cast<BigEndian<u32>*>(bytes.data() + 8) = tag_data.values().size();
+
+ auto* values = bit_cast<BigEndian<u16>*>(bytes.data() + 12);
+ for (size_t i = 0; i < tag_data.values().size(); ++i)
+ values[i] = tag_data.values()[i];
+
+ return bytes;
+}
+
static ErrorOr<ByteBuffer> encode_multi_localized_unicode(MultiLocalizedUnicodeTagData const& tag_data)
{
// ICC v4, 10.15 multiLocalizedUnicodeType
@@ -145,6 +160,8 @@ static ErrorOr<ByteBuffer> encode_tag_data(TagData const& tag_data)
return encode_chromaticity(static_cast<ChromaticityTagData const&>(tag_data));
case CicpTagData::Type:
return encode_cipc(static_cast<CicpTagData const&>(tag_data));
+ case CurveTagData::Type:
+ return encode_curve(static_cast<CurveTagData const&>(tag_data));
case MultiLocalizedUnicodeTagData::Type:
return encode_multi_localized_unicode(static_cast<MultiLocalizedUnicodeTagData const&>(tag_data));
case ParametricCurveTagData::Type: