INNER CODE UNIT · Rust

cropped

autopilot-rs/autopy · src/bitmap.rs:321

    fn cropped(&mut self, rect: ((f64, f64), (f64, f64))) -> PyResult<Py<Bitmap>> {
        let rect = Rect::new(
            Point::new((rect.0).0, (rect.0).1),
            Size::new((rect.1).0, (rect.1).1),
        );
        let bmp = self.bitmap.cropped(rect).map_err(FromImageError::from)?;
        Python::attach(|py| {
            let result = Py::new(py, Bitmap { bitmap: bmp })?;
            Ok(result)
        })
    }

    /// Returns true if bitmap is equal to receiver with the given tolerance.
    #[pyo3(signature = (bitmap, tolerance=None))]
    pub fn is_bitmap_equal(&self, bitmap: &Bitmap, tolerance: Option<f64>) -> PyResult<bool> {
        Ok(self.bitmap.bitmap_eq(&bitmap.bitmap, tolerance))
    }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…