Struct exr::image::pixel_vec::PixelVec

source ·
pub struct PixelVec<T> {
    pub resolution: Vec2<usize>,
    pub pixels: Vec<T>,
}
Expand description

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§

source§

impl<Pixel> PixelVec<Pixel>

source

pub fn constructor<Channels>(resolution: Vec2<usize>, _: &Channels) -> Self
where Pixel: Default + Clone,

Create a new flattened pixel storage, filled with default pixels. Accepts a Channels parameter, which is not used, so that it can be passed as a function pointer instead of calling it.

source

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

source

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

source

pub fn new(resolution: impl Into<Vec2<usize>>, pixels: Vec<Pixel>) -> Self

Create a new flattened pixel storage, checking the length of the provided pixels vector.

source

pub fn compute_pixel_index(&self, position: Vec2<usize>) -> usize

Compute 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§

source§

impl<T: Clone> Clone for PixelVec<T>

source§

fn clone(&self) -> PixelVec<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T> Debug for PixelVec<T>

source§

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

Formats the value using the given formatter. Read more
source§

impl<Px> GetPixel for PixelVec<Px>
where Px: Clone + Sync,

source§

type Pixel = Px

The pixel tuple containing f32, f16, u32 and Sample values. The length of the tuple must match the number of channels in the image.
source§

fn get_pixel(&self, position: Vec2<usize>) -> Self::Pixel

Inspect a single pixel at the requested position. Will be called exactly once for each pixel in the image. The position will not exceed the image dimensions. Might be called from multiple threads at the same time.
source§

impl<T: PartialEq> PartialEq for PixelVec<T>

source§

fn eq(&self, other: &PixelVec<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<Px> ValidateResult for PixelVec<Px>
where Px: ValidateResult,

source§

fn validate_result( &self, other: &Self, options: ValidationOptions, location: impl Fn() -> String, ) -> ValidationResult

Compare self with the other. Exceptional behaviour: Read more
source§

fn assert_equals_result(&self, result: &Self)

Compare self with the other. Panics if not equal. Read more
source§

impl<T: Eq> Eq for PixelVec<T>

source§

impl<T> StructuralPartialEq for PixelVec<T>

Auto Trait Implementations§

§

impl<T> Freeze for PixelVec<T>

§

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

§

impl<T> Send for PixelVec<T>
where T: Send,

§

impl<T> Sync for PixelVec<T>
where T: Sync,

§

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

§

impl<T> UnwindSafe for PixelVec<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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
source§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.