Struct PixelVec
pub struct PixelVec<T> { pub resolution: Vec2<usize>, pub pixels: Vec<T> }
Store all samples in a single array.
All samples will be converted to the type T.
This supports all the sample types, f16, f32, and u32.
The flattened vector contains all rows one after another. In each row, for each pixel, its red, green, blue, and then alpha samples are stored one after another.
Use PixelVec.compute_pixel_index(position)
to compute the flat index of a specific pixel.
Fields
resolution: Vec2<usize>The resolution of this layer.
pixels: Vec<T>The flattened vector contains all rows one after another. In each row, for each pixel, its red, green, blue, and then alpha samples are stored one after another.
Use
Flattened::compute_pixel_index(image, position)to compute the flat index of a specific pixel.
Implementations
impl<Pixel> PixelVec<Pixel>
fn constructor<Channels>(resolution: Vec2<usize>, &Channels) -> Self where Pixel: Default + Clone,Create a new flattened pixel storage, filled with default pixels. Accepts a
Channelsparameter, which is not used, so that it can be passed as a function pointer instead of calling it.fn get_pixel(&self, position: Vec2<usize>) -> &Pixel where Pixel: Sync,Examine a pixel of a
PixelVec<T>image. Can usually be used as a function reference instead of calling it directly.fn set_pixel(&mut self, position: Vec2<usize>, pixel: Pixel)Update a pixel of a
PixelVec<T>image. Can usually be used as a function reference instead of calling it directly.fn new(resolution: impl Into<Vec2<usize>>, pixels: Vec<Pixel>) -> SelfCreate a new flattened pixel storage, checking the length of the provided pixels vector.
fn compute_pixel_index(&self, position: Vec2<usize>) -> usizeCompute the flat index of a specific pixel. Returns a range of either 3 or 4 samples. The computed index can be used with
PixelVec.samples[index]. Panics for invalid sample coordinates.
Trait Implementations
impl<Px> GetPixel for PixelVec<Px>
where
Px: Clone + Sync,
type Pixel = Px;fn get_pixel(&self, position: Vec2<usize>) -> Self::Pixel
impl<Px> ValidateResult for PixelVec<Px>
where
Px: ValidateResult,
fn validate_result(&self, other: &Self, options: ValidationOptions, location: impl Fn() -> String) -> ValidationResult
impl<T> Debug for PixelVec<T>
fn fmt(&self, formatter: &mut Formatter<'_>) -> Result
impl<T: Clone> Clone for PixelVec<T>
fn clone(&self) -> Self
impl<T: Eq> Eq for PixelVec<T>
impl<T: PartialEq> PartialEq for PixelVec<T>
fn eq(&self, other: &Self) -> bool
impl<T: PartialEq> StructuralPartialEq for PixelVec<T>
Auto Trait Implementations
impl<T> Freeze for PixelVec<T>
where
Vec<T>: Freeze,
impl<T> RefUnwindSafe for PixelVec<T>
where
Vec<T>: RefUnwindSafe,
impl<T> Send for PixelVec<T>
where
Vec<T>: Send,
impl<T> Sync for PixelVec<T>
where
Vec<T>: Sync,
impl<T> Unpin for PixelVec<T>
where
Vec<T>: Unpin,
impl<T> UnsafeUnpin for PixelVec<T>
where
Vec<T>: UnsafeUnpin,
impl<T> UnwindSafe for PixelVec<T>
where
Vec<T>: UnwindSafe,
Blanket Implementations
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for PixelVec<T>
where
ST: ?Sized,
DT: ?Sized,
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for PixelVec<T>
where
ST: ?Sized,
DT: ?Sized,
impl<T> Any for PixelVec<T>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for PixelVec<T>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for PixelVec<T>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for PixelVec<T>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for PixelVec<T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Pointable for PixelVec<T>
const ALIGN: usize = _;type Init = T;unsafe fn init(init: <T as Pointable>::Init) -> usizeunsafe fn deref<'a>(ptr: usize) -> &'a Tunsafe fn deref_mut<'a>(ptr: usize) -> &'a mut Tunsafe fn drop(ptr: usize)
impl<T> Read<Exclusive, BecauseExclusive> for PixelVec<T>
where
T: ?Sized,
impl<T> ToOwned for PixelVec<T>
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for PixelVec<T>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for PixelVec<T>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for PixelVec<T>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>