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
.
§impl ImageBuf
impl ImageBuf
pub fn from_dynamic_image(image_data: DynamicImage) -> ImageBuf
pub fn from_dynamic_image(image_data: DynamicImage) -> ImageBuf
Load an image from a DynamicImage from the image crate
pub fn from_dynamic_image_with_alpha(image_data: DynamicImage) -> ImageBuf
pub fn from_dynamic_image_with_alpha(image_data: DynamicImage) -> ImageBuf
Load an image from a DynamicImage with alpha
pub fn from_dynamic_image_without_alpha(image_data: DynamicImage) -> ImageBuf
pub fn from_dynamic_image_without_alpha(image_data: DynamicImage) -> ImageBuf
Load an image from a DynamicImage without alpha