pub struct ImageBuf { /* private fields */ }
Expand description
An in-memory pixel buffer.
Contains raw bytes, dimensions, and image format (ImageFormat
).
Implementations§
§impl ImageBuf
impl ImageBuf
pub fn from_raw(
pixels: impl Into<Arc<[u8]>>,
format: ImageFormat,
width: usize,
height: usize
) -> ImageBuf
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] ⓘ
pub fn raw_pixels(&self) -> &[u8] ⓘ
Returns the raw pixel data of this image buffer.
Returns a shared reference to the raw pixel data of this image buffer.
pub fn format(&self) -> ImageFormat
pub fn format(&self) -> ImageFormat
Returns the format of the raw pixel data.
pub fn pixel_colors(&self) -> impl Iterator<Item = impl Iterator<Item = Color>>
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>::Imagewhere
Ctx: RenderContext,
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
.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for ImageBuf
impl Send for ImageBuf
impl Sync for ImageBuf
impl Unpin for ImageBuf
impl UnwindSafe for ImageBuf
Blanket Implementations§
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> RoundFrom<T> for T
impl<T> RoundFrom<T> for T
§fn round_from(x: T) -> T
fn round_from(x: T) -> T
Performs the conversion.
§impl<T, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
impl<T, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
§fn round_into(self) -> U
fn round_into(self) -> U
Performs the conversion.