Trait rgb::AsPixels

source ·
pub trait AsPixels<PixelType> {
    // Required methods
    fn as_pixels(&self) -> &[PixelType];
    fn as_pixels_mut(&mut self) -> &mut [PixelType];
}
Expand description

Casts a slice of bytes into a slice of pixels, e.g. [u8] to [RGB8].

See also FromSlice

Required Methods§

source

fn as_pixels(&self) -> &[PixelType]

Reinterpret the slice as a read-only/shared slice of pixels. Multiple consecutive elements in the slice are intepreted as a single pixel (depending on format, e.g. 3 for RGB, 4 for RGBA).

Leftover elements are ignored if the slice isn’t evenly divisible into pixels.

Use this method only when the type is known from context. See also FromSlice.

source

fn as_pixels_mut(&mut self) -> &mut [PixelType]

Reinterpret the slice as a mutable/exclusive slice of pixels. Multiple consecutive elements in the slice are intepreted as a single pixel (depending on format, e.g. 3 for RGB, 4 for RGBA).

Leftover elements are ignored if the slice isn’t evenly divisible into pixels.

Use this method only when the type is known from context. See also FromSlice.

Implementations on Foreign Types§

source§

impl<T> AsPixels<RGB<T>> for [T]

source§

fn as_pixels(&self) -> &[RGB<T>]

source§

fn as_pixels_mut(&mut self) -> &mut [RGB<T>]

source§

impl<T> AsPixels<BGRA<T, T>> for [T]

source§

fn as_pixels(&self) -> &[BGRA<T>]

source§

fn as_pixels_mut(&mut self) -> &mut [BGRA<T>]

source§

impl<T> AsPixels<BGR<T>> for [T]

source§

fn as_pixels(&self) -> &[BGR<T>]

source§

fn as_pixels_mut(&mut self) -> &mut [BGR<T>]

source§

impl<T> AsPixels<GrayAlpha<T, T>> for [T]

source§

fn as_pixels(&self) -> &[GrayAlpha<T>]

source§

fn as_pixels_mut(&mut self) -> &mut [GrayAlpha<T>]

source§

impl<T> AsPixels<Gray<T>> for [T]

source§

fn as_pixels(&self) -> &[Gray<T>]

source§

fn as_pixels_mut(&mut self) -> &mut [Gray<T>]

source§

impl<T> AsPixels<RGBA<T, T>> for [T]

source§

fn as_pixels(&self) -> &[RGBA<T>]

source§

fn as_pixels_mut(&mut self) -> &mut [RGBA<T>]

Implementors§