winc

Crates.iowinc
lib.rswinc
version0.3.0
sourcesrc
created_at2024-07-17 20:00:15.684262
updated_at2024-07-18 04:16:33.992208
descriptionWindows screen capture
homepage
repositoryhttps://github.com/TeamDman/winc
max_upload_size
id1306548
size42,529
(TeamDman)

documentation

README

winc - Windows Capture

A crate for windows screen capture.

Usage

See tests.rs for examples.

#[test]
fn region_screenshots() {
    let monitors = get_all_monitors().unwrap();
    let mut capturers = Vec::new();

    for monitor in monitors {
        let p0 = monitor.info.rect.top_left();
        let p1 = p0.translate(100, 100);
        let region = RECT::from_corners(p0, p1).translate(100, 100);
        let capturer = get_monitor_capturer(Rc::new(monitor), region);
        capturers.push(capturer);
    }
    std::fs::create_dir_all("target/capture").unwrap();

    let mut images = Vec::new();
    for capturer in capturers.iter() {
        // capture
        let capture = capturer.capture(&mut Metrics::None).unwrap();

        // save image
        let mon_name_good = capturer.monitor.info.name.replace(r"\\.\", "");
        let path = format!("target/capture/region-{}.png", mon_name_good);
        capture.save(path).unwrap();
        images.push(capture);
    }

    assert_no_transparency(&images);
}

Attributions

Some code from https://github.com/TeamDman/Cursor-Hero which used some code from https://github.com/nashaofu/screenshots-rs/ commit 999faac06f85bd93638c2a9cda6cbb25ad9f5c73

My understanding is that the licenses used in our projects are compatible. If something is wrong, please let me know!

The modifications aim to reduce redundant work for successive screen capture calls.

Might also be interesting:

Commit count: 0

cargo fmt