pub struct RasterBuffer { /* private fields */ }Expand description
A typed buffer for raster data
Implementations§
Source§impl RasterBuffer
impl RasterBuffer
Sourcepub fn new(
data: Vec<u8>,
width: u64,
height: u64,
data_type: RasterDataType,
nodata: NoDataValue,
) -> Result<Self>
pub fn new( data: Vec<u8>, width: u64, height: u64, data_type: RasterDataType, nodata: NoDataValue, ) -> Result<Self>
Creates a new raster buffer
§Errors
Returns an error if the data size doesn’t match the dimensions and type
Sourcepub fn zeros(width: u64, height: u64, data_type: RasterDataType) -> Self
pub fn zeros(width: u64, height: u64, data_type: RasterDataType) -> Self
Creates a zero-filled buffer
Sourcepub fn nodata_filled(
width: u64,
height: u64,
data_type: RasterDataType,
nodata: NoDataValue,
) -> Self
pub fn nodata_filled( width: u64, height: u64, data_type: RasterDataType, nodata: NoDataValue, ) -> Self
Creates a buffer filled with the nodata value
Sourcepub fn fill_value(&mut self, value: f64)
pub fn fill_value(&mut self, value: f64)
Fills the buffer with a constant value
Sourcepub const fn data_type(&self) -> RasterDataType
pub const fn data_type(&self) -> RasterDataType
Returns the data type
Sourcepub const fn nodata(&self) -> NoDataValue
pub const fn nodata(&self) -> NoDataValue
Returns the nodata value
Sourcepub const fn pixel_count(&self) -> u64
pub const fn pixel_count(&self) -> u64
Returns the total number of pixels
Sourcepub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
pub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
Returns mutable raw bytes
Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
Consumes the buffer and returns the raw bytes
Sourcepub fn from_typed_vec<T: Copy + 'static>(
width: usize,
height: usize,
data: Vec<T>,
data_type: RasterDataType,
) -> Result<Self>
pub fn from_typed_vec<T: Copy + 'static>( width: usize, height: usize, data: Vec<T>, data_type: RasterDataType, ) -> Result<Self>
Sourcepub fn as_slice_mut<T: Copy + 'static>(&mut self) -> Result<&mut [T]>
pub fn as_slice_mut<T: Copy + 'static>(&mut self) -> Result<&mut [T]>
Sourcepub fn is_nodata(&self, value: f64) -> bool
pub fn is_nodata(&self, value: f64) -> bool
Returns true if the given value equals the nodata value
Sourcepub fn convert_to(&self, target_type: RasterDataType) -> Result<Self>
pub fn convert_to(&self, target_type: RasterDataType) -> Result<Self>
Sourcepub fn compute_statistics(&self) -> Result<BufferStatistics>
pub fn compute_statistics(&self) -> Result<BufferStatistics>
Computes basic statistics
Trait Implementations§
Source§impl Clone for RasterBuffer
impl Clone for RasterBuffer
Source§fn clone(&self) -> RasterBuffer
fn clone(&self) -> RasterBuffer
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RasterBuffer
impl RefUnwindSafe for RasterBuffer
impl Send for RasterBuffer
impl Sync for RasterBuffer
impl Unpin for RasterBuffer
impl UnsafeUnpin for RasterBuffer
impl UnwindSafe for RasterBuffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more