You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should try to split the TransferFn trait into at least FromLinear and IntoLinear. That should cover cases where it's not so trivial, or even impossible, to reverse the process.
I have also considered baking in number type conversion to allow possibly better quantization quality and conversion speed, but I have to read up some more on that. That could perhaps be covered separately with a more precise IntoComponent option.
Motivation
The current setup assumes both that the process can be reversed and that the output type should be the same as the input type. That may not always be the case.
The text was updated successfully, but these errors were encountered:
Ogeon
changed the title
Improve the RGB transfer function trait
Improve the (non-)linear transfer function trait
Jul 17, 2021
279: Split the TransferFn trait and add lookup tables for sRGB r=Ogeon a=Ogeon
This changes how the transfer functions work a bit:
* `TransferFn` has been split into `FromLinear` and `IntoLinear`.
* The two traits take two type parameters; one for the linear encoding and one for the non-linear encoding.
The split is useful for cases when a conversion is irreversible, as mentioned in #245. The two type parameters makes it possible to convert between number types while encoding and decoding. This makes it possible to skip `.into_format()` in some cases (currently when converting between `u8` and either `f32` or `f64`). In addition to that, I made those special cases faster by using [`fast-srgb8`](https://crates.io/crates/fast-srgb8), and a similar lookup table for `f64`.
## Closed Issues
* Closes#126.
* Closes#245.
## Breaking Change
* `TransferFn` has been split into `FromLinear` and `IntoLinear`.
* `{Rgb, Luma}::{from, into}_linear` and `{Rgb, Luma}::{from, into}_encoding` are now allowed to change the output type. This changes the API and type inference. The solution for the type inference is usually to remove `into_format` from the call chain.
* `{Rgb, Luma}::{from, into}_encoding` will only convert from linear encoding, not "cross convert" between encodings.
* The number type parameter and `'static`lifetime were removed from `RgbStandard`, `LumaStandard` and `RgbSpace`.
Co-authored-by: Erik Hedvall <erikwhedvall@gmail.com>
Description
We should try to split the
TransferFn
trait into at leastFromLinear
andIntoLinear
. That should cover cases where it's not so trivial, or even impossible, to reverse the process.I have also considered baking in number type conversion to allow possibly better quantization quality and conversion speed, but I have to read up some more on that. That could perhaps be covered separately with a more precise
IntoComponent
option.Motivation
The current setup assumes both that the process can be reversed and that the output type should be the same as the input type. That may not always be the case.
The text was updated successfully, but these errors were encountered: