#[non_exhaustive]pub enum ImageDownscaleMode {
Fit(PxSize),
Fill(PxSize),
MipMap {
min_size: PxSize,
max_size: PxSize,
},
Entries(Vec<ImageDownscaleMode>),
}Expand description
Defines how an image is downscaled after decoding.
The image aspect ratio is preserved in all modes. The image is never upscaled. If the image container contains reduced alternative the nearest to the requested size is used as source.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Fit(PxSize)
Image is downscaled so that both dimensions fit inside the size.
Fill(PxSize)
Image is downscaled so that at least one dimension fits inside the size. The image is not clipped.
MipMap
Generate synthetic ImageEntryKind::Reduced entries each half the size of the image until the sample that is
nearest min_size and greater or equal to it. If the image container already has alternates that are equal to
or near a mip size that size is used instead.
Entries(Vec<ImageDownscaleMode>)
Generate multiple synthetic ImageEntryKind::Reduced entries. The entry sizes are sorted by largest first,
if the image full size already fits in the largest downscale requested the full image is returned and any
downscale actually smaller becomes a synthetic entry. If the image is larger than all requested sizes it is downscaled as well.
Implementations§
Source§impl ImageDownscaleMode
impl ImageDownscaleMode
Sourcepub fn mip_map() -> Self
pub fn mip_map() -> Self
Default mipmap min/max when the objective of the mipmap is optimizing dynamically resizing massive images.
Sourcepub fn with_entry(self, other: impl Into<ImageDownscaleMode>) -> Self
pub fn with_entry(self, other: impl Into<ImageDownscaleMode>) -> Self
Append entry downscale request.
Sourcepub fn sizes(
&self,
page_size: PxSize,
reduced_sizes: &[PxSize],
) -> (Option<PxSize>, Vec<PxSize>)
pub fn sizes( &self, page_size: PxSize, reduced_sizes: &[PxSize], ) -> (Option<PxSize>, Vec<PxSize>)
Get downscale sizes that need to be generated.
The page_size is the image full size, the reduced_sizes are
sizes of reduced alternates that are already provided by the image container.
Returns the downscale for the image full size, if needed and a list of reduced entries that must be synthesized, sorted largest to smallest.
Trait Implementations§
Source§impl Clone for ImageDownscaleMode
impl Clone for ImageDownscaleMode
Source§fn clone(&self) -> ImageDownscaleMode
fn clone(&self) -> ImageDownscaleMode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ImageDownscaleMode
impl Debug for ImageDownscaleMode
Source§impl<'de> Deserialize<'de> for ImageDownscaleMode
impl<'de> Deserialize<'de> for ImageDownscaleMode
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>,
Source§impl Hash for ImageDownscaleMode
impl Hash for ImageDownscaleMode
Source§impl IntoVar<ImageDownscaleMode> for Px
impl IntoVar<ImageDownscaleMode> for Px
fn into_var(self) -> Var<ImageDownscaleMode>
Source§impl IntoVar<ImageDownscaleMode> for PxSize
impl IntoVar<ImageDownscaleMode> for PxSize
fn into_var(self) -> Var<ImageDownscaleMode>
Source§impl IntoVar<Option<ImageDownscaleMode>> for ImageDownscaleMode
impl IntoVar<Option<ImageDownscaleMode>> for ImageDownscaleMode
Source§impl PartialEq for ImageDownscaleMode
impl PartialEq for ImageDownscaleMode
Source§impl Serialize for ImageDownscaleMode
impl Serialize for ImageDownscaleMode
impl Eq for ImageDownscaleMode
impl IntoValue<ImageDownscaleMode> for Px
impl IntoValue<ImageDownscaleMode> for PxSize
impl IntoValue<Option<ImageDownscaleMode>> for ImageDownscaleMode
impl StructuralPartialEq for ImageDownscaleMode
Auto Trait Implementations§
impl Freeze for ImageDownscaleMode
impl RefUnwindSafe for ImageDownscaleMode
impl Send for ImageDownscaleMode
impl Sync for ImageDownscaleMode
impl Unpin for ImageDownscaleMode
impl UnwindSafe for ImageDownscaleMode
Blanket Implementations§
Source§impl<T> AnyVarValue for T
impl<T> AnyVarValue for T
Source§fn clone_boxed(&self) -> BoxAnyVarValue
fn clone_boxed(&self) -> BoxAnyVarValue
Source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self and other are equal.Source§fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
other if both are of the same type.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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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