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
buf: Container
Storage for the pixels. Usually Vec<Pixel>
or &[Pixel]
. See ImgVec
and ImgRef
.
Note that future version will make this field private. Use .rows()
and .pixels()
iterators where possible.
stride: usize
: Don't access struct fields directly. Use stride()
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: u32
: Don't access struct fields directly. Use width()
Width of the image in pixels.
Note that this isn't same as the width of the row in the buf
, see stride
height: u32
: Don't access struct fields directly. Use height()
Height of the image in pixels.
Methods
impl<Container> Img<Container>
[src]
impl<Container> Img<Container>
pub fn width(&self) -> usize
[src]
pub fn width(&self) -> usize
Width of the image in pixels.
Note that this isn't same as the width of the row in image data, see stride()
pub fn height(&self) -> usize
[src]
pub fn height(&self) -> usize
Height of the image in pixels.
pub fn stride(&self) -> usize
[src]
pub fn stride(&self) -> usize
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.
ⓘImportant traits for RowsIter<'a, T>pub fn rows_buf<'a, T: 'a>(&self, buf: &'a [T]) -> RowsIter<'a, T>
[src]
pub fn rows_buf<'a, T: 'a>(&self, buf: &'a [T]) -> RowsIter<'a, T>
impl<Container> Img<Container>
[src]
impl<Container> Img<Container>
pub fn new_stride(
buf: Container,
width: usize,
height: usize,
stride: usize
) -> Self
[src]
pub fn new_stride(
buf: Container,
width: usize,
height: usize,
stride: usize
) -> Self
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.
The Container
is usually a Vec
or a slice.
pub fn new(buf: Container, width: usize, height: usize) -> Self
[src]
pub fn new(buf: Container, width: usize, height: usize) -> Self
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.
If the container is larger than width
×height
pixels, the extra rows are a considered a padding and may be ignored.
impl<OldContainer> Img<OldContainer>
[src]
impl<OldContainer> Img<OldContainer>
pub fn new_buf<NewContainer, OldPixel, NewPixel>(
&self,
new_buf: NewContainer
) -> Img<NewContainer> where
NewContainer: AsRef<[NewPixel]>,
OldContainer: AsRef<[OldPixel]>,
[src]
pub fn new_buf<NewContainer, OldPixel, NewPixel>(
&self,
new_buf: NewContainer
) -> Img<NewContainer> where
NewContainer: AsRef<[NewPixel]>,
OldContainer: AsRef<[OldPixel]>,
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]
impl<'a, Pixel: Copy> Index<(usize, usize)> for Img<&'a [Pixel]>
type Output = Pixel
The returned type after indexing.
fn index(&self, index: (usize, usize)) -> &Self::Output
[src]
fn index(&self, index: (usize, usize)) -> &Self::Output
Read a pixel at (x,y)
location (e.g. px = img[(x,y)]
)
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]
impl<'a, Pixel: Copy> Index<(u32, u32)> for Img<&'a [Pixel]>
type Output = Pixel
The returned type after indexing.
fn index(&self, index: (u32, u32)) -> &Self::Output
[src]
fn index(&self, index: (u32, u32)) -> &Self::Output
Read a pixel at (x,y)
location (e.g. px = img[(x,y)]
)
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]
impl<'a, Pixel: Copy> Index<(usize, usize)> for Img<&'a mut [Pixel]>
type Output = Pixel
The returned type after indexing.
fn index(&self, index: (usize, usize)) -> &Self::Output
[src]
fn index(&self, index: (usize, usize)) -> &Self::Output
Read a pixel at (x,y)
location (e.g. px = img[(x,y)]
)
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]
impl<'a, Pixel: Copy> Index<(u32, u32)> for Img<&'a mut [Pixel]>
type Output = Pixel
The returned type after indexing.
fn index(&self, index: (u32, u32)) -> &Self::Output
[src]
fn index(&self, index: (u32, u32)) -> &Self::Output
Read a pixel at (x,y)
location (e.g. px = img[(x,y)]
)
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]
impl<'a, Pixel: Copy> IndexMut<(usize, usize)> for Img<&'a mut [Pixel]>
fn index_mut(&mut self, index: (usize, usize)) -> &mut Self::Output
[src]
fn index_mut(&mut self, index: (usize, usize)) -> &mut Self::Output
Write a pixel at (x,y)
location (e.g. img[(x,y)] = px
)
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]
impl<'a, Pixel: Copy> IndexMut<(u32, u32)> for Img<&'a mut [Pixel]>
fn index_mut(&mut self, index: (u32, u32)) -> &mut Self::Output
[src]
fn index_mut(&mut self, index: (u32, u32)) -> &mut Self::Output
Write a pixel at (x,y)
location (e.g. img[(x,y)] = px
)
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]
impl<'a, Pixel: Copy> Index<(usize, usize)> for Img<Vec<Pixel>>
type Output = Pixel
The returned type after indexing.
fn index(&self, index: (usize, usize)) -> &Self::Output
[src]
fn index(&self, index: (usize, usize)) -> &Self::Output
Read a pixel at (x,y)
location (e.g. px = img[(x,y)]
)
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]
impl<'a, Pixel: Copy> Index<(u32, u32)> for Img<Vec<Pixel>>
type Output = Pixel
The returned type after indexing.
fn index(&self, index: (u32, u32)) -> &Self::Output
[src]
fn index(&self, index: (u32, u32)) -> &Self::Output
Read a pixel at (x,y)
location (e.g. px = img[(x,y)]
)
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]
impl<'a, Pixel: Copy> IndexMut<(usize, usize)> for Img<Vec<Pixel>>
fn index_mut(&mut self, index: (usize, usize)) -> &mut Self::Output
[src]
fn index_mut(&mut self, index: (usize, usize)) -> &mut Self::Output
Write a pixel at (x,y)
location (e.g. img[(x,y)] = px
)
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]
impl<'a, Pixel: Copy> IndexMut<(u32, u32)> for Img<Vec<Pixel>>
fn index_mut(&mut self, index: (u32, u32)) -> &mut Self::Output
[src]
fn index_mut(&mut self, index: (u32, u32)) -> &mut Self::Output
Write a pixel at (x,y)
location (e.g. img[(x,y)] = px
)
Coordinates may be outside width
/height
if the buffer has enough padding.
The x coordinate can't exceed stride
.
impl<Container: Debug> Debug for Img<Container>
[src]
impl<Container: Debug> Debug for Img<Container>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<Container: Copy> Copy for Img<Container>
[src]
impl<Container: Copy> Copy for Img<Container>
impl<Container: Clone> Clone for Img<Container>
[src]
impl<Container: Clone> Clone for Img<Container>
fn clone(&self) -> Img<Container>
[src]
fn clone(&self) -> Img<Container>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<Container: Hash> Hash for Img<Container>
[src]
impl<Container: Hash> Hash for Img<Container>
fn hash<__HContainer: Hasher>(&self, state: &mut __HContainer)
[src]
fn hash<__HContainer: Hasher>(&self, state: &mut __HContainer)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<Container: PartialEq> PartialEq for Img<Container>
[src]
impl<Container: PartialEq> PartialEq for Img<Container>
fn eq(&self, other: &Img<Container>) -> bool
[src]
fn eq(&self, other: &Img<Container>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Img<Container>) -> bool
[src]
fn ne(&self, other: &Img<Container>) -> bool
This method tests for !=
.
impl<Container: Eq> Eq for Img<Container>
[src]
impl<Container: Eq> Eq for Img<Container>
impl<Pixel, Container> ImgExt<Pixel> for Img<Container> where
Container: AsRef<[Pixel]>,
[src]
impl<Pixel, Container> ImgExt<Pixel> for Img<Container> where
Container: AsRef<[Pixel]>,
fn width_padded(&self) -> usize
[src]
fn width_padded(&self) -> usize
Maximum possible width of the data, including the stride. Read more
fn height_padded(&self) -> usize
[src]
fn height_padded(&self) -> usize
Height in number of full strides. If the underlying buffer is not an even multiple of strides, the last row is ignored. Read more
fn rows_padded(&self) -> Chunks<Pixel>
[src]
fn rows_padded(&self) -> Chunks<Pixel>
Iterate over the entire buffer as rows, including all padding
Rows will have up to stride
width, but the last row may be shorter.
impl<Pixel, Container> ImgExtMut<Pixel> for Img<Container> where
Container: AsMut<[Pixel]>,
[src]
impl<Pixel, Container> ImgExtMut<Pixel> for Img<Container> where
Container: AsMut<[Pixel]>,
fn rows_padded_mut(&mut self) -> ChunksMut<Pixel>
[src]
fn rows_padded_mut(&mut self) -> ChunksMut<Pixel>
Iterate over the entire buffer as rows, including all padding
Rows will have up to stride
width, but the last row may be shorter.
impl<Container> IntoIterator for Img<Container> where
Container: IntoIterator,
[src]
impl<Container> IntoIterator for Img<Container> where
Container: IntoIterator,