move containers to module
This commit is contained in:
parent
4cbf3784fc
commit
227db03d23
8 changed files with 35 additions and 37 deletions
40
src/containers/bitmap.rs
Normal file
40
src/containers/bitmap.rs
Normal file
|
@ -0,0 +1,40 @@
|
|||
use crate::macros::*;
|
||||
use servicepoint::Grid;
|
||||
use std::{ops::Deref, sync::Arc};
|
||||
|
||||
wrap_uniffi_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> {
|
||||
Self::internal_new(
|
||||
servicepoint::Bitmap::new(width as usize, height as usize).unwrap(),
|
||||
)
|
||||
}
|
||||
|
||||
#[uniffi::constructor]
|
||||
pub fn new_max_sized() -> Arc<Self> {
|
||||
Self::internal_new(servicepoint::Bitmap::max_sized())
|
||||
}
|
||||
|
||||
#[uniffi::constructor]
|
||||
pub fn load(width: u64, height: u64, data: Vec<u8>) -> Arc<Self> {
|
||||
Self::internal_new(
|
||||
servicepoint::Bitmap::load(width as usize, height as usize, &data)
|
||||
.unwrap(),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn equals(&self, other: &Bitmap) -> bool {
|
||||
let a = self.actual.read().unwrap();
|
||||
let b = other.actual.read().unwrap();
|
||||
*a == *b
|
||||
}
|
||||
|
||||
pub fn copy_raw(&self) -> Vec<u8> {
|
||||
self.actual.read().unwrap().deref().into()
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue