#![warn(missing_docs)]
extern crate framing;
extern crate scrap;
pub use scrap::Display;
use framing::{Chunky, Bgra};
use std::io;
pub struct Capturer {
capturer: scrap::Capturer
}
impl Capturer {
pub fn new(display: Display) -> io::Result<Self> {
let capturer = scrap::Capturer::new(display)?;
Ok(Capturer { capturer })
}
pub fn width(&self) -> usize { self.capturer.width() }
pub fn height(&self) -> usize { self.capturer.height() }
pub fn frame(&mut self) -> io::Result<Chunky<Bgra, Screenshot>> {
Ok(Chunky::from_bytes(
self.capturer.width(),
self.capturer.height(),
Screenshot { frame: self.capturer.frame()? }
))
}
}
pub struct Screenshot<'a> {
frame: scrap::Frame<'a>
}
impl<'a> AsRef<[u8]> for Screenshot<'a> {
fn as_ref(&self) -> &[u8] {
self.frame.as_ref()
}
}
unsafe impl<'a> Sync for Screenshot<'a> {}
unsafe impl<'a> Send for Screenshot<'a> {}