pub trait Image<T: Type, C: Color>: Sized + Sync + Send {
Show 29 methods
fn shape(&self) -> (usize, usize, usize);
fn data(&self) -> &[T] ⓘ;
fn data_mut(&mut self) -> &mut [T] ⓘ;
fn width(&self) -> usize { ... }
fn height(&self) -> usize { ... }
fn channels(&self) -> usize { ... }
fn len(&self) -> usize { ... }
fn total_bytes(&self) -> usize { ... }
fn index(&self, x: usize, y: usize, c: usize) -> usize { ... }
fn empty_pixel(&self) -> Vec<T> { ... }
fn at_mut(&mut self, x: usize, y: usize) -> &mut [T] ⓘ { ... }
fn at(&self, x: usize, y: usize) -> &[T] ⓘ { ... }
fn get_pixel<'a, P: PixelMut<'a, T, C>>(&self, x: usize, y: usize, px: &mut P) { ... }
fn get_pixel_f<'a, P: PixelMut<'a, f64, C>>(
&self,
x: usize,
y: usize,
px: &mut P
) { ... }
fn set_pixel<'a, P: Pixel<'a, T, C>>(&mut self, x: usize, y: usize, px: &P) { ... }
fn set_pixel_f<'a, P: Pixel<'a, f64, C>>(&mut self, x: usize, y: usize, px: &P) { ... }
fn get_f(&self, x: usize, y: usize, c: usize) -> f64 { ... }
fn set_f(&mut self, x: usize, y: usize, c: usize, f: f64) { ... }
fn get(&self, x: usize, y: usize, c: usize) -> T { ... }
fn set(&mut self, x: usize, y: usize, c: usize, t: T) { ... }
fn convert_type<U: Type, I: Image<U, C>>(&self, dest: &mut I) { ... }
fn as_image_ref(&mut self) -> ImageRef<'_, T, C> { ... }
fn to_image_ptr<'a>(self) -> ImagePtr<'a, T, C> { ... }
fn for_each<F: Sync + Send + Fn((usize, usize), &mut [T])>(&mut self, f: F) { ... }
fn for_each2<F: Sync + Send + Fn((usize, usize), &mut [T], &[T]), I: Image<T, C>>(
&mut self,
other: &I,
f: F
) { ... }
fn crop(
&self,
x: usize,
y: usize,
width: usize,
height: usize
) -> ImageBuf<T, C> { ... }
fn clone(&self) -> ImageBuf<T, C> { ... }
fn hash(&self) -> Hash { ... }
fn diff<I: Image<T, C>>(&self, other: &I) -> Diff { ... }
}
Expand description
The Image trait defines many methods for interaction with images in a generic manner
Required Methods§
Provided Methods§
fn width(&self) -> usize
fn height(&self) -> usize
fn channels(&self) -> usize
sourcefn total_bytes(&self) -> usize
fn total_bytes(&self) -> usize
Get the total number of bytes needed to store the image data
sourcefn index(&self, x: usize, y: usize, c: usize) -> usize
fn index(&self, x: usize, y: usize, c: usize) -> usize
Get the offset of the component at (x, y, c)
sourcefn empty_pixel(&self) -> Vec<T>
fn empty_pixel(&self) -> Vec<T>
Create a new, empty pixel with each component set to 0
sourcefn at_mut(&mut self, x: usize, y: usize) -> &mut [T] ⓘ
fn at_mut(&mut self, x: usize, y: usize) -> &mut [T] ⓘ
Get a vector of mutable references to each component at (x, y)
sourcefn at(&self, x: usize, y: usize) -> &[T] ⓘ
fn at(&self, x: usize, y: usize) -> &[T] ⓘ
Get a vector of immutable references to each component at (x, y)
sourcefn get_pixel<'a, P: PixelMut<'a, T, C>>(&self, x: usize, y: usize, px: &mut P)
fn get_pixel<'a, P: PixelMut<'a, T, C>>(&self, x: usize, y: usize, px: &mut P)
Load data from the pixel at (x, y) into px
sourcefn get_pixel_f<'a, P: PixelMut<'a, f64, C>>(&self, x: usize, y: usize, px: &mut P)
fn get_pixel_f<'a, P: PixelMut<'a, f64, C>>(&self, x: usize, y: usize, px: &mut P)
Load data from the pixel at (x, y) into px and convert to normalized f64
sourcefn set_pixel<'a, P: Pixel<'a, T, C>>(&mut self, x: usize, y: usize, px: &P)
fn set_pixel<'a, P: Pixel<'a, T, C>>(&mut self, x: usize, y: usize, px: &P)
Set data at (x, y) to px
sourcefn set_pixel_f<'a, P: Pixel<'a, f64, C>>(&mut self, x: usize, y: usize, px: &P)
fn set_pixel_f<'a, P: Pixel<'a, f64, C>>(&mut self, x: usize, y: usize, px: &P)
Set data at (x, y) to px after denormalizing
sourcefn get_f(&self, x: usize, y: usize, c: usize) -> f64
fn get_f(&self, x: usize, y: usize, c: usize) -> f64
Get a single component at (x, y, c) as a noramlized f64 value
sourcefn set_f(&mut self, x: usize, y: usize, c: usize, f: f64)
fn set_f(&mut self, x: usize, y: usize, c: usize, f: f64)
Set the component at (x, y, c) using a normalized f64 value
sourcefn convert_type<U: Type, I: Image<U, C>>(&self, dest: &mut I)
fn convert_type<U: Type, I: Image<U, C>>(&self, dest: &mut I)
Convert from type T to type U
sourcefn as_image_ref(&mut self) -> ImageRef<'_, T, C>
fn as_image_ref(&mut self) -> ImageRef<'_, T, C>
Convert Image to ImageRef
sourcefn to_image_ptr<'a>(self) -> ImagePtr<'a, T, C>
fn to_image_ptr<'a>(self) -> ImagePtr<'a, T, C>
Consume and convert Image to ImagePtr
sourcefn for_each<F: Sync + Send + Fn((usize, usize), &mut [T])>(&mut self, f: F)
fn for_each<F: Sync + Send + Fn((usize, usize), &mut [T])>(&mut self, f: F)
Iterate over each pixel
sourcefn for_each2<F: Sync + Send + Fn((usize, usize), &mut [T], &[T]), I: Image<T, C>>(
&mut self,
other: &I,
f: F
)
fn for_each2<F: Sync + Send + Fn((usize, usize), &mut [T], &[T]), I: Image<T, C>>(
&mut self,
other: &I,
f: F
)
Iterate over each pixel
sourcefn crop(&self, x: usize, y: usize, width: usize, height: usize) -> ImageBuf<T, C>
fn crop(&self, x: usize, y: usize, width: usize, height: usize) -> ImageBuf<T, C>
Create a new image from the region specified by (x, y, width, height)