[−][src]Trait image2::image::Image
The Image trait defines many methods for interaction with images in a generic manner
Required methods
fn shape(&self) -> (usize, usize, usize)
Returns the width, height and channels of an image
fn data(&self) -> &[T]
An immutable reference to the underlying image data
fn data_mut(&mut self) -> &mut [T]
A mutable reference to the underlying image data
Provided methods
fn buffer(&self) -> &[u8]
fn buffer_mut(&self) -> &[u8]
fn width(&self) -> usize
fn height(&self) -> usize
fn channels(&self) -> usize
fn len(&self) -> usize
Get the number of total elements in an image
fn total_bytes(&self) -> usize
Get the total number of bytes needed to store the image data
fn index(&self, x: usize, y: usize, c: usize) -> usize
Get the offset of the component at (x, y, c)
fn empty_pixel(&self) -> Vec<T>
Create a new, empty pixel with each component set to 0
fn empty_pixel_f(&self) -> Vec<f64>
Create a new, empty pixel with each component set to 0
fn at_mut(&mut self, x: usize, y: usize) -> &mut [T]
Get a vector of mutable references to each component at (x, y)
fn at(&self, x: usize, y: usize) -> &[T]
Get a vector of immutable references to each component at (x, y)
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
fn get_pixel_f<'a, P: PixelMut<'a, f64, C>>(
&self,
x: usize,
y: usize,
px: &mut P
)
&self,
x: usize,
y: usize,
px: &mut P
)
Load data from the pixel at (x, y) into px and convert to normalized f64
fn set_pixel<'a, P: Pixel<'a, T, C>>(&mut self, x: usize, y: usize, px: &P)
Set data at (x, y) to px
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
fn get_f(&self, x: usize, y: usize, c: usize) -> f64
Get a single component at (x, y, c) as a noramlized f64 value
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
fn get(&self, x: usize, y: usize, c: usize) -> T
Get a single component at (x, y, c)
fn set(&mut self, x: usize, y: usize, c: usize, t: T)
Set a single component at (x, y, c)
fn convert_type<U: Type, I: Image<U, C>>(&self, dest: &mut I)
Convert from type T to type U
fn as_image_ref(&mut self) -> ImageRef<T, C>
Convert Image to ImageRef
fn to_image_ptr<'a>(self) -> ImagePtr<'a, T, C>
Consume and convert Image to ImagePtr
fn for_each<F: Sync + Send + Fn((usize, usize), &mut [T])>(&mut self, f: F)
Iterate over each pixel
fn for_each2<F: Sync + Send + Fn((usize, usize), &mut [T], &[T]), I: Image<T, C>>(
&mut self,
other: &I,
f: F
)
&mut self,
other: &I,
f: F
)
Iterate over each pixel
fn crop(
&self,
x: usize,
y: usize,
width: usize,
height: usize
) -> ImageBuf<T, C>
&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)
fn clone(&self) -> ImageBuf<T, C>
fn multiply<'a, P: Pixel<'a, f64, C>>(&mut self, px: &P)
fn add<'a, P: Pixel<'a, f64, C>>(&mut self, px: &P)
fn hash(&self) -> Hash
fn diff<I: Image<T, C>>(&self, other: &I) -> Diff
fn gamma(&mut self, gamma: f64)
Adjust gamma NOTE: this function does not work with f32 or f64 images
fn gamma_multiply<'a, P: Pixel<'a, f64, C>>(&mut self, gamma: f64, pixel: &P)
Adjust gamma and scale NOTE: this function does not work with f32 or f64 images