Ogeon / palette

A Rust library for linear color calculations and conversion
Apache License 2.0
752 stars 60 forks source link

Add Rec. 709 and Rec. 2020 #410

Closed Kirk-Fox closed 2 months ago

Kirk-Fox commented 3 months ago

I have added the Rec. 709 and Rec. 2020 standards to the crate. Rec. 709 is simply the same as Srgb with a different transfer function, called RecOetf. Rec. 2020 is a wide color gamut standard using this same transfer function.

For Rec. 2020, I am not sure how to best implement conversions from floating-point to unsigned ints since, due to the wide gamut, it typically operates with either 10 or 12 bits per color channel, making the typical use of u8's not ideal. Ideally, there could be a lookup table containing 4096 values that could be indexed into variably depending on the chosen bit depth (e.g. REC_TO_F64[4*value] for a 10-bit Rec. 2020 value, or REC_TO_F64[16*value] for an 8-bit Rec. 709 value. I do not know the best way to incorporate any sort of variable bit depth into the library, though.