Trait rasterize::Image

source ·
pub trait Image {
    type Pixel;

    // 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_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_rgba<W>(&self, out: W) -> Result<(), Error>
where W: Write, Self::Pixel: Color, Self: Sized,

Write raw 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<'a, I> Image for &'a I
where I: Image + ?Sized,

§

type Pixel = <I as Image>::Pixel

source§

fn shape(&self) -> Shape

source§

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

source§

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

§

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>>

§

type Pixel = P

source§

fn shape(&self) -> Shape

source§

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

Implementors§

source§

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

§

type Pixel = P

source§

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

§

type Pixel = P

source§

impl<C> Image for Layer<C>

§

type Pixel = C

source§

impl<P> Image for ImageOwned<P>

§

type Pixel = P