diff options
author | Nico Weber <thakis@chromium.org> | 2023-02-17 22:10:07 -0500 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-02-19 00:01:44 +0100 |
commit | 22c0e6b60ee791c8109814a91322a3bf47a91cd9 (patch) | |
tree | d37e7cf1ca1915db524e9ffff7d6684f0925c0cf | |
parent | 8e5392f9c03df30162fbf45cb0ba39f8b586c527 (diff) | |
download | serenity-22c0e6b60ee791c8109814a91322a3bf47a91cd9.zip |
LibGfx: Implement serialization of MeasurementTagData
-rw-r--r-- | Userland/Libraries/LibGfx/ICC/BinaryWriter.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGfx/ICC/BinaryWriter.cpp b/Userland/Libraries/LibGfx/ICC/BinaryWriter.cpp index f4a9d68101..d08b89d381 100644 --- a/Userland/Libraries/LibGfx/ICC/BinaryWriter.cpp +++ b/Userland/Libraries/LibGfx/ICC/BinaryWriter.cpp @@ -62,6 +62,23 @@ static ErrorOr<ByteBuffer> encode_curve(CurveTagData const& tag_data) return bytes; } +static ErrorOr<ByteBuffer> encode_measurement(MeasurementTagData const& tag_data) +{ + // ICC v4, 10.14 measurementType + auto bytes = TRY(ByteBuffer::create_uninitialized(2 * sizeof(u32) + sizeof(MeasurementHeader))); + *bit_cast<BigEndian<u32>*>(bytes.data()) = (u32)MeasurementTagData::Type; + *bit_cast<BigEndian<u32>*>(bytes.data() + 4) = 0; + + auto& header = *bit_cast<MeasurementHeader*>(bytes.data() + 8); + header.standard_observer = tag_data.standard_observer(); + header.tristimulus_value_for_measurement_backing = tag_data.tristimulus_value_for_measurement_backing(); + header.measurement_geometry = tag_data.measurement_geometry(); + header.measurement_flare = tag_data.measurement_flare().raw(); + header.standard_illuminant = tag_data.standard_illuminant(); + + return bytes; +} + static ErrorOr<ByteBuffer> encode_multi_localized_unicode(MultiLocalizedUnicodeTagData const& tag_data) { // ICC v4, 10.15 multiLocalizedUnicodeType @@ -186,6 +203,8 @@ static ErrorOr<ByteBuffer> encode_tag_data(TagData const& tag_data) return encode_cipc(static_cast<CicpTagData const&>(tag_data)); case CurveTagData::Type: return encode_curve(static_cast<CurveTagData const&>(tag_data)); + case MeasurementTagData::Type: + return encode_measurement(static_cast<MeasurementTagData const&>(tag_data)); case MultiLocalizedUnicodeTagData::Type: return encode_multi_localized_unicode(static_cast<MultiLocalizedUnicodeTagData const&>(tag_data)); case ParametricCurveTagData::Type: |