summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2023-02-17 20:42:20 -0500
committerAndreas Kling <kling@serenityos.org>2023-02-19 00:01:44 +0100
commit685e2da30221352c3d89142b83c59c375b6de6a0 (patch)
treeb434799bed6b2dc014087f97b05d8e2eee4c5ea1 /Userland
parent931594fce3c40565c598d7baa6c71fd524634ba5 (diff)
downloadserenity-685e2da30221352c3d89142b83c59c375b6de6a0.zip
LibGfx: Implement serialization of S15Fixed16ArrayTagData
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibGfx/ICC/BinaryWriter.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGfx/ICC/BinaryWriter.cpp b/Userland/Libraries/LibGfx/ICC/BinaryWriter.cpp
index c2df74b08c..8467f7a894 100644
--- a/Userland/Libraries/LibGfx/ICC/BinaryWriter.cpp
+++ b/Userland/Libraries/LibGfx/ICC/BinaryWriter.cpp
@@ -60,6 +60,20 @@ static ErrorOr<ByteBuffer> encode_multi_localized_unicode(MultiLocalizedUnicodeT
return bytes;
}
+static ErrorOr<ByteBuffer> encode_s15_fixed_array(S15Fixed16ArrayTagData const& tag_data)
+{
+ // ICC v4, 10.22 s15Fixed16ArrayType
+ auto bytes = TRY(ByteBuffer::create_uninitialized(2 * sizeof(u32) + tag_data.values().size() * sizeof(s15Fixed16Number)));
+ *bit_cast<BigEndian<u32>*>(bytes.data()) = (u32)S15Fixed16ArrayTagData::Type;
+ *bit_cast<BigEndian<u32>*>(bytes.data() + 4) = 0;
+
+ auto* values = bit_cast<BigEndian<s15Fixed16Number>*>(bytes.data() + 8);
+ for (size_t i = 0; i < tag_data.values().size(); ++i)
+ values[i] = tag_data.values()[i].raw();
+
+ return bytes;
+}
+
static ErrorOr<ByteBuffer> encode_xyz(XYZTagData const& tag_data)
{
// ICC v4, 10.31 XYZType
@@ -79,6 +93,8 @@ static ErrorOr<ByteBuffer> encode_tag_data(TagData const& tag_data)
switch (tag_data.type()) {
case MultiLocalizedUnicodeTagData::Type:
return encode_multi_localized_unicode(static_cast<MultiLocalizedUnicodeTagData const&>(tag_data));
+ case S15Fixed16ArrayTagData::Type:
+ return encode_s15_fixed_array(static_cast<S15Fixed16ArrayTagData const&>(tag_data));
case XYZTagData::Type:
return encode_xyz(static_cast<XYZTagData const&>(tag_data));
}