ImageMut

Type Alias ImageMut 

Source
pub type ImageMut<'a, Color> = Image<Color, &'a mut [Color]>;
Expand description

A mutable, borrowed image backed by a mutable reference to a slice.

This type consists of a width, a height, and a pixel slice in row-major order. The length of the pixel slice is guaranteed to match width * height and be less than or equal to MAX_PIXELS.

See ImageBuf for an owned variant of an image and ImageRef for an immutable, borrowed image.

§Examples

Directly creating an ImageMut from a slice:

let (width, height) = (512, 512);
let mut pixels = vec![Srgb::new(0, 0, 0); (width * height) as usize];
let image = ImageMut::new(width, height, &mut pixels).unwrap();

Converting a mutable reference to a RgbImage from the image crate to an ImageMut:

let mut image = RgbImage::new(256, 256);
let image = ImageMut::try_from(&mut image)?;

Aliased Type§

pub struct ImageMut<'a, Color> { /* private fields */ }

Trait Implementations§

Source§

impl<Color> Default for ImageMut<'_, Color>

Source§

fn default() -> Self

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

impl<'a, Component, Container> TryFrom<&'a mut ImageBuffer<Rgb<Component>, Container>> for ImageMut<'a, Srgb<Component>>
where Rgb<Component>: Pixel<Subpixel = Component>, Container: Deref<Target = [<Rgb<Component> as Pixel>::Subpixel]> + DerefMut,

Source§

type Error = LengthOutOfRange

The type returned in the event of a conversion error.
Source§

fn try_from( image: &'a mut ImageBuffer<Rgb<Component>, Container>, ) -> Result<Self, Self::Error>

Performs the conversion.