linux x11 rgb565 capture (#8580)

Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
21pages
2024-07-03 14:20:41 +08:00
committed by GitHub
parent 6d2e985593
commit d00582e929
7 changed files with 165 additions and 45 deletions

View File

@@ -59,6 +59,7 @@ pub enum ImageFormat {
ABGR,
ARGB,
}
#[repr(C)]
pub struct ImageRgb {
pub raw: Vec<u8>,
@@ -208,11 +209,27 @@ impl<'a> EncodeInput<'a> {
pub enum Pixfmt {
BGRA,
RGBA,
RGB565LE,
I420,
NV12,
I444,
}
impl Pixfmt {
pub fn bpp(&self) -> usize {
match self {
Pixfmt::BGRA | Pixfmt::RGBA => 32,
Pixfmt::RGB565LE => 16,
Pixfmt::I420 | Pixfmt::NV12 => 12,
Pixfmt::I444 => 24,
}
}
pub fn bytes_per_pixel(&self) -> usize {
(self.bpp() + 7) / 8
}
}
#[derive(Debug, Clone)]
pub struct EncodeYuvFormat {
pub pixfmt: Pixfmt,