diff options
-rw-r--r-- | Userland/Libraries/LibGfx/ICC/BinaryWriter.cpp | 16 |
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)); } |