Clean up test code
parent
0f5e4c7258
commit
2ff6b35af1
30
src/main.rs
30
src/main.rs
|
@ -11,6 +11,25 @@ use memmap::Mmap;
|
||||||
|
|
||||||
use marathon::wad;
|
use marathon::wad;
|
||||||
use durandal::pict::load_pict;
|
use durandal::pict::load_pict;
|
||||||
|
use durandal::image::Image;
|
||||||
|
|
||||||
|
fn write_ppm(fname: &str, im: &Image) -> io::Result<()>
|
||||||
|
{
|
||||||
|
let out = fs::File::create(fname)?;
|
||||||
|
let mut out = io::BufWriter::new(out);
|
||||||
|
|
||||||
|
write!(&mut out, "P3\n{} {}\n255\n", im.w(), im.h())?;
|
||||||
|
|
||||||
|
for y in 0..im.h() {
|
||||||
|
for x in 0..im.w()
|
||||||
|
{
|
||||||
|
let cr = &im[(x, y)];
|
||||||
|
write!(&mut out, "{} {} {} ", cr.r, cr.g, cr.b)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn main() -> io::Result<()>
|
fn main() -> io::Result<()>
|
||||||
{
|
{
|
||||||
|
@ -28,17 +47,8 @@ fn main() -> io::Result<()>
|
||||||
let im = load_pict(c);
|
let im = load_pict(c);
|
||||||
match im {
|
match im {
|
||||||
Ok(im) => {
|
Ok(im) => {
|
||||||
let out = fs::File::create(format!("out_{}.ppm", id))?;
|
|
||||||
let mut out = io::BufWriter::new(out);
|
|
||||||
println!("entry {} has PICT {}x{}", id, im.w(), im.h());
|
println!("entry {} has PICT {}x{}", id, im.w(), im.h());
|
||||||
write!(&mut out, "P3\n{} {}\n255\n", im.w(), im.h())?;
|
write_ppm(&format!("out_{}.ppm", id), &im)?;
|
||||||
for y in 0..im.h() {
|
|
||||||
for x in 0..im.w()
|
|
||||||
{
|
|
||||||
let cr = &im[(x, y)];
|
|
||||||
write!(&mut out, "{} {} {} ", cr.r, cr.g, cr.b)?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
Err(e) => println!("entry {} has PICT (invalid: {:?})", id, e),
|
Err(e) => println!("entry {} has PICT (invalid: {:?})", id, e),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue