mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:27:35 +00:00
LibGfx: Extract all_bytes_are_zero() function in ICCProfile
This commit is contained in:
parent
aa107ef2d6
commit
090bd02a88
1 changed files with 11 additions and 5 deletions
|
@ -234,15 +234,21 @@ ErrorOr<XYZ> parse_pcs_illuminant(ICCHeader const& header)
|
||||||
return xyz;
|
return xyz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<size_t N>
|
||||||
|
bool all_bytes_are_zero(const u8 (&bytes)[N])
|
||||||
|
{
|
||||||
|
for (u8 byte : bytes) {
|
||||||
|
if (byte != 0)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Optional<Crypto::Hash::MD5::DigestType> parse_profile_id(ICCHeader const& header)
|
Optional<Crypto::Hash::MD5::DigestType> parse_profile_id(ICCHeader const& header)
|
||||||
{
|
{
|
||||||
// ICC v4, 7.2.18 Profile ID field
|
// 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."
|
// "A profile ID field value of zero (00h) shall indicate that a profile ID has not been calculated."
|
||||||
bool did_calculate_profile_id = false;
|
if (all_bytes_are_zero(header.profile_id))
|
||||||
for (u8 b : header.profile_id)
|
|
||||||
if (b != 0)
|
|
||||||
did_calculate_profile_id = true;
|
|
||||||
if (!did_calculate_profile_id)
|
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
Crypto::Hash::MD5::DigestType md5;
|
Crypto::Hash::MD5::DigestType md5;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue