Struct piet_common::ImageBuf

source ·
pub struct ImageBuf { /* private fields */ }
Expand description

An in-memory pixel buffer.

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

Implementations§

source§

impl ImageBuf

source

pub fn empty() -> ImageBuf

Create an empty image buffer.

source

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.

source

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

Returns the raw pixel data of this image buffer.

source

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

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

source

pub fn format(&self) -> ImageFormat

Returns the format of the raw pixel data.

source

pub fn width(&self) -> usize

The width, in pixels, of this image.

source

pub fn height(&self) -> usize

The height, in pixels, of this image.

source

pub fn size(&self) -> Size

The size of this image, in pixels.

source

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.

source

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

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

source

pub fn ptr_eq(&self, other: &ImageBuf) -> bool

Returns true if the two ImageBufs refer to the same memory location.

Trait Implementations§

source§

impl Clone for ImageBuf

source§

fn clone(&self) -> ImageBuf

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for ImageBuf

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for ImageBuf

source§

fn default() -> ImageBuf

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> RoundFrom<T> for T

source§

fn round_from(x: T) -> T

Performs the conversion.
source§

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

source§

fn round_into(self) -> U

Performs the conversion.
source§

impl<T> ToOwned for Twhere
    T: Clone,

§

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 Twhere
    U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.