Skip to main content

Image

Struct Image 

Source
pub struct Image<T: ImageDataType> { /* private fields */ }

Implementations§

Source§

impl<T: ImageDataType> Image<T>

Source

pub fn new_with_padding( size: (usize, usize), offset: (usize, usize), padding: (usize, usize), ) -> Result<Image<T>>

Source

pub fn new(size: (usize, usize)) -> Result<Image<T>>

Source

pub fn new_uninit(size: (usize, usize)) -> Result<Image<T>>

Allocates an uninitialized image buffer.

With the allow-unsafe feature, the memory is left truly uninitialized (saving page-fault and zeroing costs). Without it, the buffer is zeroed.

§Safety contract

The caller MUST write every pixel before reading it.

Source

pub fn new_with_value(size: (usize, usize), value: T) -> Result<Image<T>>

Source

pub fn allocation_size(size: (usize, usize)) -> u64

Computes the allocation size in bytes for an image of the given dimensions. This accounts for cache-line alignment of rows.

Source

pub fn new_tracked( size: (usize, usize), tracker: &MemoryTracker, ) -> Result<Image<T>>

Creates a new image after checking the memory tracker budget. The image tracks its allocation and releases the budget on drop.

Source

pub fn new_with_padding_tracked( size: (usize, usize), offset: (usize, usize), padding: (usize, usize), tracker: &MemoryTracker, ) -> Result<Image<T>>

Creates a new image with padding after checking the memory tracker budget. The image tracks its allocation and releases the budget on drop.

Source

pub fn size(&self) -> (usize, usize)

Source

pub fn offset(&self) -> (usize, usize)

Source

pub fn padding(&self) -> (usize, usize)

Source

pub fn fill(&mut self, v: T)

Source

pub fn get_rect_including_padding_mut( &mut self, rect: Rect, ) -> ImageRectMut<'_, T>

Source

pub fn get_rect_including_padding(&mut self, rect: Rect) -> ImageRect<'_, T>

Source

pub fn get_rect_mut(&mut self, rect: Rect) -> ImageRectMut<'_, T>

Source

pub fn get_rect(&self, rect: Rect) -> ImageRect<'_, T>

Source

pub fn try_clone(&self) -> Result<Self>

Source

pub fn into_raw(self) -> OwnedRawImage

Source

pub fn from_raw(raw: OwnedRawImage) -> Self

Source

pub fn row(&self, row: usize) -> &[T]

Source

pub fn row_mut(&mut self, row: usize) -> &mut [T]

Source

pub fn distinct_full_rows_mut<I: DistinctRowsIndexes>( &mut self, rows: I, ) -> I::CastOutput<'_, T>

Note: this is quadratic in the number of rows. Indexing ignores any padding rows, i.e. the row at index 0 will be the first row of the padding, unlike with all the other row accessors.

Source

pub fn all_rows_mut(&mut self) -> Vec<&mut [T]>

Returns mutable slices for all rows. Each slice has exactly width elements where width = self.size().0. Rows are disjoint within the underlying buffer (separated by cache-line-aligned stride).

Trait Implementations§

Source§

impl<T: ImageDataType> Debug for Image<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Image<T>

§

impl<T> RefUnwindSafe for Image<T>
where T: RefUnwindSafe,

§

impl<T> Send for Image<T>

§

impl<T> Sync for Image<T>

§

impl<T> Unpin for Image<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Image<T>

§

impl<T> UnwindSafe for Image<T>
where T: UnwindSafe,

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> 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, 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.