#[non_exhaustive]pub enum Align {
Crop(u32, u32),
Extend(u32, u32),
Distort(u32, u32),
}Expand description
How to align output dimensions to codec-required multiples.
All variants take (x_align, y_align) for per-axis alignment.
Use Subsampling::mcu_align() for JPEG MCU-aligned extend.
Source: 801x601, align to mod-16
Crop: 800x592 -- round down, lose edge pixels
Extend: 816x608 -- round up, replicate edges, content_size=(801,601)
Distort: 800x608 -- round to nearest, slight stretchVariants (Non-exhaustive)§
This enum is marked as non-exhaustive
Crop(u32, u32)
Round canvas down to nearest multiple per axis. Loses up to n-1
edge pixels per axis. Simple, lossy.
Extend(u32, u32)
Extend canvas up to nearest multiple per axis. Resets placement
to (0, 0) — renderer replicates edge pixels into the extension
area at the bottom-right. Original content dimensions stored in
IdealLayout::content_size / LayoutPlan::content_size.
No content loss. This is how JPEG MCU padding works.
Distort(u32, u32)
Round resize_to to nearest multiple per axis, stretching content
slightly to fit. Minimal distortion, no pixel loss, no padding.
Canvas follows resize_to in non-pad modes; in pad modes the image
is recentered within the existing canvas.
Implementations§
Source§impl Align
impl Align
Sourcepub const fn uniform_crop(n: u32) -> Self
pub const fn uniform_crop(n: u32) -> Self
Uniform crop alignment (same for both axes).
Sourcepub const fn uniform_extend(n: u32) -> Self
pub const fn uniform_extend(n: u32) -> Self
Uniform extend alignment (same for both axes).
Sourcepub const fn uniform_distort(n: u32) -> Self
pub const fn uniform_distort(n: u32) -> Self
Uniform distort alignment (same for both axes).