nashaofu / xcap

XCap is a cross-platform screen capture library written in Rust. It supports Linux (X11, Wayland), MacOS, and Windows. XCap supports screenshot and video recording (to be implemented).

Home Page:https://docs.rs/xcap

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature: add capturing into raw BGR buffer

konstantinzolotarev opened this issue · comments

First of all,, thank you very much for a great work.

Is it possible to add ability to make screenshots into raw buffer rather than Result<ImageRgba> ?

it's very useful for work with opencv, but right now your lib does conversion from bgr into rgba and then to work properly with images in opencv code have to do backward conversion from rgba into bgr.

Just a side note. Result might be something like

pub struct RawImage {
    pub width: u32,
    pub height: u32,
    pub data: Vec<u8>, // even BGRA works very well in here. 
}

Then it's very easy to convert it into opencv::Mat

unsafe {
        Mat::new_rows_cols_with_data(
            image.height as i32,
            image.width as i32,
            core::CV_8UC4,
            image.data.as_mut_ptr().cast::<c_void>(),
            core::Mat_AUTO_STEP,
        )
        .unwrap()
    }