summaryrefslogtreecommitdiff
path: root/packer/src/bin
diff options
context:
space:
mode:
Diffstat (limited to 'packer/src/bin')
-rw-r--r--packer/src/bin/benchmark.rs26
-rw-r--r--packer/src/bin/res/bunny.ffbin0 -> 8208 bytes
-rw-r--r--packer/src/bin/res/bunny.pngbin0 -> 438 bytes
-rw-r--r--packer/src/bin/res/gator.bmpbin0 -> 750054 bytes
-rw-r--r--packer/src/bin/res/gator.ffbin0 -> 2000016 bytes
-rw-r--r--packer/src/bin/res/ghost.icobin0 -> 67646 bytes
6 files changed, 26 insertions, 0 deletions
diff --git a/packer/src/bin/benchmark.rs b/packer/src/bin/benchmark.rs
new file mode 100644
index 0000000..bb83992
--- /dev/null
+++ b/packer/src/bin/benchmark.rs
@@ -0,0 +1,26 @@
+use std::{fs::File, sync::Arc, time::Instant};
+
+use image::{io::Reader as ImageReader, ImageOutputFormat};
+use packer::RectanglePacker;
+
+fn main() -> Result<(), exun::RawUnexpected> {
+ let img1 = ImageReader::open("src/bin/res/gator.bmp")?.decode()?;
+ let img2 = ImageReader::open("src/bin/res/bunny.ff")?.decode()?;
+ let img3 = ImageReader::open("src/bin/res/ghost.ico")?.decode()?;
+
+ let start = Instant::now();
+ let mut packer = RectanglePacker::new();
+ packer.add_texture("gator".into(), Arc::new(img1.to_rgb8()));
+ packer.add_texture("bunny".into(), Arc::new(img2.to_rgb8()));
+ packer.add_texture("ghost".into(), Arc::new(img3.to_rgb8()));
+ println!("{} milliseconds", start.elapsed().as_secs_f32() * 1000.0);
+
+ let start = Instant::now();
+ let packed = packer.output();
+ println!("{} milliseconds", start.elapsed().as_secs_f32() * 1000.0);
+
+ let mut file = File::create("packed.png")?;
+ packed?.0.write_to(&mut file, ImageOutputFormat::Bmp)?;
+
+ Ok(())
+}
diff --git a/packer/src/bin/res/bunny.ff b/packer/src/bin/res/bunny.ff
new file mode 100644
index 0000000..64c5a69
--- /dev/null
+++ b/packer/src/bin/res/bunny.ff
Binary files differ
diff --git a/packer/src/bin/res/bunny.png b/packer/src/bin/res/bunny.png
new file mode 100644
index 0000000..87ba72d
--- /dev/null
+++ b/packer/src/bin/res/bunny.png
Binary files differ
diff --git a/packer/src/bin/res/gator.bmp b/packer/src/bin/res/gator.bmp
new file mode 100644
index 0000000..e752b56
--- /dev/null
+++ b/packer/src/bin/res/gator.bmp
Binary files differ
diff --git a/packer/src/bin/res/gator.ff b/packer/src/bin/res/gator.ff
new file mode 100644
index 0000000..aac1bcb
--- /dev/null
+++ b/packer/src/bin/res/gator.ff
Binary files differ
diff --git a/packer/src/bin/res/ghost.ico b/packer/src/bin/res/ghost.ico
new file mode 100644
index 0000000..102de00
--- /dev/null
+++ b/packer/src/bin/res/ghost.ico
Binary files differ