Function rasterize::linear_to_srgb

source ·
pub fn linear_to_srgb(x0: f32) -> f32
Expand description

Convert Linear RGB color component into a SRGB color component.

It was hard to optimize this function, even current version is slow because of the conditional jump. Lookup table is not working here as well it should be at least 4K in size an not cache friendly.

Precise implementation

pub fn linear_to_srgb(value: f32) -> f32 {
    if value <= 0.0031308 {
        value * 12.92
    } else {
        1.055 * value.powf(1.0 / 2.4) - 0.055
    }
}