pub struct Padding2D {
pub top: usize,
pub bottom: usize,
pub left: usize,
pub right: usize,
}Expand description
Represents 2D padding with top, bottom, left, and right values (in pixels).
Fields§
§top: usizeAmount of padding to add on the top side.
bottom: usizeAmount of padding to add on the bottom side.
left: usizeAmount of padding to add on the left side.
right: usizeAmount of padding to add on the right side.
Implementations§
Source§impl Padding2D
impl Padding2D
Sourcepub fn validate_size(&self, old_size: ImageSize, new_size: ImageSize) -> bool
pub fn validate_size(&self, old_size: ImageSize, new_size: ImageSize) -> bool
Validates that a new image size correctly matches the expected dimensions after applying this padding to an existing image.
§Arguments
old_size: The original image size before padding.new_size: The resulting image size after padding.
§Returns
trueif thenew_sizewidth and height are equal toold_size.width + left + rightandold_size.height + top + bottom, respectively.falseotherwise.
§Example
use kornia_image::ImageSize;
use kornia_imgproc::padding::Padding2D;
let padding = Padding2D { top: 1, bottom: 1, left: 2, right: 2 };
let old_size = ImageSize { width: 4, height: 4 };
let new_size = ImageSize { width: 8, height: 6 };
assert!(padding.validate_size(old_size, new_size));Auto Trait Implementations§
impl Freeze for Padding2D
impl RefUnwindSafe for Padding2D
impl Send for Padding2D
impl Sync for Padding2D
impl Unpin for Padding2D
impl UnsafeUnpin for Padding2D
impl UnwindSafe for Padding2D
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
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> ⓘ
Converts
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> ⓘ
Converts
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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
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
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.