pub struct Dimensions {
pub width: u32,
pub height: u32,
}Expand description
Width and height of an image, in pixels.
Fields§
§width: u32Image width in pixels.
height: u32Image height in pixels.
Implementations§
Source§impl Dimensions
impl Dimensions
Sourcepub fn new(width: u32, height: u32) -> Result<Dimensions, Error>
pub fn new(width: u32, height: u32) -> Result<Dimensions, Error>
Creates dimensions, rejecting a zero width or height.
The fields stay public for ergonomic struct literals; this constructor is the validated
path that buffer types (crate::ImageRef) and codecs use so an empty image is caught
once, at the boundary, rather than re-checked in every encoder.
§Errors
Returns Error::InvalidInput if either dimension is zero.
Sourcepub fn num_pixels(self) -> Option<usize>
pub fn num_pixels(self) -> Option<usize>
The pixel count width * height, or None if it overflows usize.
Sourcepub fn sample_count(self, channels: usize) -> Option<usize>
pub fn sample_count(self, channels: usize) -> Option<usize>
The sample count for an interleaved buffer of channels samples per pixel
(width * height * channels), or None on overflow. The length an crate::ImageRef
validates against.
Trait Implementations§
Source§impl Clone for Dimensions
impl Clone for Dimensions
Source§fn clone(&self) -> Dimensions
fn clone(&self) -> Dimensions
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 Dimensions
Source§impl Debug for Dimensions
impl Debug for Dimensions
impl Eq for Dimensions
Source§impl Hash for Dimensions
impl Hash for Dimensions
Source§impl PartialEq for Dimensions
impl PartialEq for Dimensions
Source§fn eq(&self, other: &Dimensions) -> bool
fn eq(&self, other: &Dimensions) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for Dimensions
Auto Trait Implementations§
impl Freeze for Dimensions
impl RefUnwindSafe for Dimensions
impl Send for Dimensions
impl Sync for Dimensions
impl Unpin for Dimensions
impl UnsafeUnpin for Dimensions
impl UnwindSafe for Dimensions
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