Crate srgb[−][src]
The crate provides primitives for manipulating colours in sRGB colour space. Specifically, it provides functions for converting between sRGB space, linear sRGB space and XYZ colour space; as well as exposes the definition of D65 reference white point as well as XYZ colour conversion matrices.
The crate intents to provide low-level primitives needed to work with sRGB colour space. Those primitives can be used by other libraries which need to convert between sRGB and other colour spaces (if the conversion requires going through XYZ colour space) or blend colours together (which requires performing gamma correction).
Functions provided in the main module implement conversions between sRGB and
XYZ colour spaces while providing routines for intermediate conversions.
Functions in gamma
submodule provide functions for doing gamma
compression and expansion; they operate on a single colour component.
Lastly, xyz
submodule provides functions for converting between linear
sRGB and XYZ colour spaces as well as constants exposing the matrices used
by those functions.
Re-exports
pub use xyz::linear_from_xyz; | |
pub use xyz::xyz_from_linear; |
Modules
gamma | Functions implementing sRGB gamma compression and expansion formulæ. |
xyz | Functions and constant handling and related to conversion between linear sRGB space and CIE XYZ colour space. |
Functions
linear_from_normalised | Converts an sRGB colour in normalised representation into linear space. That is, performs gamma expansion on each component (which should be in 0–1 range) and returns the colour in linear space. |
linear_from_u8 | Converts a 24-bit sRGB colour (also known as true colour) into linear space. That is, performs gamma expansion on each component and returns the colour in linear sRGB space with each component normalised to the range 0–1. |
normalised_from_linear | Converts an sRGB colour in linear space to normalised space. That is, performs gamma compression on each component (which should be in 0–1 range) and encodes each component as an 8-bit integer. |
normalised_from_u8 | Converts a 24-bit sRGB colour (also known as true colour) into normalised representation. Returns three components each normalised to the range 0–1. |
u8_from_linear | Converts an sRGB colour in linear space to a 24-bit sRGB colour (also known as true colour). That is, performs gamma compression on each component and encodes each component as an 8-bit integer. |
u8_from_normalised | Converts an sRGB colour in normalised representation into a 24-bit (also known as true colour). That is, converts sRGB representation where each component is a number in the range from zero to one to one where each component is an 8-bit unsigned integer. Components in source colour are clamped to the valid range. |