pub struct Screenshot { /* private fields */ }Expand description
A captured screenshot backed by raw RGBA8 pixel data.
Pixels are stored in row-major order; each pixel is four consecutive bytes
[R, G, B, A] with values in 0..=255.
Implementations§
Source§impl Screenshot
impl Screenshot
Sourcepub fn from_rgb(width: u32, height: u32, data: &[u8]) -> Screenshot
pub fn from_rgb(width: u32, height: u32, data: &[u8]) -> Screenshot
Create a screenshot from raw RGB8 pixel data, promoting to RGBA8
with full opacity (alpha = 255).
§Panics
Panics if data.len() != width * height * 3.
Sourcepub fn into_data(self) -> Vec<u8> ⓘ
pub fn into_data(self) -> Vec<u8> ⓘ
Consume the screenshot and return the underlying RGBA8 pixel buffer.
Sourcepub fn encode_png(&self) -> Result<Vec<u8>, EncodeError>
pub fn encode_png(&self) -> Result<Vec<u8>, EncodeError>
Encode the screenshot as a PNG image.
Sourcepub fn encode_ppm(&self) -> Vec<u8> ⓘ
pub fn encode_ppm(&self) -> Vec<u8> ⓘ
Encode the screenshot as a PPM (Portable Pixmap, P6 binary) image.
The alpha channel is discarded; only RGB values are written.
Sourcepub fn encode_pgm(&self) -> Vec<u8> ⓘ
pub fn encode_pgm(&self) -> Vec<u8> ⓘ
Encode the screenshot as a PGM (Portable Graymap, P5 binary) image.
Each pixel is converted to grayscale using the ITU-R BT.601 luminance
coefficients: Y = 0.299·R + 0.587·G + 0.114·B.
Sourcepub fn encode(&self, format: ImageFormat) -> Result<Vec<u8>, EncodeError>
pub fn encode(&self, format: ImageFormat) -> Result<Vec<u8>, EncodeError>
Encode the screenshot in the given ImageFormat.
Trait Implementations§
Source§impl Clone for Screenshot
impl Clone for Screenshot
Source§fn clone(&self) -> Screenshot
fn clone(&self) -> Screenshot
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more