feat: take screenshot (#11591)

* feat: take screenshot

Signed-off-by: fufesou <linlong1266@gmail.com>

* screenshot, vram temp switch capturer

Signed-off-by: fufesou <linlong1266@gmail.com>

* fix: misspelling

Signed-off-by: fufesou <linlong1266@gmail.com>

* screenshot, taking

Signed-off-by: fufesou <linlong1266@gmail.com>

* screenshot, rgba stride

Signed-off-by: fufesou <linlong1266@gmail.com>

* Bumps 1.4.0

Signed-off-by: fufesou <linlong1266@gmail.com>

---------

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou
2025-04-30 17:23:35 +08:00
committed by GitHub
parent 2864e1984a
commit c626c2414d
82 changed files with 948 additions and 96 deletions

View File

@@ -197,3 +197,40 @@ pub fn convert_to_yuv(
}
Ok(())
}
#[cfg(not(target_os = "ios"))]
pub fn convert(captured: &PixelBuffer, pixfmt: crate::Pixfmt, dst: &mut Vec<u8>) -> ResultType<()> {
if captured.pixfmt() == pixfmt {
dst.extend_from_slice(captured.data());
return Ok(());
}
let src = captured.data();
let src_stride = captured.stride();
let src_pixfmt = captured.pixfmt();
let src_width = captured.width();
let src_height = captured.height();
let unsupported = format!(
"unsupported pixfmt conversion: {src_pixfmt:?} -> {:?}",
pixfmt
);
match (src_pixfmt, pixfmt) {
(crate::Pixfmt::BGRA, crate::Pixfmt::RGBA) | (crate::Pixfmt::RGBA, crate::Pixfmt::BGRA) => {
dst.resize(src.len(), 0);
call_yuv!(ABGRToARGB(
src.as_ptr(),
src_stride[0] as _,
dst.as_mut_ptr(),
src_stride[0] as _,
src_width as _,
src_height as _,
));
}
_ => {
bail!(unsupported);
}
}
Ok(())
}

View File

@@ -63,6 +63,7 @@ pub enum ImageFormat {
}
#[repr(C)]
#[derive(Clone)]
pub struct ImageRgb {
pub raw: Vec<u8>,
pub w: usize,