INNER CODE UNIT · Rust
open
autopilot-rs/autopy · src/bitmap.rs:144
fn open(cls: &Bound<'_, PyType>, path: String) -> PyResult<Py<Bitmap>> {
let image = image::open(path).map_err(FromImageError::from)?;
let bmp = autopilot::bitmap::Bitmap::new(image, None);
let result = Py::new(cls.py(), Bitmap { bitmap: bmp })?;
Ok(result)
}
/// Returns hexadecimal value describing the color at a given point.
///
/// Exceptions:
/// - `ValueError` is thrown if the point out of bounds.
fn get_color(&self, x: f64, y: f64) -> PyResult<u32> {
let point = Point::new(x, y);
if !self.bitmap.bounds().is_point_visible(point) {
Err(pyo3::exceptions::PyValueError::new_err(format!(
"Point out of bounds {}",
point
)))