Trait Image

Source
pub trait Image {
    type Pixel;

Show 13 methods // Required methods fn data(&self) -> &[Self::Pixel]; fn shape(&self) -> Shape; // Provided methods fn size(&self) -> Size { ... } fn width(&self) -> usize { ... } fn height(&self) -> usize { ... } fn get(&self, row: usize, col: usize) -> Option<&Self::Pixel> { ... } fn view( &self, row_min: usize, row_max: usize, col_min: usize, col_max: usize, ) -> ImageRef<'_, Self::Pixel> { ... } fn as_ref(&self) -> ImageRef<'_, Self::Pixel> { ... } fn iter(&self) -> ImageIter<'_, Self::Pixel> { ... } fn write(self, fmt: ImageWriteFormat, out: impl Write) -> Result<(), Error> where Self::Pixel: Color, Self: Sized { ... } fn write_rgba<W>(&self, out: W) -> Result<(), Error> where W: Write, Self::Pixel: Color, Self: Sized { ... } fn write_ppm<W>(&self, out: W) -> Result<(), Error> where W: Write, Self::Pixel: Color, Self: Sized { ... } fn write_bmp<W>(&self, out: W) -> Result<(), Error> where W: Write, Self::Pixel: Color, Self: Sized { ... }
}
Expand description

Trait common to all image types

Required Associated Types§

Source

type Pixel

Pixel type

Required Methods§

Source

fn data(&self) -> &[Self::Pixel]

Data containing image

Source

fn shape(&self) -> Shape

Shape of the image

Provided Methods§

Source

fn size(&self) -> Size

Image size

Source

fn width(&self) -> usize

Image width

Source

fn height(&self) -> usize

Image height

Source

fn get(&self, row: usize, col: usize) -> Option<&Self::Pixel>

Get pixel at the specified row and column

Source

fn view( &self, row_min: usize, row_max: usize, col_min: usize, col_max: usize, ) -> ImageRef<'_, Self::Pixel>

Create sub-image bounded by constraints, _max values are not inclusive.

Source

fn as_ref(&self) -> ImageRef<'_, Self::Pixel>

Create immutable view to the image of the concrete type of ImageRef

Source

fn iter(&self) -> ImageIter<'_, Self::Pixel>

Iterate over pixels

Source

fn write(self, fmt: ImageWriteFormat, out: impl Write) -> Result<(), Error>
where Self::Pixel: Color, Self: Sized,

Source

fn write_rgba<W>(&self, out: W) -> Result<(), Error>
where W: Write, Self::Pixel: Color, Self: Sized,

Write raw (height, width, RGBA…) data

Source

fn write_ppm<W>(&self, out: W) -> Result<(), Error>
where W: Write, Self::Pixel: Color, Self: Sized,

Write image in PPM format

Source

fn write_bmp<W>(&self, out: W) -> Result<(), Error>
where W: Write, Self::Pixel: Color, Self: Sized,

Write image in BMP format

Implementations on Foreign Types§

Source§

impl<I> Image for &I
where I: Image + ?Sized,

Source§

type Pixel = <I as Image>::Pixel

Source§

fn shape(&self) -> Shape

Source§

fn data(&self) -> &[Self::Pixel]

Source§

impl<I> Image for &mut I
where I: Image + ?Sized,

Source§

type Pixel = <I as Image>::Pixel

Source§

fn shape(&self) -> Shape

Source§

fn data(&self) -> &[Self::Pixel]

Source§

impl<P> Image for Arc<dyn Image<Pixel = P>>

Source§

type Pixel = P

Source§

fn shape(&self) -> Shape

Source§

fn data(&self) -> &[Self::Pixel]

Implementors§

Source§

impl<C> Image for Layer<C>

Source§

type Pixel = C

Source§

impl<P> Image for ImageMutRef<'_, P>

Source§

type Pixel = P

Source§

impl<P> Image for ImageOwned<P>

Source§

type Pixel = P

Source§

impl<P> Image for ImageRef<'_, P>

Source§

type Pixel = P