pub struct ImageDimensions {
pub width: u32,
pub height: u32,
}
Expand description
Dimensions of an image.
Fields§
§width: u32
The width of the image.
height: u32
The height of the image.
Implementations§
source§impl ImageDimensions
impl ImageDimensions
sourcefn from_options(width: Option<u32>, height: Option<u32>) -> Option<Self>
fn from_options(width: Option<u32>, height: Option<u32>) -> Option<Self>
Construct an ImageDimensions
from the given optional values.
Returns None
if either of the values are None
.
sourcepub fn is_bigger_than(&self, other: ImageDimensions) -> bool
pub fn is_bigger_than(&self, other: ImageDimensions) -> bool
Whether these dimensions are bigger than the given dimensions.
Returns true
if either width
or height
is bigger than or equal to
the given dimensions.
sourcepub fn should_resize_for_thumbnail(
&self,
thumbnail_dimensions: ImageDimensions,
) -> bool
pub fn should_resize_for_thumbnail( &self, thumbnail_dimensions: ImageDimensions, ) -> bool
Whether these dimensions should be resized to generate a thumbnail.
sourcepub const fn increase_by(self, value: u32) -> Self
pub const fn increase_by(self, value: u32) -> Self
Increase both these dimensions by the given value.
sourcepub fn resize(
self,
requested_dimensions: ImageDimensions,
strategy: ResizeStrategy,
) -> Self
pub fn resize( self, requested_dimensions: ImageDimensions, strategy: ResizeStrategy, ) -> Self
Compute the new dimensions for resizing to the requested dimensions while preserving the aspect ratio of these dimensions and respecting the given strategy.
sourcepub fn resize_for_thumbnail(self) -> Option<Self>
pub fn resize_for_thumbnail(self) -> Option<Self>
Compute the dimensions for a thumbnail while preserving the aspect ratio of these dimensions.
Returns None
if these dimensions are smaller than the wanted
dimensions.
sourcepub fn to_image_loader_request(
self,
requested_dimensions: ImageDimensions,
) -> FrameRequest
pub fn to_image_loader_request( self, requested_dimensions: ImageDimensions, ) -> FrameRequest
Convert these dimensions to a request for the image loader with the requested dimensions.
Trait Implementations§
source§impl Clone for ImageDimensions
impl Clone for ImageDimensions
source§fn clone(&self) -> ImageDimensions
fn clone(&self) -> ImageDimensions
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ImageDimensions
impl Debug for ImageDimensions
source§impl From<ImageDimensions> for BaseImageInfo
impl From<ImageDimensions> for BaseImageInfo
source§fn from(value: ImageDimensions) -> Self
fn from(value: ImageDimensions) -> Self
impl Copy for ImageDimensions
Auto Trait Implementations§
impl Freeze for ImageDimensions
impl RefUnwindSafe for ImageDimensions
impl Send for ImageDimensions
impl Sync for ImageDimensions
impl Unpin for ImageDimensions
impl UnwindSafe for ImageDimensions
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more