Skip to main content

Rows

Struct Rows 

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

Source

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);
Source

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());
Source

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);
Source

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]));
Source

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);
Source

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§

Source§

impl<'s> Clone for Rows<'s>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'s> Copy for Rows<'s>

Source§

impl Debug for Rows<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.