Expand description
Cleanroom ICC profile parser and colour transform (ICC.1:2010, v2 and v4 profiles) for pdfboss.
parse reads a profile’s header, tag table, and default device-to-PCS
transform: matrix/TRC and grayTRC models (Annex F), or an A2B0 lookup
transform (lut8Type, lut16Type, lutAToBType). Profile::transform then
maps device components to non-linear sRGB in 0..=1: PCS values are
chromatically adapted from the D50 PCS illuminant to D65 with the linear
Bradford matrix (Annex E) and converted through the IEC 61966-2-1 primary
matrix and transfer. Everything is combined at parse time; a transform
call is curve lookups, one 3x3 multiply, and the sRGB encode, with no
allocation.
A 3-channel matrix/TRC profile whose composed transform is the identity
within SRGB_TOLERANCE at the probe points reports
DeviceSpace::Rgb from Profile::device_equivalent (a gray profile
analogously reports DeviceSpace::Gray), so callers can keep painting
in device space. Only the profile’s default transform is used; rendering
intents are not switched.
Structs§
- Profile
- A parsed profile: its device channel count and compiled transform.
Enums§
- Device
Space - The device space a profile’s transform is indistinguishable from.
- IccError
- Why a profile would not parse.
Constants§
- D50
- The nCIEXYZ values of the PCS illuminant (D50), ICC.1:2010 clause 7.2.16.
- SRGB_
TOLERANCE - Per-channel tolerance for the composed-identity probe behind
Profile::device_equivalent: about 2,5 steps of 8-bit output. A pure gamma-2,2 curve misses the sRGB transfer by ~0,03 at 1/16 input, so it honestly fails.
Functions§
- lab_
to_ xyz - CIE Lab* to XYZ relative to
white, per the CIE definition used by ISO 32000-1 clause 8.6.5.4: the inverse transfer g(t) = t^3 above 6/29 continues linearly with slope 108/841 below it. - mat_
apply - Applies a 3x3 matrix to a column vector.
- mat_mul
- Row-major 3x3 matrix product.
- parse
- Parses an ICC profile and compiles its default device-to-sRGB transform.
- srgb_
encode - The IEC 61966-2-1 sRGB opto-electronic transfer: linear 0..=1 in, non-linear 0..=1 out. Out-of-range and non-finite inputs clamp.
- xyz_
to_ linear_ srgb - Matrix taking XYZ relative to
whiteto linear sRGB: Bradford adaptation to D65 followed by the sRGB primary matrix.
Type Aliases§
- Mat3
- A row-major 3x3 matrix.