37 lines
960 B
Rust
37 lines
960 B
Rust
use crate::{
|
|
containers::{wrap_get_set_fill_2d, wrap_width_height},
|
|
macros::wrap_object,
|
|
};
|
|
use servicepoint::{Brightness, Grid};
|
|
use std::{ops::Deref, sync::Arc};
|
|
|
|
wrap_object!(BrightnessGrid);
|
|
wrap_width_height!(BrightnessGrid);
|
|
wrap_get_set_fill_2d!(BrightnessGrid, Brightness);
|
|
|
|
#[uniffi::export]
|
|
impl BrightnessGrid {
|
|
#[uniffi::constructor]
|
|
pub fn new(width: u64, height: u64) -> Arc<Self> {
|
|
Self::internal_new(servicepoint::BrightnessGrid::new(
|
|
width as usize,
|
|
height as usize,
|
|
))
|
|
}
|
|
|
|
#[uniffi::constructor]
|
|
pub fn load(width: u64, height: u64, data: Vec<u8>) -> Arc<Self> {
|
|
Self::internal_new(
|
|
servicepoint::BrightnessGrid::saturating_load(
|
|
width as usize,
|
|
height as usize,
|
|
&data,
|
|
)
|
|
.unwrap(),
|
|
)
|
|
}
|
|
|
|
pub fn copy_raw(&self) -> Vec<u8> {
|
|
self.read().deref().into()
|
|
}
|
|
}
|