Expand description
Pixel value codec — convert raw band bytes ↔ f64 for resampling math.
Every resampling kernel does its arithmetic in f64, regardless of the
source dtype. This module is the bridge: read one pixel as f64, do
the math, write back as the dtype’s raw bytes (clamping to the dtype’s
valid range).
§Why f64
- All numeric pixel types fit losslessly into f64 (even u32 and f32)
- Bilinear / cubic / lanczos kernels need fractional math anyway
- The per-pixel f64 ↔ raw cost is dominated by the kernel evaluation, not the conversion
Functions§
- read
- Read one pixel from a band at
(col, row)asf64. ReturnsNoneif the band’s dtype isn’t supported by the resamplers (Rgb8/Rgba8 need per-channel handling that the caller does manually) or if the coordinate is out of range. - write
- Write
valueinto a band at(col, row). Clamps to the dtype’s valid range; rounds-to-nearest for integer types. Returnsfalseif the coordinate is out of range OR the dtype isn’t supported.