mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:47:35 +00:00
LibGfx: Extract encode_header() function in ICC writing code
This commit is contained in:
parent
743b6e8781
commit
026d9ceaf9
1 changed files with 12 additions and 6 deletions
|
@ -11,13 +11,8 @@
|
|||
|
||||
namespace Gfx::ICC {
|
||||
|
||||
ErrorOr<ByteBuffer> encode(Profile const& profile)
|
||||
static ErrorOr<void> encode_header(ByteBuffer& bytes, Profile const& profile)
|
||||
{
|
||||
|
||||
// Leaves enough room for the profile header and the tag table count.
|
||||
// FIXME: Serialize tag data and write tag table and tag data too.
|
||||
auto bytes = TRY(ByteBuffer::create_zeroed(sizeof(ICCHeader) + sizeof(u32)));
|
||||
|
||||
VERIFY(bytes.size() >= sizeof(ICCHeader));
|
||||
auto& raw_header = *bit_cast<ICCHeader*>(bytes.data());
|
||||
|
||||
|
@ -62,6 +57,17 @@ ErrorOr<ByteBuffer> encode(Profile const& profile)
|
|||
static_assert(sizeof(id.data) == sizeof(raw_header.profile_id));
|
||||
memcpy(raw_header.profile_id, id.data, sizeof(id.data));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<ByteBuffer> encode(Profile const& profile)
|
||||
{
|
||||
// Leaves enough room for the profile header and the tag table count.
|
||||
// FIXME: Serialize tag data and write tag table and tag data too.
|
||||
auto bytes = TRY(ByteBuffer::create_zeroed(sizeof(ICCHeader) + sizeof(u32)));
|
||||
|
||||
TRY(encode_header(bytes, profile));
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue