diff options
author | Nico Weber <thakis@chromium.org> | 2023-04-11 08:53:28 -0400 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-04-11 18:23:07 +0200 |
commit | 5df35d030fce99ea0926d773630cc5d3e9c40752 (patch) | |
tree | a6fc65282ed77d5b5ffeeec832c740711d595dc4 /Userland/Libraries/LibGfx | |
parent | 5da9057a8f48f8a6cc6a46bbb00407059cbe4a2a (diff) | |
download | serenity-5df35d030fce99ea0926d773630cc5d3e9c40752.zip |
LibGfx/ICC: Extract sRGB_curve() function
This returns just the tone reproduction curve of the sRGB profile.
Diffstat (limited to 'Userland/Libraries/LibGfx')
-rw-r--r-- | Userland/Libraries/LibGfx/ICC/WellKnownProfiles.cpp | 11 | ||||
-rw-r--r-- | Userland/Libraries/LibGfx/ICC/WellKnownProfiles.h | 2 |
2 files changed, 10 insertions, 3 deletions
diff --git a/Userland/Libraries/LibGfx/ICC/WellKnownProfiles.cpp b/Userland/Libraries/LibGfx/ICC/WellKnownProfiles.cpp index 3300aac428..26d04870f0 100644 --- a/Userland/Libraries/LibGfx/ICC/WellKnownProfiles.cpp +++ b/Userland/Libraries/LibGfx/ICC/WellKnownProfiles.cpp @@ -38,6 +38,13 @@ static ErrorOr<NonnullRefPtr<XYZTagData>> XYZ_data(XYZ xyz) return try_make_ref_counted<XYZTagData>(0, 0, move(xyzs)); } +ErrorOr<NonnullRefPtr<TagData>> sRGB_curve() +{ + // Numbers from https://en.wikipedia.org/wiki/SRGB#From_sRGB_to_CIE_XYZ + Array<S15Fixed16, 7> curve_parameters = { 2.4, 1 / 1.055, 0.055 / 1.055, 1 / 12.92, 0.04045 }; + return try_make_ref_counted<ParametricCurveTagData>(0, 0, ParametricCurveTagData::FunctionType::sRGB, curve_parameters); +} + ErrorOr<NonnullRefPtr<Profile>> sRGB() { // Returns an sRGB profile. @@ -54,9 +61,7 @@ ErrorOr<NonnullRefPtr<Profile>> sRGB() TRY(tag_table.try_set(copyrightTag, TRY(en_US("Public Domain"sv)))); // Transfer function. - // Numbers from https://en.wikipedia.org/wiki/SRGB#From_sRGB_to_CIE_XYZ - Array<S15Fixed16, 7> curve_parameters = { 2.4, 1 / 1.055, 0.055 / 1.055, 1 / 12.92, 0.04045 }; - auto curve = TRY(try_make_ref_counted<ParametricCurveTagData>(0, 0, ParametricCurveTagData::FunctionType::sRGB, curve_parameters)); + auto curve = TRY(sRGB_curve()); TRY(tag_table.try_set(redTRCTag, curve)); TRY(tag_table.try_set(greenTRCTag, curve)); TRY(tag_table.try_set(blueTRCTag, curve)); diff --git a/Userland/Libraries/LibGfx/ICC/WellKnownProfiles.h b/Userland/Libraries/LibGfx/ICC/WellKnownProfiles.h index aedbc14973..40cb7f6427 100644 --- a/Userland/Libraries/LibGfx/ICC/WellKnownProfiles.h +++ b/Userland/Libraries/LibGfx/ICC/WellKnownProfiles.h @@ -15,4 +15,6 @@ class Profile; ErrorOr<NonnullRefPtr<Profile>> sRGB(); +ErrorOr<NonnullRefPtr<TagData>> sRGB_curve(); + } |