Skip to main content

Image

Struct Image 

Source
pub struct Image<P, S = ImageSize> { /* private fields */ }
Expand description

Generic image type

The image is laid out in row-major order, and can be indexed either by a usize index or a (row, column) tuple.

       0 ------------> width (columns)
       |             |
       |             |
       |             |
       V--------------
  height (rows)

Implementations§

Source§

impl<P: Send, S: ImageSizeLike + Sync> Image<P, S>

Source

pub fn apply_effect<F: Fn(usize, usize) -> P + Send + Sync>( &mut self, f: F, threads: Option<&ThreadPool>, )

Generates an image by computing a per-pixel function

This should be called on the output image; the closure takes (x, y) tuples and is expected to capture one or more source images.

Source§

impl<P: Default + Clone, S: ImageSizeLike> Image<P, S>

Source

pub fn new(size: S) -> Self

Builds a new image filled with P::default()

Source§

impl<P, S: Clone> Image<P, S>

Source

pub fn size(&self) -> S

Returns the image size

Source

pub fn map<T, F: Fn(&P) -> T>(&self, f: F) -> Image<T, S>

Generates an image by mapping a simple function over each pixel

Source

pub fn take(self) -> (Vec<P>, S)

Decomposes the image into its components

Source§

impl<P, S: ImageSizeLike> Image<P, S>

Source

pub fn width(&self) -> usize

Returns the image width

Source

pub fn height(&self) -> usize

Returns the image height

Source§

impl<P, S> Image<P, S>

Source

pub fn iter(&self) -> impl Iterator<Item = &P> + '_

Iterates over pixel values

Source

pub fn len(&self) -> usize

Returns the number of pixels in the image

Source

pub fn is_empty(&self) -> bool

Checks whether the image is empty

Source§

impl<P: Default + Copy + Clone> Image<P, VoxelSize>

Source

pub fn depth(&self) -> usize

Returns the image depth in voxels

Trait Implementations§

Source§

impl<P: Clone, S: Clone> Clone for Image<P, S>

Source§

fn clone(&self) -> Image<P, S>

Returns a duplicate 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<P, S: Default> Default for Image<P, S>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<P, S: ImageSizeLike> Index<(usize, usize)> for Image<P, S>

Indexes an image with (row, col)

Source§

type Output = P

The returned type after indexing.
Source§

fn index(&self, pos: (usize, usize)) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<P, S> Index<Range<usize>> for Image<P, S>

Source§

type Output = [P]

The returned type after indexing.
Source§

fn index(&self, index: Range<usize>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<P, S> Index<RangeFrom<usize>> for Image<P, S>

Source§

type Output = [P]

The returned type after indexing.
Source§

fn index(&self, index: RangeFrom<usize>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<P, S> Index<RangeFull> for Image<P, S>

Source§

type Output = [P]

The returned type after indexing.
Source§

fn index(&self, index: RangeFull) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<P, S> Index<RangeInclusive<usize>> for Image<P, S>

Source§

type Output = [P]

The returned type after indexing.
Source§

fn index(&self, index: RangeInclusive<usize>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<P, S> Index<RangeTo<usize>> for Image<P, S>

Source§

type Output = [P]

The returned type after indexing.
Source§

fn index(&self, index: RangeTo<usize>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<P, S> Index<RangeToInclusive<usize>> for Image<P, S>

Source§

type Output = [P]

The returned type after indexing.
Source§

fn index(&self, index: RangeToInclusive<usize>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<P, S> Index<usize> for Image<P, S>

Source§

type Output = P

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<P, S: ImageSizeLike> IndexMut<(usize, usize)> for Image<P, S>

Source§

fn index_mut(&mut self, pos: (usize, usize)) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<P, S> IndexMut<Range<usize>> for Image<P, S>

Source§

fn index_mut(&mut self, index: Range<usize>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<P, S> IndexMut<RangeFrom<usize>> for Image<P, S>

Source§

fn index_mut(&mut self, index: RangeFrom<usize>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<P, S> IndexMut<RangeFull> for Image<P, S>

Source§

fn index_mut(&mut self, index: RangeFull) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<P, S> IndexMut<RangeInclusive<usize>> for Image<P, S>

Source§

fn index_mut(&mut self, index: RangeInclusive<usize>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<P, S> IndexMut<RangeTo<usize>> for Image<P, S>

Source§

fn index_mut(&mut self, index: RangeTo<usize>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<P, S> IndexMut<RangeToInclusive<usize>> for Image<P, S>

Source§

fn index_mut(&mut self, index: RangeToInclusive<usize>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<P, S> IndexMut<usize> for Image<P, S>

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a, P: 'a, S> IntoIterator for &'a Image<P, S>

Source§

type Item = &'a P

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, P>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<P, S> IntoIterator for Image<P, S>

Source§

type Item = P

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<P>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<P, S> Freeze for Image<P, S>
where S: Freeze,

§

impl<P, S> RefUnwindSafe for Image<P, S>

§

impl<P, S> Send for Image<P, S>
where S: Send, P: Send,

§

impl<P, S> Sync for Image<P, S>
where S: Sync, P: Sync,

§

impl<P, S> Unpin for Image<P, S>
where S: Unpin, P: Unpin,

§

impl<P, S> UnsafeUnpin for Image<P, S>
where S: UnsafeUnpin,

§

impl<P, S> UnwindSafe for Image<P, S>
where S: UnwindSafe, P: 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, dest: *mut u8)

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.