pub struct Pixmap { /* private fields */ }Expand description
A CPU pixel buffer in straight (non-premultiplied) RGBA8, row-major,
tightly packed (stride == width * 4).
This is the payload handed to a Surface for display. It is what the
software backend produces today; a future GPU backend may bypass it.
Implementations§
Source§impl Pixmap
impl Pixmap
Sourcepub fn decode(bytes: &[u8]) -> Result<Pixmap, ImageError>
pub fn decode(bytes: &[u8]) -> Result<Pixmap, ImageError>
Decode an image file held in memory into a straight-alpha RGBA pixmap,
sniffing the format through the oxideav registry (see
image_formats for the formats). Animated formats yield their first
frame; images without alpha decode fully opaque.
assert_eq!(Pixmap::decode(b"not an image"), Err(ImageError::UnknownFormat));Sourcepub fn decode_with(
formats: &RuntimeContext,
bytes: &[u8],
) -> Result<Pixmap, ImageError>
pub fn decode_with( formats: &RuntimeContext, bytes: &[u8], ) -> Result<Pixmap, ImageError>
decode through a caller-built oxideav registry, for
formats beyond the built-in set.
Sourcepub fn from_oxideav_image(image: &Image) -> Result<Pixmap, ImageError>
pub fn from_oxideav_image(image: &Image) -> Result<Pixmap, ImageError>
Convert a decoded oxideav-image picture (any pixel layout the stack
converts from) to RGBA.
Sourcepub fn from_video_frame(
frame: &VideoFrame,
size: PhysicalSize,
format: PixelFormat,
) -> Result<Pixmap, ImageError>
pub fn from_video_frame( frame: &VideoFrame, size: PhysicalSize, format: PixelFormat, ) -> Result<Pixmap, ImageError>
Convert an oxideav VideoFrame of size pixels in format to an
RGBA pixmap. Packed RGBA is copied row by row (dropping any stride
padding); every other layout goes through oxideav’s pixel-format
conversion (YUV, RGB, gray, palettes, 16-bit, …).
Sourcepub fn to_video_frame(&self) -> VideoFrame
pub fn to_video_frame(&self) -> VideoFrame
This pixmap as a single-plane packed RGBA (PixelFormat::Rgba)
oxideav VideoFrame, for handing to the rest of the stack.
Source§impl Pixmap
impl Pixmap
Sourcepub fn new(size: PhysicalSize) -> Self
pub fn new(size: PhysicalSize) -> Self
Allocate a fully transparent pixmap of size.
Sourcepub fn from_rgba8(size: PhysicalSize, data: Vec<u8>) -> Self
pub fn from_rgba8(size: PhysicalSize, data: Vec<u8>) -> Self
Wrap existing RGBA8 bytes. Panics if data.len() != width*height*4.
pub fn size(&self) -> PhysicalSize
pub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
Sourcepub fn blit(&mut self, src: &Pixmap, dst_x: u32, dst_y: u32)
pub fn blit(&mut self, src: &Pixmap, dst_x: u32, dst_y: u32)
Copy src into this pixmap with its top-left at (dst_x, dst_y),
clipped to this pixmap’s bounds. A straight row-by-row replace (no alpha
blend) — used to composite an opaque area-repaint render (see
SoftwareRenderer::render_region) into the retained full-window buffer.