pub enum PaddingMode {
Constant,
Replicate,
Reflect101,
Reflect,
Wrap,
}Expand description
A border type for the spatial padding.
Variants§
Constant
This border type fills the border with a single, constant color value.
Example: …d c b a | 0 0 0 0…
Replicate
This border type takes the outermost row or column of pixels and repeats it into the padded region.
Example: …d c b a | a a a a…
Reflect101
This border type reflects the pixel values at the boundary, starting with the pixel ‘next’ to the edge.
Example: …d c b a | b c d e…
Reflect
This border type reflects the pixel values at the boundary, starting with the edge pixel itself.
Example: …d c b a | a b c d…
Wrap
This border type wraps the content from the opposite side to fill the border.
Example: …d c b a | w x y z…
Implementations§
Source§impl PaddingMode
impl PaddingMode
Sourcepub fn map_index(&self, i: isize, len: usize) -> usize
pub fn map_index(&self, i: isize, len: usize) -> usize
Maps index i to a valid index i.e. within [0, len) according to the padding mode.
Replicate: clamp to edgeReflect: mirror including edgeReflect101: mirror excluding edgeWrap: circular wrapConstant: returns 0 (not used directly)
§Arguments
i: The (possibly out-of-range) coordinate index.len: The valid length of the dimension.
§Returns
A valid mapped index within [0, len).
Sourcepub fn apply_padding<T: Copy + Send + Sync, const C: usize>(
&self,
new_data: &mut [T],
old_width: usize,
old_height: usize,
new_width: usize,
new_height: usize,
padding: &Padding2D,
)
pub fn apply_padding<T: Copy + Send + Sync, const C: usize>( &self, new_data: &mut [T], old_width: usize, old_height: usize, new_width: usize, new_height: usize, padding: &Padding2D, )
Applies the selected padding mode to fill image borders in new_data.
§Arguments
new_data: Target image buffer (already containing the original image in the center).old_width,old_height: Dimensions of the original image.new_width,new_height: Dimensions of the padded image.padding:left,right,topandbottompadding extents in pixels.
§Notes
PaddingMode::Constantis assumed to be already applied when initializingnew_data.- Other modes (
Replicate,Reflect,Reflect101,Wrap) will fill the outer border areas.
Trait Implementations§
Source§impl Clone for PaddingMode
impl Clone for PaddingMode
Source§fn clone(&self) -> PaddingMode
fn clone(&self) -> PaddingMode
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for PaddingMode
Auto Trait Implementations§
impl Freeze for PaddingMode
impl RefUnwindSafe for PaddingMode
impl Send for PaddingMode
impl Sync for PaddingMode
impl Unpin for PaddingMode
impl UnsafeUnpin for PaddingMode
impl UnwindSafe for PaddingMode
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§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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.