Trait image2::Type

source ·
pub trait Type: 'static + Unpin + Default + Clone + Copy + Sync + Send + PartialEq + PartialOrd + Debug {
    const MIN: f64;
    const MAX: f64;
    const BASE: BaseType;
Show 13 methods // Required methods fn to_f64(&self) -> f64; fn from_f64(f: f64) -> Self; // Provided methods fn is_float() -> bool { ... } fn type_name() -> &'static str { ... } fn set_from_f64(&mut self, f: f64) { ... } fn set_from_norm(&mut self, f: f64) { ... } fn to_norm(&self) -> f64 { ... } fn from_norm(f: f64) -> Self { ... } fn normalize(f: f64) -> f64 { ... } fn denormalize(f: f64) -> f64 { ... } fn clamp(f: f64) -> f64 { ... } fn convert<X: Type>(&self) -> X { ... } fn bits() -> usize { ... }
}
Expand description

Type is used to represent supported image data types

Required Associated Constants§

source

const MIN: f64

Min value

source

const MAX: f64

Max value

source

const BASE: BaseType

I/O base type

Required Methods§

source

fn to_f64(&self) -> f64

Convert to f64

source

fn from_f64(f: f64) -> Self

Convert from f64

Provided Methods§

source

fn is_float() -> bool

Returns true when T is a floating point type

source

fn type_name() -> &'static str

Get the type name

source

fn set_from_f64(&mut self, f: f64)

Set a value from an f64 value

source

fn set_from_norm(&mut self, f: f64)

Set a value from normalized float

source

fn to_norm(&self) -> f64

Convert from T to normalized float

source

fn from_norm(f: f64) -> Self

Convert to T from normalized float

source

fn normalize(f: f64) -> f64

Scale a value to fit between 0 and 1.0 based on the min/max values for T

source

fn denormalize(f: f64) -> f64

Scale an f64 value to fit the range supported by T

source

fn clamp(f: f64) -> f64

Ensure the given value is less than the max allowed and greater than or equal to the minimum value

source

fn convert<X: Type>(&self) -> X

Convert a value from one type to another

source

fn bits() -> usize

Get the number of bits for a data type

Implementations on Foreign Types§

source§

impl Type for u8

source§

const MIN: f64 = 0f64

source§

const MAX: f64 = 255f64

source§

const BASE: BaseType = io::BaseType::UInt8

source§

fn to_f64(&self) -> f64

source§

fn from_f64(f: f64) -> Self

source§

impl Type for i16

source§

const MIN: f64 = -32768f64

source§

const MAX: f64 = 32767f64

source§

const BASE: BaseType = io::BaseType::Int16

source§

fn to_f64(&self) -> f64

source§

fn from_f64(f: f64) -> Self

source§

impl Type for f64

source§

const MIN: f64 = 0f64

source§

const MAX: f64 = 1f64

source§

const BASE: BaseType = io::BaseType::Double

source§

fn to_f64(&self) -> f64

source§

fn from_f64(f: f64) -> Self

source§

impl Type for u32

source§

const MIN: f64 = 0f64

source§

const MAX: f64 = 4294967295f64

source§

const BASE: BaseType = io::BaseType::UInt32

source§

fn to_f64(&self) -> f64

source§

fn from_f64(f: f64) -> Self

source§

impl Type for u64

source§

const MIN: f64 = 0f64

source§

const MAX: f64 = 1.8446744073709552E+19f64

source§

const BASE: BaseType = io::BaseType::UInt64

source§

fn to_f64(&self) -> f64

source§

fn from_f64(f: f64) -> Self

source§

impl Type for i8

source§

const MIN: f64 = -128f64

source§

const MAX: f64 = 127f64

source§

const BASE: BaseType = io::BaseType::Int8

source§

fn to_f64(&self) -> f64

source§

fn from_f64(f: f64) -> Self

source§

impl Type for u16

source§

const MIN: f64 = 0f64

source§

const MAX: f64 = 65535f64

source§

const BASE: BaseType = io::BaseType::UInt16

source§

fn to_f64(&self) -> f64

source§

fn from_f64(f: f64) -> Self

source§

impl Type for i32

source§

const MIN: f64 = -2147483648f64

source§

const MAX: f64 = 2147483647f64

source§

const BASE: BaseType = io::BaseType::Int32

source§

fn to_f64(&self) -> f64

source§

fn from_f64(f: f64) -> Self

source§

impl Type for f32

source§

const MIN: f64 = 0f64

source§

const MAX: f64 = 1f64

source§

const BASE: BaseType = io::BaseType::Float

source§

fn to_f64(&self) -> f64

source§

fn from_f64(f: f64) -> Self

source§

impl Type for i64

source§

const MIN: f64 = -9.2233720368547758E+18f64

source§

const MAX: f64 = 9.2233720368547758E+18f64

source§

const BASE: BaseType = io::BaseType::Int64

source§

fn to_f64(&self) -> f64

source§

fn from_f64(f: f64) -> Self

Implementors§

source§

impl Type for f16

source§

const MIN: f64 = 0f64

source§

const MAX: f64 = 1f64

source§

const BASE: BaseType = io::BaseType::Half