pub struct CropScaleConfig {
pub source_width: u32,
pub source_height: u32,
pub target_width: u32,
pub target_height: u32,
pub aspect_mode: AspectMode,
pub pad_alignment: PadAlignment,
pub pad_color: (u8, u8, u8),
pub manual_crop: Option<Rect>,
}Expand description
Configuration for a crop-and-scale operation.
Fields§
§source_width: u32Source resolution.
source_height: u32Source height in pixels.
target_width: u32Target width in pixels.
target_height: u32Target height in pixels.
aspect_mode: AspectModeAspect ratio handling mode.
pad_alignment: PadAlignmentPadding alignment when using AspectMode::Pad.
pad_color: (u8, u8, u8)Padding color as (R, G, B).
manual_crop: Option<Rect>Optional manual crop region applied before scaling.
Implementations§
Source§impl CropScaleConfig
impl CropScaleConfig
Sourcepub fn new(
source_width: u32,
source_height: u32,
target_width: u32,
target_height: u32,
) -> Self
pub fn new( source_width: u32, source_height: u32, target_width: u32, target_height: u32, ) -> Self
Creates a new crop/scale configuration.
Sourcepub fn with_aspect_mode(self, mode: AspectMode) -> Self
pub fn with_aspect_mode(self, mode: AspectMode) -> Self
Sets the aspect ratio handling mode.
Sourcepub fn with_pad_alignment(self, alignment: PadAlignment) -> Self
pub fn with_pad_alignment(self, alignment: PadAlignment) -> Self
Sets the padding alignment.
Sourcepub fn with_pad_color(self, r: u8, g: u8, b: u8) -> Self
pub fn with_pad_color(self, r: u8, g: u8, b: u8) -> Self
Sets the padding color (used for letterbox/pillarbox bars).
Sourcepub fn with_manual_crop(self, crop: Rect) -> Self
pub fn with_manual_crop(self, crop: Rect) -> Self
Sets a manual crop region applied before scaling.
Sourcepub fn source_aspect(&self) -> f64
pub fn source_aspect(&self) -> f64
Returns the source aspect ratio.
Sourcepub fn target_aspect(&self) -> f64
pub fn target_aspect(&self) -> f64
Returns the target aspect ratio.
Sourcepub fn compute_scaled_size(&self) -> (u32, u32)
pub fn compute_scaled_size(&self) -> (u32, u32)
Computes the scaled region (before padding) that fits within the target.
Returns (scaled_width, scaled_height).
Sourcepub fn compute_pad_offsets(&self) -> (u32, u32)
pub fn compute_pad_offsets(&self) -> (u32, u32)
Computes the padding offsets when using AspectMode::Pad.
Returns (x_offset, y_offset) for the image within the padded frame.
Sourcepub fn compute_crop_rect(&self) -> Rect
pub fn compute_crop_rect(&self) -> Rect
Computes the crop rect when using AspectMode::Crop.
Trait Implementations§
Source§impl Clone for CropScaleConfig
impl Clone for CropScaleConfig
Source§fn clone(&self) -> CropScaleConfig
fn clone(&self) -> CropScaleConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for CropScaleConfig
impl RefUnwindSafe for CropScaleConfig
impl Send for CropScaleConfig
impl Sync for CropScaleConfig
impl Unpin for CropScaleConfig
impl UnsafeUnpin for CropScaleConfig
impl UnwindSafe for CropScaleConfig
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> 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