pub struct Image<T: ImageDataType> { /* private fields */ }Implementations§
Source§impl<T: ImageDataType> Image<T>
impl<T: ImageDataType> Image<T>
pub fn new_with_padding( size: (usize, usize), offset: (usize, usize), padding: (usize, usize), ) -> Result<Image<T>>
pub fn new(size: (usize, usize)) -> Result<Image<T>>
Sourcepub fn new_uninit(size: (usize, usize)) -> Result<Image<T>>
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.
pub fn new_with_value(size: (usize, usize), value: T) -> Result<Image<T>>
Sourcepub fn allocation_size(size: (usize, usize)) -> u64
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.
Sourcepub fn new_tracked(
size: (usize, usize),
tracker: &MemoryTracker,
) -> Result<Image<T>>
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.
Sourcepub fn new_with_padding_tracked(
size: (usize, usize),
offset: (usize, usize),
padding: (usize, usize),
tracker: &MemoryTracker,
) -> Result<Image<T>>
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.
pub fn size(&self) -> (usize, usize)
pub fn offset(&self) -> (usize, usize)
pub fn padding(&self) -> (usize, usize)
pub fn fill(&mut self, v: T)
pub fn get_rect_including_padding_mut( &mut self, rect: Rect, ) -> ImageRectMut<'_, T>
pub fn get_rect_including_padding(&mut self, rect: Rect) -> ImageRect<'_, T>
pub fn get_rect_mut(&mut self, rect: Rect) -> ImageRectMut<'_, T>
pub fn get_rect(&self, rect: Rect) -> ImageRect<'_, T>
pub fn try_clone(&self) -> Result<Self>
pub fn into_raw(self) -> OwnedRawImage
pub fn from_raw(raw: OwnedRawImage) -> Self
pub fn row(&self, row: usize) -> &[T]
pub fn row_mut(&mut self, row: usize) -> &mut [T]
Sourcepub fn distinct_full_rows_mut<I: DistinctRowsIndexes>(
&mut self,
rows: I,
) -> I::CastOutput<'_, T>
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.
Sourcepub fn all_rows_mut(&mut self) -> Vec<&mut [T]>
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).