Created
July 4, 2025 23:02
-
-
Save philopaterwaheed/75ad90c042d3c5311f2bc1026fb1e1e7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use image::{ImageBuffer, Rgb}; | |
| fn main() -> Result<(), Box<dyn std::error::Error>> { | |
| // Create a simple test image | |
| let width = 200_u32; | |
| let height = 150_u32; | |
| // Create a blue image | |
| let img1: ImageBuffer<Rgb<u8>, Vec<u8>> = ImageBuffer::from_fn(width, height, |_x, _y| { | |
| Rgb([0u8, 100u8, 255u8]) | |
| }); | |
| img1.save("test_images/test_blue.png")?; | |
| // Create a gradient image | |
| let img2: ImageBuffer<Rgb<u8>, Vec<u8>> = ImageBuffer::from_fn(width, height, |x, y| { | |
| let red = (255.0 * x as f32 / width as f32) as u8; | |
| let green = (255.0 * y as f32 / height as f32) as u8; | |
| Rgb([red, green, 128u8]) | |
| }); | |
| img2.save("test_images/test_gradient.png")?; | |
| println!("Test images created successfully!"); | |
| Ok(()) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment