| 1 | fn main() { |
| 2 | let args: Vec<String> = std::env::args().collect(); |
| 3 | if args.len() != 3 { |
| 4 | eprintln!("usage: dump_dds <in.dds> <out.png>"); |
| 5 | std::process::exit(1); |
| 6 | } |
| 7 | let bytes = std::fs::read(&args[1]).expect("read"); |
| 8 | let dds = image_dds::ddsfile::Dds::read(&bytes[..]).expect("parse dds"); |
| 9 | let img = image_dds::image_from_dds(&dds, 0).expect("decode"); |
| 10 | img.save(&args[2]).expect("save png"); |
| 11 | // Also print a few pixel values so we can see if they're grey |
| 12 | let (w, h) = (img.width(), img.height()); |
| 13 | let samples = [(w/4, h/4), (w/2, h/2), (3*w/4, 3*h/4)]; |
| 14 | for (x, y) in samples { |
| 15 | let p = img.get_pixel(x, y); |
| 16 | println!("pixel ({}, {}): {:?}", x, y, p); |
| 17 | } |
| 18 | } |