PixelBuffer

Trait PixelBuffer 

Source
pub trait PixelBuffer<'a> {
    type Pixel: Copy;

    // Required methods
    fn from_line(line_buffer: &'a mut [u8]) -> Self;
    fn put_pixel(&mut self, pixel: Self::Pixel);

    // Provided methods
    fn put_pixels(&mut self, pixel: Self::Pixel, count: usize) { ... }
    fn pixel_stride() -> usize { ... }
}
Expand description

A trait for providing a way for placing pixels into byte buffers.

Required Associated Types§

Source

type Pixel: Copy

Specifies the type used for pixels.

Required Methods§

Source

fn from_line(line_buffer: &'a mut [u8]) -> Self

Should return a new instance of PixelBuffer implementation from the mutable slice of bytes representing a single line of pixels of the target buffer.

Source

fn put_pixel(&mut self, pixel: Self::Pixel)

Puts the next pixel into the line buffer and increases an internal cursor position by a single pixel.

If the internal buffer boundaries would be overflown, this method must not panic, but instead, it should just return without writing anything to the underlying buffer.

Provided Methods§

Source

fn put_pixels(&mut self, pixel: Self::Pixel, count: usize)

Puts count number of pixel copies into the line buffer and increases an internal cursor position accordingly.

If the internal buffer boundaries would be overflown, this method must not panic, but instead, it should just return without writing anything to the underlying buffer.

Source

fn pixel_stride() -> usize

Returns the stride of a single pixel in bytes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a> PixelBuffer<'a> for PixelBufA24<'a>

Source§

type Pixel = [u8; 3]

Source§

impl<'a> PixelBuffer<'a> for PixelBufA32<'a>

Source§

type Pixel = [u8; 4]

Source§

impl<'a> PixelBuffer<'a> for PixelBufP8<'a>

Source§

impl<'a> PixelBuffer<'a> for PixelBufP16<'a>

Source§

impl<'a> PixelBuffer<'a> for PixelBufP32<'a>