1pub mod args;
2pub mod palette;
3pub mod resize;
4
5#[derive(Debug, PartialEq, clap::ValueEnum, Clone)]
6pub enum RatioMode {
7 Maintain,
8 Stretch,
9 Crop,
10}
11
12#[cfg(test)]
13pub mod test_utils {
14 use image::{ImageBuffer, Rgb};
15 use std::fs::File;
16 use std::{io, io::Write, path::PathBuf};
17
18 pub fn create_test_image(width: u32, height: u32) -> image::RgbImage {
20 let mut img = ImageBuffer::new(width, height);
21 for (x, y, pixel) in img.enumerate_pixels_mut() {
22 let r = (x * 255 / (width - 1)) as u8;
23 let g = (y * 255 / (height - 1)) as u8;
24 let b = ((x + y) * 255 / (width + height - 2)) as u8;
25 *pixel = Rgb([r, g, b]);
26 }
27 img
28 }
29
30 pub fn create_test_act_file(path: &PathBuf) -> Result<(), io::Error> {
32 let mut file = File::create(path)?;
33
34 let colors = [
36 [0, 0, 0], [255, 255, 255], [255, 0, 0], [0, 255, 0], [0, 0, 255], ];
42
43 let mut palette_data = Vec::new();
45
46 for color in &colors {
48 palette_data.push(color[0]); palette_data.push(color[1]); palette_data.push(color[2]); }
52
53 palette_data.extend(vec![0; 251 * 3]);
57
58 palette_data.push(0); palette_data.push(5); palette_data.push(0xFF);
64 palette_data.push(0xFF);
65
66 file.write_all(&palette_data)?;
68 Ok(())
69 }
70}