use super::*;
mod to_complete;
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub struct GridCornerRMXP {
image: RgbaImage,
}
impl GridAtlas for GridCornerRMXP {
unsafe fn new(image: RgbaImage) -> Self {
Self { image }
}
fn create(image: &RgbaImage, (x, y): (u32, u32), (w, h): (u32, u32)) -> ImageResult<Self> {
let (image_w, image_h) = image.dimensions();
if x + w * 6 > image_w || y + h * 8 > image_h {
io_error("The image size has out of range", ErrorKind::InvalidInput)?;
}
let view = image.view(x, y, w * 6, h * 8);
unsafe { Ok(Self::new(view.to_image())) }
}
fn get_cell_size(&self) -> (u32, u32) {
(self.image.width() / 6, self.image.height() / 8)
}
fn get_image(&self) -> &RgbaImage {
&self.image
}
fn get_by_mask(&self, _: u8) -> RgbaImage {
todo!()
}
fn load<P>(path: P) -> ImageResult<Self>
where
P: AsRef<Path>,
{
let image = image::open(path)?.to_rgba8();
check_image_multiple(&image, 6, 8)?;
Ok(Self { image })
}
}