[]Struct druid::ImageBuf

pub struct ImageBuf { /* fields omitted */ }

An in-memory pixel buffer.

Contains raw bytes, dimensions, and image format (piet::ImageFormat).

Implementations

impl ImageBuf

pub fn empty() -> ImageBuf

Create an empty image buffer.

pub fn from_raw(
    pixels: impl Into<Arc<[u8]>>,
    format: ImageFormat,
    width: usize,
    height: usize
) -> ImageBuf

Creates a new image buffer from an array of bytes.

format specifies the pixel format of the pixel data, which must have length width * height * format.bytes_per_pixel().

Panics

Panics if the pixel data has the wrong length.

pub fn raw_pixels(&self) -> &[u8]

Returns the raw pixel data of this image buffer.

pub fn raw_pixels_shared(&self) -> Arc<[u8]>

Returns a shared reference to the raw pixel data of this image buffer.

pub fn format(&self) -> ImageFormat

Returns the format of the raw pixel data.

pub fn width(&self) -> usize

The width, in pixels, of this image.

pub fn height(&self) -> usize

The height, in pixels, of this image.

pub fn size(&self) -> Size

The size of this image, in pixels.

pub fn pixel_colors(&self) -> impl Iterator<Item = impl Iterator<Item = Color>>

Returns an iterator over the pixels in this image.

The return value is an iterator over "rows", where each "row" is an iterator over the color of the pixels in that row.

pub fn to_image<Ctx>(&self, ctx: &mut Ctx) -> <Ctx as RenderContext>::Image where
    Ctx: RenderContext

Converts this buffer an image that is optimized for drawing into a RenderContext.

Trait Implementations

impl Clone for ImageBuf

impl Debug for ImageBuf

impl Default for ImageBuf

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> RoundFrom<T> for T

impl<T, U> RoundInto<U> for T where
    U: RoundFrom<T>, 

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.