Skip to main content

MultiBandBuffer

Struct MultiBandBuffer 

Source
pub struct MultiBandBuffer { /* private fields */ }
Expand description

A multi-band raster buffer holding multiple single-band buffers.

All bands must share identical dimensions and data type.

Implementations§

Source§

impl MultiBandBuffer

Source

pub fn from_bands( bands: Vec<RasterBuffer>, colors: Vec<ColorInterpretation>, ) -> Result<Self>

Create a MultiBandBuffer from individual band buffers and color interpretations.

All bands must have the same width, height, and data type.

§Errors

Returns an error if bands have mismatched dimensions or data types, or if the color interpretation count doesn’t match the band count.

Source

pub fn from_interleaved( data: &[u8], width: u64, height: u64, band_count: u32, data_type: RasterDataType, nodata: NoDataValue, ) -> Result<Self>

Create a MultiBandBuffer from interleaved (BIP) data.

Deinterleaves band-interleaved-by-pixel data into separate band buffers.

§Errors

Returns an error if the data size doesn’t match dimensions × band_count × type_size.

Source

pub fn from_bsq( data: &[u8], width: u64, height: u64, band_count: u32, data_type: RasterDataType, nodata: NoDataValue, ) -> Result<Self>

Create a MultiBandBuffer from band-sequential (BSQ) data.

§Errors

Returns an error if the data size doesn’t match dimensions × band_count × type_size.

Source

pub fn from_bil( data: &[u8], width: u64, height: u64, band_count: u32, data_type: RasterDataType, nodata: NoDataValue, ) -> Result<Self>

Create a MultiBandBuffer from Band-Interleaved-by-Line (BIL) data.

Rearranges BIL-layout bytes into the internal BSQ (band-sequential) representation.

BIL layout: for each row r and then each band b, the width * pixel_size bytes for that (row, band) slice are contiguous:

[row0_band0_col0..colN, row0_band1_col0..colN, …, row0_bandN_col0..colN,
 row1_band0_col0..colN, row1_band1_col0..colN, …, rowH_bandN_col0..colN]
§Errors

Returns an error if the data size doesn’t match width × height × band_count × pixel_size.

Source

pub fn band_count(&self) -> u32

Returns the number of bands.

Source

pub fn width(&self) -> u64

Returns the width in pixels (same for all bands).

Source

pub fn height(&self) -> u64

Returns the height in pixels (same for all bands).

Source

pub fn data_type(&self) -> RasterDataType

Returns the data type (same for all bands).

Source

pub fn layout(&self) -> PixelLayout

Returns the pixel layout.

Source

pub fn set_band_nodata(&mut self, band: u32, nodata: NoDataValue) -> Result<()>

Set per-band nodata override value.

Source

pub fn band(&self, band: u32) -> Result<BandRef<'_>>

Get a reference to a specific band buffer.

§Errors

Returns an error if band is out of range.

Source

pub fn band_mut(&mut self, band: u32) -> Result<&mut RasterBuffer>

Get a mutable reference to a specific band buffer.

§Errors

Returns an error if band is out of range.

Source

pub fn bands(&self) -> BandIterator<'_>

Returns a lazy iterator over all bands.

Source

pub fn to_interleaved(&self) -> Vec<u8>

Interleave all bands into a single BIP byte buffer.

Returns pixels in band-interleaved-by-pixel order: R₁G₁B₁ R₂G₂B₂ …

Source

pub fn to_bsq(&self) -> Vec<u8>

Flatten all bands into BSQ byte buffer.

Returns band-sequential data: all of band 0, then all of band 1, etc.

Source

pub fn to_bil(&self) -> Vec<u8>

Emits the buffer data in Band-Interleaved-by-Line (BIL) layout.

BIL layout: for each row r and then each band b, all width * pixel_size bytes for that (row, band) slice are written contiguously:

[row0_band0, row0_band1, …, row0_bandN, row1_band0, …, rowH_bandN]
Source

pub fn compute_all_statistics(&self) -> Result<Vec<BufferStatistics>>

Compute statistics for all bands.

§Errors

Returns an error if statistics computation fails for any band.

Source

pub fn into_bands(self) -> Vec<RasterBuffer>

Consume and return the inner band buffers.

Trait Implementations§

Source§

impl Clone for MultiBandBuffer

Source§

fn clone(&self) -> MultiBandBuffer

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MultiBandBuffer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.