mod app; mod bitmap; mod command; mod consts; mod dither; mod symmetry; mod undo; mod utils; use app::AppState; use std::{ env, fs::OpenOptions, io::{Cursor, Read}, }; use obi::Image; pub fn main() { let sdl_context = sdl2::init().unwrap(); let ttf_context = sdl2::ttf::init().unwrap(); let args: Vec<_> = env::args().collect(); if args.len() < 2 { AppState::init(200, 200, &sdl_context, &ttf_context, None).run(); return; } else { let path = args.get(1).unwrap(); let image_src = OpenOptions::new() .read(true) .write(false) .create(false) .open(path); if let Ok(mut image) = image_src { let mut buf = Vec::new(); image.read_to_end(&mut buf).unwrap(); let decoded = Image::decode(&mut (Cursor::new(buf))).unwrap(); let (width, height) = (decoded.width(), decoded.height()); AppState::init( width, height, &sdl_context, &ttf_context, Some(decoded.data), ) .run(); } } }