Struct imgref::Img [] [src]

pub struct Img<Container> {
    pub buf: Container,
    pub stride: usize,
    pub width: u32,
    pub height: u32,
}

Basic struct used for both owned (alias ImgVec) and borrowed (alias ImgRef) image fragments.

Note: the fields are pub only because of borrow checker limitations. Please consider them as read-only.

Fields

Storage for the pixels. Usually Vec<Pixel> or &[Pixel]. See ImgVec and ImgRef.

Number of pixels to skip in the container to advance to the next row.

Note: pixels between width and stride may not be usable, and may not even exist in the last row.

Width of the image in pixels.

Note that this isn't same as the width of the row in the buf, see stride

Height of the image in pixels.

Methods

impl<Container> Img<Container>
[src]

Width of the image in pixels.

Note that this isn't same as the width of the row in image data, see stride()

Height of the image in pixels.

Number of pixels to skip in the container to advance to the next row. Note the last row may have fewer pixels than the stride.

impl<'a, T> Img<&'a [T]>
[src]

Make a reference for a part of the image, without copying any pixels.

Deprecated

Note: it iterates all pixels in the underlying buffer, not just limited by width/height.

impl<Container> Img<Container>
[src]

Same as new(), except each row is located stride number of pixels after the previous one.

Stride can be equal to width or larger. If it's larger, then pixels between end of previous row and start of the next are considered a padding, and may be ignored.

Create new image with Container (which can be Vec, &[] or something else) with given width and height in pixels.

Assumes the pixels in container are contiguous, layed out row by row with width pixels per row and at least height rows.

impl<OldContainer> Img<OldContainer>
[src]

A convenience method for creating an image of the same size and stride, but with a new buffer.

Trait Implementations

impl<'a, Pixel: Copy> Index<(usize, usize)> for Img<&'a [Pixel]>
[src]

The returned type after indexing

Read a pixel at (x,y) location.

Coordinates may be outside width/height if the buffer has enough padding. The x coordinate can't exceed stride.

impl<'a, Pixel: Copy> Index<(u32, u32)> for Img<&'a [Pixel]>
[src]

The returned type after indexing

Read a pixel at (x,y) location.

Coordinates may be outside width/height if the buffer has enough padding. The x coordinate can't exceed stride.

impl<'a, Pixel: Copy> Index<(usize, usize)> for Img<&'a mut [Pixel]>
[src]

The returned type after indexing

Read a pixel at (x,y) location.

Coordinates may be outside width/height if the buffer has enough padding. The x coordinate can't exceed stride.

impl<'a, Pixel: Copy> Index<(u32, u32)> for Img<&'a mut [Pixel]>
[src]

The returned type after indexing

Read a pixel at (x,y) location.

Coordinates may be outside width/height if the buffer has enough padding. The x coordinate can't exceed stride.

impl<'a, Pixel: Copy> IndexMut<(usize, usize)> for Img<&'a mut [Pixel]>
[src]

Write a pixel at (x,y) location.

Coordinates may be outside width/height if the buffer has enough padding. The x coordinate can't exceed stride.

impl<'a, Pixel: Copy> IndexMut<(u32, u32)> for Img<&'a mut [Pixel]>
[src]

Write a pixel at (x,y) location.

Coordinates may be outside width/height if the buffer has enough padding. The x coordinate can't exceed stride.

impl<'a, Pixel: Copy> Index<(usize, usize)> for Img<Vec<Pixel>>
[src]

The returned type after indexing

Read a pixel at (x,y) location.

Coordinates may be outside width/height if the buffer has enough padding. The x coordinate can't exceed stride.

impl<'a, Pixel: Copy> Index<(u32, u32)> for Img<Vec<Pixel>>
[src]

The returned type after indexing

Read a pixel at (x,y) location.

Coordinates may be outside width/height if the buffer has enough padding. The x coordinate can't exceed stride.

impl<'a, Pixel: Copy> IndexMut<(usize, usize)> for Img<Vec<Pixel>>
[src]

Write a pixel at (x,y) location.

Coordinates may be outside width/height if the buffer has enough padding. The x coordinate can't exceed stride.

impl<'a, Pixel: Copy> IndexMut<(u32, u32)> for Img<Vec<Pixel>>
[src]

Write a pixel at (x,y) location.

Coordinates may be outside width/height if the buffer has enough padding. The x coordinate can't exceed stride.

impl<Container: Clone> Clone for Img<Container>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<Pixel, Container> ImgExt<Pixel> for Img<Container> where
    Container: AsRef<[Pixel]>, 
[src]

Maximum possible width of the data, including the stride. Read more

Height in number of full strides. If the underlying buffer is not an even multiple of strides, the last row is ignored. Read more

impl<'a, T> Copy for Img<&'a [T]>
[src]

References (ImgRef) should be passed "by value" to avoid a double indirection of &Img<&[]>.

impl<Container> IntoIterator for Img<Container> where
    Container: IntoIterator
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more