Struct png::common::ScaledFloat
source · pub struct ScaledFloat(u32);
Expand description
An unsigned integer scaled version of a floating point value, equivalent to an integer quotient with fixed denominator (100_000)).
Tuple Fields§
§0: u32
Implementations§
source§impl ScaledFloat
impl ScaledFloat
const SCALING: f32 = 1.0E+5f32
sourcepub fn in_range(value: f32) -> bool
pub fn in_range(value: f32) -> bool
Gets whether the value is within the clamped range of this type.
sourcepub fn exact(value: f32) -> bool
pub fn exact(value: f32) -> bool
Gets whether the value can be exactly converted in round-trip.
fn forward(value: f32) -> u32
fn reverse(encoded: u32) -> f32
sourcepub fn new(value: f32) -> Self
pub fn new(value: f32) -> Self
Slightly inaccurate scaling and quantization. Clamps the value into the representable range if it is negative or too large.
sourcepub fn from_scaled(val: u32) -> Self
pub fn from_scaled(val: u32) -> Self
Fully accurate construction from a value scaled as per specification.
sourcepub fn into_scaled(self) -> u32
pub fn into_scaled(self) -> u32
Get the accurate encoded value.
sourcepub fn into_value(self) -> f32
pub fn into_value(self) -> f32
Get the unscaled value as a floating point.
pub(crate) fn encode_gama<W: Write>( self, w: &mut W, ) -> Result<(), EncodingError>
Trait Implementations§
source§impl Clone for ScaledFloat
impl Clone for ScaledFloat
source§fn clone(&self) -> ScaledFloat
fn clone(&self) -> ScaledFloat
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ScaledFloat
impl Debug for ScaledFloat
source§impl PartialEq for ScaledFloat
impl PartialEq for ScaledFloat
source§fn eq(&self, other: &ScaledFloat) -> bool
fn eq(&self, other: &ScaledFloat) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Copy for ScaledFloat
impl Eq for ScaledFloat
impl StructuralPartialEq for ScaledFloat
Auto Trait Implementations§
impl Freeze for ScaledFloat
impl RefUnwindSafe for ScaledFloat
impl Send for ScaledFloat
impl Sync for ScaledFloat
impl Unpin for ScaledFloat
impl UnwindSafe for ScaledFloat
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more