pub trait NormalizedFloat<T>{
// Required methods
fn to_f32_normalized(&self) -> Option<f32>;
fn to_f64_normalized(&self) -> Option<f64>;
fn from_f32_normalized(value: f32) -> Option<T>;
fn from_f64_normalized(value: f64) -> Option<T>;
}Expand description
Trait for converting the provided value to a normalized float.
This is used for image processing where a lot of operations rely on floating values.
Required Methods§
Sourcefn to_f32_normalized(&self) -> Option<f32>
fn to_f32_normalized(&self) -> Option<f32>
Convert the value to a 32 bit float.
The value will be in a normalized range according to color depths.
For example in u8, a value of 255 would be represented as 1.0.
Returns None if it overflows and could not be represented.
Sourcefn to_f64_normalized(&self) -> Option<f64>
fn to_f64_normalized(&self) -> Option<f64>
Convert the value to a 64 bit float
The value will be in a normalized range according to color depths.
For example in u8, a value of 255 would be represented as 1.0.
Returns None if it overflows and could not be represented.
Sourcefn from_f32_normalized(value: f32) -> Option<T>
fn from_f32_normalized(value: f32) -> Option<T>
Converts the f32 value to the provided type
Returns None if it overflows and could not be represented.
Sourcefn from_f64_normalized(value: f64) -> Option<T>
fn from_f64_normalized(value: f64) -> Option<T>
Converts the f64 value to the provided type
Returns None if it overflows and could not be represented.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.