Transform converts device RGB from a matrix/TRC profile to sRGB. It holds the per-channel linearisation curves and the single precomputed matrix that maps linear device RGB straight to linear sRGB.
type Transform struct {
// contains filtered or unexported fields
}
func NewTransform(profile []byte) (*Transform, error)
NewTransform parses an ICC profile and builds a matrix/TRC -> sRGB transform. It returns an error when the profile is corrupt or is not a supported matrix/TRC RGB profile; in either case the caller falls back to its existing colour handling. The returned Transform is immutable and safe for concurrent use.
func (t *Transform) Convert(r, g, b float64) (sr, sg, sb float64)
Convert maps one normalised device-RGB triple (each component in [0,1]) to normalised sRGB (each component in [0,1]). It linearises each channel through its TRC, applies the combined matrix to reach linear sRGB, then applies the sRGB encoding transfer function. Out-of-gamut and non-finite intermediate values are clamped, so the result is always within [0,1].
func (t *Transform) EncodeLinear(lr, lg, lb float64) (sr, sg, sb float64)
EncodeLinear applies the combined colorant/adaptation matrix and the sRGB encoding transfer function to a TRC-linearised device-RGB triple, returning normalised sRGB. It is the second half of Convert.
func (t *Transform) LinearizeChannel(channel int, x float64) float64
LinearizeChannel applies the per-channel TRC linearisation to a single normalised device value, where channel is 0=red, 1=green, 2=blue. It is the linearisation half of Convert, exposed so callers can precompute per-channel lookup tables.