pub struct HeightmapView<'a> {
pub format: HeightmapFormat,
pub rgb: &'a [u8],
pub width: u32,
pub height: u32,
}Expand description
Zero-copy borrowed view over an encoded RGB heightmap.
Holds a &[u8] referencing the source bytes and lazily yields decoded
elevations via Self::iter / Self::get — no Vec<f32> is
materialised unless the caller explicitly asks via Self::to_vec or
Self::decode_into.
Fields§
§format: HeightmapFormatFormat used to interpret the bytes.
rgb: &'a [u8]Raw RGB bytes (width * height * 3 bytes, row-major).
width: u32Image width in pixels.
height: u32Image height in pixels.
Implementations§
Source§impl<'a> HeightmapView<'a>
impl<'a> HeightmapView<'a>
Sourcepub fn new(
format: HeightmapFormat,
rgb: &'a [u8],
width: u32,
height: u32,
) -> Self
pub fn new( format: HeightmapFormat, rgb: &'a [u8], width: u32, height: u32, ) -> Self
Wrap an RGB buffer. Asserts rgb.len() == width * height * 3.
Sourcepub fn iter(&self) -> impl Iterator<Item = f32> + '_
pub fn iter(&self) -> impl Iterator<Item = f32> + '_
Iterator over decoded elevations in row-major order.
Sourcepub fn decode_into(&self, out: &mut [f32])
pub fn decode_into(&self, out: &mut [f32])
Decode the entire view into a caller-owned buffer.
Trait Implementations§
Source§impl<'a> Clone for HeightmapView<'a>
impl<'a> Clone for HeightmapView<'a>
Source§fn clone(&self) -> HeightmapView<'a>
fn clone(&self) -> HeightmapView<'a>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a> Debug for HeightmapView<'a>
impl<'a> Debug for HeightmapView<'a>
impl<'a> Copy for HeightmapView<'a>
Auto Trait Implementations§
impl<'a> Freeze for HeightmapView<'a>
impl<'a> RefUnwindSafe for HeightmapView<'a>
impl<'a> Send for HeightmapView<'a>
impl<'a> Sync for HeightmapView<'a>
impl<'a> Unpin for HeightmapView<'a>
impl<'a> UnsafeUnpin for HeightmapView<'a>
impl<'a> UnwindSafe for HeightmapView<'a>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more