use crate::{ containers::{wrap_get_set_fill_2d, wrap_width_height}, macros::wrap_object, }; use servicepoint::Grid; use std::{ops::Deref, sync::Arc}; wrap_object!(Bitmap); wrap_width_height!(Bitmap); wrap_get_set_fill_2d!(Bitmap, bool); #[uniffi::export] impl Bitmap { #[uniffi::constructor] pub fn new(width: u64, height: u64) -> Arc { Self::internal_new( servicepoint::Bitmap::new(width as usize, height as usize).unwrap(), ) } #[uniffi::constructor] pub fn new_max_sized() -> Arc { Self::internal_new(servicepoint::Bitmap::max_sized()) } #[uniffi::constructor] pub fn load(width: u64, height: u64, data: Vec) -> Arc { // TODO: throw exception Self::internal_new( servicepoint::Bitmap::load(width as usize, height as usize, &data) .unwrap(), ) } pub fn copy_raw(&self) -> Vec { self.read().deref().into() } }