png/
srgb.rs

1use crate::{ScaledFloat, SourceChromaticities};
2
3/// Get the gamma that should be substituted for images conforming to the sRGB color space.
4pub fn substitute_gamma() -> ScaledFloat {
5    // Value taken from https://www.w3.org/TR/2003/REC-PNG-20031110/#11sRGB
6    ScaledFloat::from_scaled(45455)
7}
8
9/// Get the chromaticities that should be substituted for images conforming to the sRGB color space.
10pub fn substitute_chromaticities() -> SourceChromaticities {
11    // Values taken from https://www.w3.org/TR/2003/REC-PNG-20031110/#11sRGB
12    SourceChromaticities {
13        white: (
14            ScaledFloat::from_scaled(31270),
15            ScaledFloat::from_scaled(32900),
16        ),
17        red: (
18            ScaledFloat::from_scaled(64000),
19            ScaledFloat::from_scaled(33000),
20        ),
21        green: (
22            ScaledFloat::from_scaled(30000),
23            ScaledFloat::from_scaled(60000),
24        ),
25        blue: (
26            ScaledFloat::from_scaled(15000),
27            ScaledFloat::from_scaled(6000),
28        ),
29    }
30}