pub struct Rows<'s> { /* private fields */ }Expand description
Rows of one plane: a region of memory, the position of the first row, a signed stride in bytes and the number of rows.
§Examples
use webp::api::decode::{decode, ColorMode, Config};
let image = decode(&file, &Config::new(ColorMode::Rgb))?;
let rows = image.rows().expect("an RGB mode");
assert_eq!((rows.len(), rows.row_len(), rows.stride()), (2, 9, 9));
assert_eq!(&rows.row(0).unwrap()[..3], &[255, 0, 0]);
assert_eq!(rows.iter().count(), 2);Implementations§
Source§impl<'s> Rows<'s>
impl<'s> Rows<'s>
Sourcepub const fn len(&self) -> u32
pub const fn len(&self) -> u32
The number of rows.
§Examples
use webp::api::decode::{decode, ColorMode, Config};
assert_eq!(decode(&file, &Config::new(ColorMode::Rgba))?.rows().unwrap().len(), 5);Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Whether there are no rows, as before an incremental decoding has decoded any.
§Examples
use webp::api::decode::{decode, ColorMode, Config};
assert!(!decode(&file, &Config::new(ColorMode::Rgba))?.rows().unwrap().is_empty());Sourcepub fn row(&self, index: u32) -> Option<&'s [u8]>
pub fn row(&self, index: u32) -> Option<&'s [u8]>
Row index, row_len bytes from the first row plus index strides,
or None for an index at or past Rows::len.
§Examples
use webp::api::decode::{decode, ColorMode, Config};
let image = decode(&file, &Config::new(ColorMode::Rgb))?;
let rows = image.rows().unwrap();
assert_eq!(rows.row(1), Some(&[1_u8, 2, 3][..]));
assert_eq!(rows.row(2), None);Sourcepub fn iter(&self) -> impl Iterator<Item = &'s [u8]> + 's
pub fn iter(&self) -> impl Iterator<Item = &'s [u8]> + 's
The rows in order: row 0, then row 1, and so on.
§Examples
use webp::api::decode::{decode, ColorMode, Config};
let image = decode(&file, &Config::new(ColorMode::Rgba))?;
assert!(image.rows().unwrap().iter().all(|row| row == [9_u8; 8]));Sourcepub const fn row_len(&self) -> usize
pub const fn row_len(&self) -> usize
The bytes of a row: the width times the bytes per pixel, or the width of a plane.
§Examples
use webp::api::decode::{decode, ColorMode, Config};
assert_eq!(decode(&file, &Config::new(ColorMode::Rgb565))?.rows().unwrap().row_len(), 10);Sourcepub const fn stride(&self) -> isize
pub const fn stride(&self) -> isize
The distance from a row to the next, in bytes; negative while a flipped incremental decoding runs, whose row 0 is then the bottom row of the output.
§Examples
use webp::api::decode::{decode, ColorMode, Config};
assert_eq!(decode(&file, &Config::new(ColorMode::Argb))?.rows().unwrap().stride(), 12);Trait Implementations§
Auto Trait Implementations§
impl<'s> Forget for Rows<'s>
impl<'s> Freeze for Rows<'s>
impl<'s> Move for Rows<'s>
impl<'s> RefUnwindSafe for Rows<'s>
impl<'s> Send for Rows<'s>
impl<'s> Sync for Rows<'s>
impl<'s> Unpin for Rows<'s>
impl<'s> UnsafeUnpin for Rows<'s>
impl<'s> UnwindSafe for Rows<'s>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more