[−][src]Struct pel::RawSurface
Raw, generic surface used by pel.
Methods
impl<I> RawSurface<I> where
I: Default + Copy,
[src]
I: Default + Copy,
pub fn new(w: usize, h: usize) -> Self
[src]
Surface constructor.
pub fn width(&self) -> usize
[src]
Surface width.
pub fn height(&self) -> usize
[src]
Surface height.
pub fn size(&self) -> (usize, usize)
[src]
Surface size as a (width, height) tuple.
pub fn into_raw_parts(self) -> (Vec<I>, usize, usize)
[src]
Decomposes surface into its raw components.
- buf - a vector of BGRA bytes;
- w - surface width in pels;
- h - surface height in pels.
pub fn from_raw_parts(buf: Vec<I>, w: usize, h: usize) -> Self
[src]
Creates surface directly from the raw components of another surface.
Panics
If buf.len()
isn't equal to w * h
.
pub unsafe fn from_raw_parts_unchecked(buf: Vec<I>, w: usize, h: usize) -> Self
[src]
Creates surface directly from the raw components of another surface without checking if buffer size is correct.
Safety
If buf.len()
isn't equal to w * h
, undefined behaviour may be invoked by later
operations on this surface.
pub fn as_ptr(&self) -> *const I
[src]
Returns a raw pointer to the surface's internal buffer.
The caller must ensure that the surface outlives the pointer this function returns, or else
it will end up pointing to garbage. The caller must also ensure that the memory the
pointer (non-transitively) points to is never written to (except inside an
UnsafeCell
) using this pointer or any pointer derived from it.
pub fn as_mut_ptr(&mut self) -> *mut I
[src]
Returns an unsafe mutable pointer to the surface's internal buffer.
The caller must ensure that the surface outlives the pointer this function returns, or else it will end up pointing to garbage.
pub fn as_slice(&self) -> &[I]
[src]
Extracts a slice referencing entire underlying buffer.
pub fn as_mut_slice(&mut self) -> &mut [I]
[src]
Extracts a mutable slice referencing entire underlying buffer.
pub fn clear<O: Into<I>>(&mut self, value: O)
[src]
Clears entire surface with pel value.
pub fn for_each<F, O>(&mut self, f: F) where
F: Fn(O) -> O,
O: From<I> + Into<I>,
[src]
F: Fn(O) -> O,
O: From<I> + Into<I>,
Transforms all pels using given function.
pub fn read<O: From<I>>(&self, x: usize, y: usize) -> Result<O>
[src]
pub fn write<O: Into<I>>(&mut self, x: usize, y: usize, value: O) -> Result<()>
[src]
pub unsafe fn read_unchecked<O: From<I>>(&self, x: usize, y: usize) -> O
[src]
Reads pel value.
Safety
It is undefined behaviour to provide indices that are out of surface bounds.
pub unsafe fn write_unchecked<O: Into<I>>(
&mut self,
x: usize,
y: usize,
value: O
)
[src]
&mut self,
x: usize,
y: usize,
value: O
)
Writes pel value.
Safety
It is undefined behaviour to provide indices that are out of surface bounds.
pub fn index(&self, x: usize, y: usize) -> Result<usize>
[src]
Calculates index of a pel at (x, y) of this surface.
(0, 0) is top left of the surface.
Errors
If indices are out of surface bounds, Error::OutOfBounds
is returned.
pub fn index_unchecked(&self, x: usize, y: usize) -> usize
[src]
Calculates index of a pel at (x, y) of this surface.
(0, 0) is top left of the surface.
This function doesn't check if index is in bounds, but is still safe.
Trait Implementations
impl<I: Clone> Clone for RawSurface<I>
[src]
fn clone(&self) -> RawSurface<I>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Auto Trait Implementations
impl<I> RefUnwindSafe for RawSurface<I> where
I: RefUnwindSafe,
I: RefUnwindSafe,
impl<I> Send for RawSurface<I> where
I: Send,
I: Send,
impl<I> Sync for RawSurface<I> where
I: Sync,
I: Sync,
impl<I> Unpin for RawSurface<I> where
I: Unpin,
I: Unpin,
impl<I> UnwindSafe for RawSurface<I> where
I: UnwindSafe,
I: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,