Crate screen_shot

Crate screen_shot 

Source
Expand description

§screen-shot-rs

Crates.io Downloads Docs.rs License Issues Rust Edition Unsafe Maintenance

Get a bitmap image of any display in Rust. This crate is hosted on crates.io.

Note: This crate is a fork of alexchandel/screenshot-rs.

Contributions welcome!

§Examples

use screen_shot::get_screenshot;

{
	let s = get_screenshot(0).unwrap();

	println!("{} x {}", s.width(), s.height());

	// ::image::save_buffer(&Path::new("test.png"),
	// 	s.as_slice(), s.width() as u32, s.height() as u32, image::RGBA(8))
	// .unwrap();
}

§Development

§Known Issues

  • get_screenshot leaks memory on certain error conditions, by returning before releasing OS handles. PR’s welcome.
  • The BMP Image in the example is rotated +90 degrees because I don’t adjust for BMP idiosyncrasy.
  • The PNG Image in the example has its R & B channels exchanged because PistonDevelopers/image doesn’t support ARGB pixels. Capture a bitmap image of a display. The resulting screenshot is stored in the Screenshot type, which varies per platform.

§Platform-specific details

Despite OS X’s CoreGraphics documentation, the bitmap returned has its origin at the top left corner. It uses ARGB pixels.

The Windows GDI bitmap has its coordinate origin at the bottom left. We attempt to undo this by reordering the rows. Windows also uses ARGB pixels.

Structs§

Pixel
Screenshot
An image buffer containing the screenshot. Pixels are stored as ARGB.

Functions§

get_screenshot

Type Aliases§

ScreenResult