use crate::{jpeg, png, webp, EnhancedDynamicImageTrait};
use anyhow::Result;
use image::DynamicImage;
use versatiles_core::types::{Blob, TileFormat};
pub fn create_image_rgba() -> DynamicImage {
DynamicImage::from_fn_rgba8(256, 256, |x, y| [x as u8, (255 - x) as u8, y as u8, (255 - y) as u8])
}
pub fn create_image_rgb() -> DynamicImage {
DynamicImage::from_fn_rgb8(256, 256, |x, y| [x as u8, (255 - x) as u8, y as u8])
}
pub fn create_image_grey() -> DynamicImage {
DynamicImage::from_fn_l8(256, 256, |x, _y| x as u8)
}
pub fn create_image_greya() -> DynamicImage {
DynamicImage::from_fn_la8(256, 256, |x, y| [x as u8, y as u8])
}
pub fn image2blob(image: &DynamicImage, format: TileFormat) -> Result<Blob> {
use TileFormat::*;
match format {
AVIF => todo!(),
BIN => todo!(),
GEOJSON => todo!(),
JPG => jpeg::image2blob(image, None),
JSON => todo!(),
MVT => todo!(),
PNG => png::image2blob(image),
SVG => todo!(),
TOPOJSON => todo!(),
WEBP => webp::image2blob(image, None),
}
}