diff options
author | Nico Weber <thakis@chromium.org> | 2023-02-17 21:25:27 -0500 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-02-19 00:01:44 +0100 |
commit | 1ca7f109a17141badffe3c84e2d6830664da5e7a (patch) | |
tree | eff4b0ce2e87f5d4523548333a6801a6f985cca4 /Userland | |
parent | fd590fe55dd046a6f624345b119cc97dfe45b540 (diff) | |
download | serenity-1ca7f109a17141badffe3c84e2d6830664da5e7a.zip |
LibGfx: Implement serialization of CicpTagData
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGfx/ICC/BinaryWriter.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGfx/ICC/BinaryWriter.cpp b/Userland/Libraries/LibGfx/ICC/BinaryWriter.cpp index 294c90ec3d..a6d23d5f9f 100644 --- a/Userland/Libraries/LibGfx/ICC/BinaryWriter.cpp +++ b/Userland/Libraries/LibGfx/ICC/BinaryWriter.cpp @@ -34,6 +34,19 @@ static ErrorOr<ByteBuffer> encode_chromaticity(ChromaticityTagData const& tag_da return bytes; } +static ErrorOr<ByteBuffer> encode_cipc(CicpTagData const& tag_data) +{ + // ICC v4, 10.3 cicpType + auto bytes = TRY(ByteBuffer::create_uninitialized(2 * sizeof(u32) + 4)); + *bit_cast<BigEndian<u32>*>(bytes.data()) = (u32)CicpTagData::Type; + *bit_cast<BigEndian<u32>*>(bytes.data() + 4) = 0; + bytes.data()[8] = tag_data.color_primaries(); + bytes.data()[9] = tag_data.transfer_characteristics(); + bytes.data()[10] = tag_data.matrix_coefficients(); + bytes.data()[11] = tag_data.video_full_range_flag(); + return bytes; +} + static ErrorOr<ByteBuffer> encode_multi_localized_unicode(MultiLocalizedUnicodeTagData const& tag_data) { // ICC v4, 10.15 multiLocalizedUnicodeType @@ -130,6 +143,8 @@ static ErrorOr<ByteBuffer> encode_tag_data(TagData const& tag_data) switch (tag_data.type()) { case ChromaticityTagData::Type: return encode_chromaticity(static_cast<ChromaticityTagData const&>(tag_data)); + case CicpTagData::Type: + return encode_cipc(static_cast<CicpTagData const&>(tag_data)); case MultiLocalizedUnicodeTagData::Type: return encode_multi_localized_unicode(static_cast<MultiLocalizedUnicodeTagData const&>(tag_data)); case ParametricCurveTagData::Type: |