From 743888ae0c1038a92f4a0b64709a313eba70c887 Mon Sep 17 00:00:00 2001 From: Genny Date: Wed, 10 Mar 2021 01:26:24 -0600 Subject: Refactor code and get ready for extension blocks --- src/gif.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/gif.rs') diff --git a/src/gif.rs b/src/gif.rs index c3ef56b..f6ff345 100644 --- a/src/gif.rs +++ b/src/gif.rs @@ -1,10 +1,9 @@ -use crate::block::{ColorTable, Image, ScreenDescriptor, Version}; - +use crate::block::{Block, ColorTable, ScreenDescriptor, Version}; pub struct Gif { pub header: Version, pub screen_descriptor: ScreenDescriptor, pub global_color_table: Option, - pub images: Vec + pub blocks: Vec // Trailer at the end of this struct is 0x3B // } @@ -28,9 +27,13 @@ impl Gif { 0 }; - for image in self.images.iter() { - boxed = image.as_boxed_slice(mcs); - out.extend_from_slice(&*boxed); + for block in self.blocks.iter() { + match block { + Block::IndexedImage(image) => { + boxed = image.as_boxed_slice(mcs); + out.extend_from_slice(&*boxed); + } + } } // Write Trailer -- cgit 1.4.1-3-g733a5