pub struct RgbaBuffer {
pub width: u32,
pub height: u32,
pub data: Vec<u8>,
}Expand description
RGBA pixel buffer returned by headless rendering.
Pixels are stored row-major, left-to-right, top-to-bottom. Each pixel occupies exactly 4 bytes in the order R, G, B, A.
Fields§
§width: u32Width in pixels.
height: u32Height in pixels.
data: Vec<u8>Raw pixel data: width * height * 4 bytes (R, G, B, A per pixel).
Implementations§
Source§impl RgbaBuffer
impl RgbaBuffer
Sourcepub fn has_content(&self) -> bool
pub fn has_content(&self) -> bool
Returns true if any byte in the pixel data is non-zero.
A buffer composed entirely of zero bytes represents a fully transparent (or un-rendered) frame. Any non-zero R, G, B, or A value means that at least one pixel carried visible or semi-transparent content.
Sourcepub fn save_png(&self, path: &Path) -> Result<(), SoftRenderError>
pub fn save_png(&self, path: &Path) -> Result<(), SoftRenderError>
Save this buffer as a PNG file at path.
Uses the png crate (pure Rust) — no C/C++ dependencies.
§Errors
Returns crate::SoftRenderError::Io if the file cannot be created or
written, and crate::SoftRenderError::Png if the PNG encoder fails.
Auto Trait Implementations§
impl Freeze for RgbaBuffer
impl RefUnwindSafe for RgbaBuffer
impl Send for RgbaBuffer
impl Sync for RgbaBuffer
impl Unpin for RgbaBuffer
impl UnsafeUnpin for RgbaBuffer
impl UnwindSafe for RgbaBuffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more