NormalizedFloat

Trait NormalizedFloat 

Source
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§

Source

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.

Source

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.

Source

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.

Source

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.

Implementations on Foreign Types§

Source§

impl NormalizedFloat<f32> for f32

Source§

impl NormalizedFloat<f64> for f64

Source§

impl NormalizedFloat<i8> for i8

Source§

impl NormalizedFloat<i16> for i16

Source§

impl NormalizedFloat<i32> for i32

Source§

impl NormalizedFloat<u8> for u8

Source§

impl NormalizedFloat<u16> for u16

Source§

impl NormalizedFloat<u32> for u32

Implementors§