Enum exr::block::samples::Sample

source ·
pub enum Sample {
    F16(f16),
    F32(f32),
    U32(u32),
}
Expand description

A single red, green, blue, or alpha value.

Variants§

§

F16(f16)

A 16-bit float sample.

§

F32(f32)

A 32-bit float sample.

§

U32(u32)

An unsigned integer sample.

Implementations§

source§

impl Sample

source

pub fn f32(f32: f32) -> Self

Create a sample containing a 32-bit float.

source

pub fn f16(f16: f16) -> Self

Create a sample containing a 16-bit float.

source

pub fn u32(u32: u32) -> Self

Create a sample containing a 32-bit integer.

source

pub fn to_f16(self) -> f16

Convert the sample to an f16 value. This has lower precision than f32. Note: An f32 can only represent integers up to 1024 as precise as a u32 could.

source

pub fn to_f32(self) -> f32

Convert the sample to an f32 value. Note: An f32 can only represent integers up to 8388608 as precise as a u32 could.

source

pub fn to_u32(self) -> u32

Convert the sample to a u32. Rounds floats to integers the same way that 3.1 as u32 does.

source

pub fn is_nan(self) -> bool

Is this value not a number?

source

pub fn is_zero(&self) -> bool

Is this value zero or negative zero?

Trait Implementations§

source§

impl Clone for Sample

source§

fn clone(&self) -> Sample

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Sample

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Sample

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<T> From<Option<T>> for Samplewhere T: Into<Sample> + Default,

source§

fn from(num: Option<T>) -> Self

Converts to this type from the input type.
source§

impl From<Sample> for f16

source§

fn from(s: Sample) -> Self

Converts to this type from the input type.
source§

impl From<Sample> for f32

source§

fn from(s: Sample) -> Self

Converts to this type from the input type.
source§

impl From<Sample> for u32

source§

fn from(s: Sample) -> Self

Converts to this type from the input type.
source§

impl From<f16> for Sample

source§

fn from(f: f16) -> Self

Converts to this type from the input type.
source§

impl From<f32> for Sample

source§

fn from(f: f32) -> Self

Converts to this type from the input type.
source§

impl From<u32> for Sample

source§

fn from(f: u32) -> Self

Converts to this type from the input type.
source§

impl FromNativeSample for Sample

source§

fn from_f16(value: f16) -> Self

Create this sample from a f16, trying to represent the same numerical value
source§

fn from_f32(value: f32) -> Self

Create this sample from a f32, trying to represent the same numerical value
source§

fn from_u32(value: u32) -> Self

Create this sample from a u32, trying to represent the same numerical value
source§

fn from_f16s(from: &[f16], to: &mut [Self])

Convert all values from the slice into this type. This function exists to allow the compiler to perform a vectorization optimization. Note that this default implementation will not be vectorized by the compiler automatically. For maximum performance you will need to override this function and implement it via an explicit batched conversion such as convert_to_f32_slice
source§

fn from_f32s(from: &[f32], to: &mut [Self])

Convert all values from the slice into this type. This function exists to allow the compiler to perform a vectorization optimization. Note that this default implementation will be vectorized by the compiler automatically.
source§

fn from_u32s(from: &[u32], to: &mut [Self])

Convert all values from the slice into this type. This function exists to allow the compiler to perform a vectorization optimization. Note that this default implementation will be vectorized by the compiler automatically, provided that the CPU supports the necessary conversion instructions. For example, x86_64 lacks the instructions to convert u32 to floats, so this will inevitably be slow on x86_64.
source§

impl IntoNativeSample for Sample

source§

fn to_f16(&self) -> f16

Convert this sample to an f16, trying to represent the same numerical value.
source§

fn to_f32(&self) -> f32

Convert this sample to an f32, trying to represent the same numerical value.
source§

fn to_u32(&self) -> u32

Convert this sample to an u16, trying to represent the same numerical value.
source§

impl PartialEq<Sample> for Sample

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl ValidateResult for Sample

source§

fn validate_result( &self, other: &Self, options: ValidationOptions, location: impl Fn() -> String ) -> ValidationResult

Compare self with the other. Exceptional behaviour: Read more
source§

fn assert_equals_result(&self, result: &Self)

Compare self with the other. Panics if not equal. Read more
source§

impl Copy for Sample

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<R, P> ReadPrimitive<R> for Pwhere R: Read + ReadEndian<P>, P: Default,

source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.