Skip to main content

RasterWindow

Struct RasterWindow 

Source
pub struct RasterWindow {
    pub col_off: u32,
    pub row_off: u32,
    pub width: u32,
    pub height: u32,
}
Expand description

A sub-region window into a raster dataset. Defines a rectangular area for reading/writing a portion of raster data.

Fields§

§col_off: u32

Column offset from the left edge (0-based)

§row_off: u32

Row offset from the top edge (0-based)

§width: u32

Width of the window in pixels

§height: u32

Height of the window in pixels

Implementations§

Source§

impl RasterWindow

Source

pub fn new(col_off: u32, row_off: u32, width: u32, height: u32) -> Result<Self>

Create a new window. Validates that width and height are > 0.

Source

pub fn full(raster_width: u32, raster_height: u32) -> Result<Self>

Create a window covering the full extent of a raster.

Source

pub fn fits_within(&self, raster_width: u32, raster_height: u32) -> bool

Check if this window fits within a raster of the given dimensions.

Source

pub fn validate_bounds( &self, raster_width: u32, raster_height: u32, ) -> Result<()>

Validate that this window fits within the given raster dimensions. Returns an error if any part is out of bounds.

Source

pub fn pixel_count(&self) -> u64

Total number of pixels in this window.

Source

pub fn intersection(&self, other: &RasterWindow) -> Option<RasterWindow>

Intersect this window with another, returning the overlapping region. Returns None if they don’t overlap.

Source

pub fn union_bounds(&self, other: &RasterWindow) -> RasterWindow

Compute the union bounding box of this window and another.

Source

pub fn contains_pixel(&self, col: u32, row: u32) -> bool

Check if this window contains the given pixel coordinates.

Source

pub fn subdivide( &self, tile_width: u32, tile_height: u32, ) -> Result<Vec<RasterWindow>>

Subdivide this window into tiles of the given size. The last tiles in each row/column may be smaller.

Source

pub fn to_global(&self, local_col: u32, local_row: u32) -> Result<(u32, u32)>

Convert a pixel coordinate from window-local to global raster coordinates.

Source

pub fn to_local(&self, global_col: u32, global_row: u32) -> Option<(u32, u32)>

Convert a pixel coordinate from global raster to window-local coordinates. Returns None if the global coordinate is outside this window.

Source

pub fn extract_from_buffer( &self, source: &[u8], raster_width: u32, bytes_per_pixel: u32, ) -> Result<Vec<u8>>

Extract the bytes for this window from a full-raster band buffer. Assumes row-major layout with bytes_per_pixel bytes per pixel and raster_width pixels per row in the source buffer.

Source

pub fn write_to_buffer( &self, window_data: &[u8], dest: &mut [u8], raster_width: u32, bytes_per_pixel: u32, ) -> Result<()>

Write window data back into a full-raster band buffer.

Trait Implementations§

Source§

impl Clone for RasterWindow

Source§

fn clone(&self) -> RasterWindow

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 RasterWindow

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for RasterWindow

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for RasterWindow

Source§

fn eq(&self, other: &RasterWindow) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for RasterWindow

Source§

impl Eq for RasterWindow

Source§

impl StructuralPartialEq for RasterWindow

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.