mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 14:37:45 +00:00
LibGfx/ICC: Make mAB tags work for profiles that use PCSLAB
ICC profiles work by transforming from the input color space (one of many: RGB, CMYK, YUV, etc) to a "profile connection space" (PCS) and then from there to the output color space. However, there's not one but two possible profile connection spaces, PCSXYZ and PCSLAB. The matrix/curve tags can only be used with PCSXYZ, but the mAB, mBA, mft1, mft2 tags can be used with PCSLAB as well. The PCSLAB encoding has L going from 0 to 100 and ab from -128 to 127, instead of from 0 to 1. So they need to be scaled up at the end. That's also the reason for the "mystery conversion factor": PCSXYZ doesn't go from 0 to 1 either, but from 0 to 65535/32768, per ICC v4 6.3.4.2 General PCS encoding, Table 11 - PCSXYZ X, Y or Z encoding. Between input and output are various curves (and the CLUT) that have domain and range of 0..1. For these, the color has to be linearly scaled to 0..1 before the curve and back to the actual range after the curve. Doing that back-to-back is a no-op, so scaling back at the very end is sufficient.
This commit is contained in:
parent
64ffae9c55
commit
fda9840f48
2 changed files with 29 additions and 17 deletions
|
@ -1227,7 +1227,7 @@ ErrorOr<FloatVector3> Profile::to_pcs_a_to_b(TagData const& tag_data, ReadonlyBy
|
|||
if (a_to_b.number_of_output_channels() != number_of_components_in_color_space(connection_space()))
|
||||
return Error::from_string_literal("ICC::Profile::to_pcs_a_to_b: mAB output channel count does not match profile connection space size");
|
||||
|
||||
return a_to_b.evaluate(color);
|
||||
return a_to_b.evaluate(connection_space(), color);
|
||||
}
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue