[−]Struct druid::ImageBuf
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
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,
Ctx: RenderContext,
Converts this buffer an image that is optimized for drawing into a RenderContext
.
Trait Implementations
impl Clone for ImageBuf
pub fn clone(&self) -> ImageBuf
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for ImageBuf
impl Default for ImageBuf
Auto Trait Implementations
impl RefUnwindSafe for ImageBuf
[src]
impl Send for ImageBuf
[src]
impl Sync for ImageBuf
[src]
impl Unpin for ImageBuf
[src]
impl UnwindSafe for ImageBuf
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> RoundFrom<T> for T
pub fn round_from(x: T) -> T
impl<T, U> RoundInto<U> for T where
U: RoundFrom<T>,
U: RoundFrom<T>,
pub fn round_into(self) -> U
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,