diff options
-rw-r--r-- | gifed/examples/streaming_write.rs | 39 | ||||
-rw-r--r-- | gifed/examples/write.rs | 35 |
2 files changed, 0 insertions, 74 deletions
diff --git a/gifed/examples/streaming_write.rs b/gifed/examples/streaming_write.rs deleted file mode 100644 index c86f933..0000000 --- a/gifed/examples/streaming_write.rs +++ /dev/null @@ -1,39 +0,0 @@ -use std::fs::File; - -use gifed::{ - block::{LoopCount, Palette}, - writer::{ImageBuilder, Writer}, - Color, EncodeError, -}; - -fn main() -> Result<(), EncodeError> { - let gif_path = match std::env::args().nth(1) { - None => { - eprintln!("Expected a path to output the gif to"); - std::process::exit(-1); - } - Some(path) => path, - }; - - let mut palette = Palette::new(); - - // Fill the palette with every gray - for gray in 0..=255 { - palette.push(Color::new(gray, gray, gray)); - } - - let mut image = vec![0; 128 * 128]; - - // Create a file to write the gif to. We can try here, with the ?, because - // EncodeError has a From<std::io::Error> impl - let file = File::create(gif_path)?; - let mut writer = Writer::new(file, 128, 128, Some(palette))?; - for idx in 0..=255 { - image.fill(idx); - - writer.image(ImageBuilder::new(128, 128).delay(3).build(image.clone())?)?; - } - - writer.repeat(LoopCount::Forever)?; - writer.done() -} diff --git a/gifed/examples/write.rs b/gifed/examples/write.rs deleted file mode 100644 index 39e28d6..0000000 --- a/gifed/examples/write.rs +++ /dev/null @@ -1,35 +0,0 @@ -use gifed::{ - block::{LoopCount, Palette}, - writer::ImageBuilder, - Color, EncodeError, Gif, -}; - -fn main() -> Result<(), EncodeError> { - let gif_path = match std::env::args().nth(1) { - None => { - eprintln!("Expected a path to output the gif to"); - std::process::exit(-1); - } - Some(path) => path, - }; - - let mut palette = Palette::new(); - - // Fill the palette with every gray - for gray in 0..=255 { - palette.push(Color::new(gray, gray, gray)); - } - - let mut image = vec![0; 128 * 128]; - - let mut builder = Gif::builder(128, 128).palette(palette); - for idx in 0..=255 { - image.fill(idx); - - builder = builder.image(ImageBuilder::new(128, 128).delay(3).build(image.clone())?); - } - - builder.repeat(LoopCount::Forever).build()?.save(gif_path)?; - - Ok(()) -} |