mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:17:44 +00:00
LibGfx: Store profile id MD5 in ICCProfile
This commit is contained in:
parent
c10a02c405
commit
d5c8c90ff0
2 changed files with 21 additions and 0 deletions
|
@ -233,6 +233,23 @@ ErrorOr<XYZ> parse_pcs_illuminant(ICCHeader const& header)
|
||||||
|
|
||||||
return xyz;
|
return xyz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Optional<Crypto::Hash::MD5::DigestType> parse_profile_id(ICCHeader const& header)
|
||||||
|
{
|
||||||
|
// ICC v4, 7.2.18 Profile ID field
|
||||||
|
// "A profile ID field value of zero (00h) shall indicate that a profile ID has not been calculated."
|
||||||
|
bool did_calculate_profile_id = false;
|
||||||
|
for (u8 b : header.profile_md5)
|
||||||
|
if (b != 0)
|
||||||
|
did_calculate_profile_id = true;
|
||||||
|
if (!did_calculate_profile_id)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
Crypto::Hash::MD5::DigestType md5;
|
||||||
|
static_assert(sizeof(md5.data) == sizeof(header.profile_md5));
|
||||||
|
memcpy(md5.data, header.profile_md5, sizeof(md5.data));
|
||||||
|
return md5;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StringView device_class_name(DeviceClass device_class)
|
StringView device_class_name(DeviceClass device_class)
|
||||||
|
@ -364,6 +381,7 @@ ErrorOr<NonnullRefPtr<Profile>> Profile::try_load_from_externally_owned_memory(R
|
||||||
profile->m_flags = Flags { header.profile_flags };
|
profile->m_flags = Flags { header.profile_flags };
|
||||||
profile->m_rendering_intent = TRY(parse_rendering_intent(header));
|
profile->m_rendering_intent = TRY(parse_rendering_intent(header));
|
||||||
profile->m_pcs_illuminant = TRY(parse_pcs_illuminant(header));
|
profile->m_pcs_illuminant = TRY(parse_pcs_illuminant(header));
|
||||||
|
profile->m_id = parse_profile_id(header);
|
||||||
|
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <AK/NonnullRefPtr.h>
|
#include <AK/NonnullRefPtr.h>
|
||||||
#include <AK/RefCounted.h>
|
#include <AK/RefCounted.h>
|
||||||
#include <AK/Span.h>
|
#include <AK/Span.h>
|
||||||
|
#include <LibCrypto/Hash/MD5.h>
|
||||||
|
|
||||||
namespace Gfx::ICC {
|
namespace Gfx::ICC {
|
||||||
|
|
||||||
|
@ -136,6 +137,7 @@ public:
|
||||||
Flags flags() const { return m_flags; }
|
Flags flags() const { return m_flags; }
|
||||||
RenderingIntent rendering_intent() const { return m_rendering_intent; }
|
RenderingIntent rendering_intent() const { return m_rendering_intent; }
|
||||||
const XYZ& pcs_illuminant() const { return m_pcs_illuminant; }
|
const XYZ& pcs_illuminant() const { return m_pcs_illuminant; }
|
||||||
|
Optional<Crypto::Hash::MD5::DigestType> const& id() const { return m_id; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Version m_version;
|
Version m_version;
|
||||||
|
@ -146,6 +148,7 @@ private:
|
||||||
Flags m_flags;
|
Flags m_flags;
|
||||||
RenderingIntent m_rendering_intent;
|
RenderingIntent m_rendering_intent;
|
||||||
XYZ m_pcs_illuminant;
|
XYZ m_pcs_illuminant;
|
||||||
|
Optional<Crypto::Hash::MD5::DigestType> m_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue