pub struct Resolution {
pub width: u32,
pub height: u32,
}Expand description
Width × Height in pixels.
Fields§
§width: u32Width in pixels.
height: u32Height in pixels.
Implementations§
Source§impl Resolution
impl Resolution
Sourcepub fn aspect_ratio(&self) -> (u32, u32)
pub fn aspect_ratio(&self) -> (u32, u32)
Aspect ratio as a simplified fraction (e.g., (16, 9)).
Sourcepub fn aspect_ratio_f64(&self) -> f64
pub fn aspect_ratio_f64(&self) -> f64
Aspect ratio as a floating-point value (width / height).
Sourcepub fn is_portrait(&self) -> bool
pub fn is_portrait(&self) -> bool
Whether the image is taller than it is wide.
Sourcepub fn is_landscape(&self) -> bool
pub fn is_landscape(&self) -> bool
Whether the image is wider than it is tall.
Sourcepub fn pixel_count(&self) -> u64
pub fn pixel_count(&self) -> u64
Total pixel count.
Sourcepub fn scale_to_fit(&self, max_width: u32, max_height: u32) -> Self
pub fn scale_to_fit(&self, max_width: u32, max_height: u32) -> Self
Scale to fit within the given bounds, preserving aspect ratio.
Sourcepub fn scale_to_fill(&self, width: u32, height: u32) -> Self
pub fn scale_to_fill(&self, width: u32, height: u32) -> Self
Scale to fill the given bounds, preserving aspect ratio (may overflow bounds).
Trait Implementations§
Source§impl Clone for Resolution
impl Clone for Resolution
Source§fn clone(&self) -> Resolution
fn clone(&self) -> Resolution
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for Resolution
Source§impl Debug for Resolution
impl Debug for Resolution
Source§impl<'de> Deserialize<'de> for Resolution
impl<'de> Deserialize<'de> for Resolution
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Resolution
Source§impl Hash for Resolution
impl Hash for Resolution
Source§impl PartialEq for Resolution
impl PartialEq for Resolution
Source§impl Serialize for Resolution
impl Serialize for Resolution
impl StructuralPartialEq for Resolution
Auto Trait Implementations§
impl Freeze for Resolution
impl RefUnwindSafe for Resolution
impl Send for Resolution
impl Sync for Resolution
impl Unpin for Resolution
impl UnsafeUnpin for Resolution
impl UnwindSafe for Resolution
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