Sample types in layouts, resize DecoderResult

By adding the type interpretation to `BufferLayoutPreference` (simply
computed from the same fields that are trivial to fetch in
`ReadoutLayout` with the rest) we can allocate an appropriate
`DecoderResult` without any `Decoder` instance. We still want a Limits
instance though. This lets a caller read _typed_ data from the `_bytes`
methods which perform less allocations. It also lets them read multiple
planes in a more convenient interface. See, `read_image` will keep its
planar treatment bug for a little bit so you don't accidentally break
during an upgrade.

This also implies less code is being monomorphized, just a bonus.
This commit is contained in:
A. Molzer committed 2025-12-28 21:06:59 +01:00
1 parent af8a8d660f
commit 6d56d014a1
3 files changed
+163 -73

No files matched your search

+3
View File
@@ -98,6 +98,8 @@ pub(crate) struct ReadoutLayout {
pub color: ColorType,
/// The number of bytes from one row to another.
pub minimum_row_stride: usize,
/// The format of samples (assumed uniform for now, same with depth of `ColorType`).
pub sample_format: SampleFormat,
/// Number of bytes to advance in output per row.
pub row_stride: usize,
@@ -659,6 +661,7 @@ impl Image {
planar_config: self.planar_config,
color,
minimum_row_stride,
sample_format: self.sample_format,
row_stride: data_row_bytes,
chunk_row_stride: chunk_row_bytes,
chunk_col_stride,