pub struct SampleEncoding { /* private fields */ }Expand description
Full re-export of zenpixels core types (zero module name collisions!).
Checked interpretation of one integer code in a stored sample.
Extract a code with (sample >> bit_shift) & ((1 << code_bits) - 1) using
sufficiently wide arithmetic. Bits outside that payload are padding: ignored
on read and written as zero on output.
Implementations§
Source§impl SampleEncoding
impl SampleEncoding
Sourcepub const fn new(
storage: SampleType,
code_bits: u8,
bit_shift: u8,
) -> Result<SampleEncoding, SampleEncodingError>
pub const fn new( storage: SampleType, code_bits: u8, bit_shift: u8, ) -> Result<SampleEncoding, SampleEncodingError>
Describe an integer component without examining or changing samples.
storage must be an integer SampleType. code_bits must be in
1..=storage.bits(), and code_bits + bit_shift <= storage.bits().
Sourcepub const fn storage(self) -> SampleType
pub const fn storage(self) -> SampleType
Integer storage type; this does not determine the code depth.
Sourcepub const fn code_bits(self) -> u8
pub const fn code_bits(self) -> u8
Number of significant code bits in the sample representation.
Sourcepub const fn bit_shift(self) -> u8
pub const fn bit_shift(self) -> u8
Number of low padding bits below the code in its stored sample.
Sourcepub const fn to_bit_packing(self) -> Option<BitPacking>
pub const fn to_bit_packing(self) -> Option<BitPacking>
Convert to crate::BitPacking when storage is unsigned (U8, U16, U32).
Trait Implementations§
Source§impl Clone for SampleEncoding
impl Clone for SampleEncoding
Source§fn clone(&self) -> SampleEncoding
fn clone(&self) -> SampleEncoding
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more