mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 09:39:39 +00:00
LibGfx: Fix ICC v2 profiles with table-based L* curves
Skia's SkColorSpace::Make() doesn't seem to like ICC v2 profiles containing table-based L* transfer curves. Now we use skcms_ApproximateCurve() to convert these tables to parametric curves that Skia supports in case Skia's SkColorSpace::Make() fails.
This commit is contained in:
parent
c4fadc1abf
commit
bfc79a403d
Notes:
github-actions[bot]
2025-06-16 09:32:41 +00:00
Author: https://github.com/aplefull
Commit: bfc79a403d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4977
Reviewed-by: https://github.com/gmta ✅
1 changed files with 14 additions and 1 deletions
|
@ -101,7 +101,20 @@ ErrorOr<ColorSpace> ColorSpace::load_from_icc_bytes(ReadonlyBytes icc_bytes)
|
|||
if (!skcms_Parse(icc_bytes.data(), icc_bytes.size(), &icc_profile))
|
||||
return Error::from_string_literal("Failed to parse the ICC profile");
|
||||
|
||||
return ColorSpace { make<Details::ColorSpaceImpl>(SkColorSpace::Make(icc_profile)) };
|
||||
auto color_space_result = SkColorSpace::Make(icc_profile);
|
||||
|
||||
if (!color_space_result) {
|
||||
if (icc_profile.has_trc && icc_profile.has_toXYZD50) {
|
||||
skcms_TransferFunction transfer_function;
|
||||
float max_error;
|
||||
|
||||
if (skcms_ApproximateCurve(&icc_profile.trc[0], &transfer_function, &max_error)) {
|
||||
color_space_result = SkColorSpace::MakeRGB(transfer_function, icc_profile.toXYZD50);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ColorSpace { make<Details::ColorSpaceImpl>(color_space_result) };
|
||||
}
|
||||
return ColorSpace {};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue