summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx/ICC
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2023-03-05 11:28:21 -0500
committerLinus Groh <mail@linusgroh.de>2023-03-05 18:21:43 +0000
commitefabfd4c66b932e65fde7c07e7f50d7734b4b68a (patch)
tree95a0aab24a9e942ded650bc9fedeb937ff49869c /Userland/Libraries/LibGfx/ICC
parentbe1d7c325a5e2483038f82d2303a9de3a007be5d (diff)
downloadserenity-efabfd4c66b932e65fde7c07e7f50d7734b4b68a.zip
LibGfx: Fill in remaining values in built-in sRGB profile
The values aren't 100% self-consistent, but it probably doesn't make a difference for u8 color data. Good enough for now. See all the links on #17714 for some more background.
Diffstat (limited to 'Userland/Libraries/LibGfx/ICC')
-rw-r--r--Userland/Libraries/LibGfx/ICC/WellKnownProfiles.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/Userland/Libraries/LibGfx/ICC/WellKnownProfiles.cpp b/Userland/Libraries/LibGfx/ICC/WellKnownProfiles.cpp
index 389c40c7b7..7b420b530a 100644
--- a/Userland/Libraries/LibGfx/ICC/WellKnownProfiles.cpp
+++ b/Userland/Libraries/LibGfx/ICC/WellKnownProfiles.cpp
@@ -43,7 +43,7 @@ ErrorOr<NonnullRefPtr<Profile>> sRGB()
// Returns an sRGB profile.
// https://en.wikipedia.org/wiki/SRGB
- // FIXME: There's a surprising amount of variety in sRGB ICC profiles in the wild.
+ // FIXME: There are many different sRGB ICC profiles in the wild.
// Explain why, and why this picks the numbers it does.
auto header = rgb_header();
@@ -61,16 +61,23 @@ ErrorOr<NonnullRefPtr<Profile>> sRGB()
TRY(tag_table.try_set(greenTRCTag, curve));
TRY(tag_table.try_set(blueTRCTag, curve));
- // Chromatic adaptation matrix, chromacities and whitepoint.
- // FIXME: Actual values for chromatic adaptation matrix and chromacities.
- TRY(tag_table.try_set(mediaWhitePointTag, TRY(XYZ_data(XYZ { 0, 0, 0 }))));
- TRY(tag_table.try_set(redMatrixColumnTag, TRY(XYZ_data(XYZ { 0, 0, 0 }))));
- TRY(tag_table.try_set(greenMatrixColumnTag, TRY(XYZ_data(XYZ { 0, 0, 0 }))));
- TRY(tag_table.try_set(blueMatrixColumnTag, TRY(XYZ_data(XYZ { 0, 0, 0 }))));
+ // White point.
+ // ICC v4, 9.2.36 mediaWhitePointTag: " For displays, the values specified shall be those of the PCS illuminant as defined in 7.2.16."
+ TRY(tag_table.try_set(mediaWhitePointTag, TRY(XYZ_data(header.pcs_illuminant))));
- Vector<S15Fixed16, 9> chromatic_adaptation_matrix = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ // The chromatic_adaptation_matrix values are from https://www.color.org/chadtag.xalter
+ // That leads to exactly the S15Fixed16 values in the sRGB profiles in GIMP, Android, RawTherapee (but not in Compact-ICC-Profiles's v4 sRGB profile).
+ Vector<S15Fixed16, 9> chromatic_adaptation_matrix = { 1.047882, 0.022918, -0.050217, 0.029586, 0.990478, -0.017075, -0.009247, 0.015075, 0.751678 };
TRY(tag_table.try_set(chromaticAdaptationTag, TRY(try_make_ref_counted<S15Fixed16ArrayTagData>(0, 0, move(chromatic_adaptation_matrix)))));
+ // The chromaticity values are from https://www.color.org/srgb.pdf
+ // The chromatic adaptation matrix in that document is slightly different from the one on https://www.color.org/chadtag.xalter,
+ // so the values in our sRGB profile are currently not fully self-consistent.
+ // FIXME: Make values self-consistent (probably by using slightly different chromaticities).
+ TRY(tag_table.try_set(redMatrixColumnTag, TRY(XYZ_data(XYZ { 0.436030342570117, 0.222438466210245, 0.013897440074263 }))));
+ TRY(tag_table.try_set(greenMatrixColumnTag, TRY(XYZ_data(XYZ { 0.385101860087134, 0.716942745571917, 0.097076381494207 }))));
+ TRY(tag_table.try_set(blueMatrixColumnTag, TRY(XYZ_data(XYZ { 0.143067806654203, 0.060618777416563, 0.713926257896652 }))));
+
return Profile::create(header, move(tag_table));
}