mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:47:45 +00:00
LibGfx/ICC: Extract sRGB_curve() function
This returns just the tone reproduction curve of the sRGB profile.
This commit is contained in:
parent
5da9057a8f
commit
5df35d030f
2 changed files with 10 additions and 3 deletions
|
@ -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));
|
||||
|
|
|
@ -15,4 +15,6 @@ class Profile;
|
|||
|
||||
ErrorOr<NonnullRefPtr<Profile>> sRGB();
|
||||
|
||||
ErrorOr<NonnullRefPtr<TagData>> sRGB_curve();
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue