pub struct Weights { /* private fields */ }Expand description
Precomputed weights for one resize pass along one axis.
Built once per pass and shared by every row (or column) it is applied to, which is what turns a resize into a multiply-accumulate loop.
Implementations§
Source§impl Weights
impl Weights
Sourcepub fn build(filter: Filter, input_len: u32, output_len: u32) -> Result<Self>
pub fn build(filter: Filter, input_len: u32, output_len: u32) -> Result<Self>
Build the weight table mapping input_len samples onto output_len.
§Errors
Returns PixelsError::InvalidArgument if either length is zero, or
if the filter support at this scale would exceed what u32 can index.
Sourcepub fn window(self, offset: u32, len: u32) -> Self
pub fn window(self, offset: u32, len: u32) -> Self
The table restricted to output positions offset..offset + len,
renumbered from zero: the window a cropping resize keeps. The weights
are shared, so nothing is recomputed and the kept positions resample
exactly as they would in the full table.
Sourcepub fn for_tile(
&self,
out_start: u32,
out_len: u32,
in_start: u32,
) -> Result<Self>
pub fn for_tile( &self, out_start: u32, out_len: u32, in_start: u32, ) -> Result<Self>
The sub-table covering out_len output positions from out_start,
rebased so run starts are relative to input index in_start.
This is how a tile uses the image’s weights rather than its own. Building a fresh table from the tile’s dimensions would resample at the tile’s scale instead of the image’s, so an output pixel would depend on where the tile boundaries fell — which SPEC §Guarantees 2 forbids.
§Errors
Returns PixelsError::graph if the requested outputs fall outside
this table, or if a run would start before in_start — either means
the tile is not the footprint input_regions asked for.