diff options
author | Genny <gen@nyble.dev> | 2021-09-15 22:16:30 -0500 |
---|---|---|
committer | Genny <gen@nyble.dev> | 2021-09-15 22:16:30 -0500 |
commit | 7b8081a79fb3db4a76f9e4cca8f8a88e6e7f873c (patch) | |
tree | 5eab8cbf47698b031c12f8eadc4c55f674f70c01 /src/writer/imagebuilder.rs | |
parent | cdedae673268c372beb27c6d2f123cdf21f630f1 (diff) | |
download | gifed-7b8081a79fb3db4a76f9e4cca8f8a88e6e7f873c.tar.gz gifed-7b8081a79fb3db4a76f9e4cca8f8a88e6e7f873c.zip |
Reading, fix writing, monocommit
Diffstat (limited to 'src/writer/imagebuilder.rs')
-rw-r--r-- | src/writer/imagebuilder.rs | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/src/writer/imagebuilder.rs b/src/writer/imagebuilder.rs index f2156ac..d38687e 100644 --- a/src/writer/imagebuilder.rs +++ b/src/writer/imagebuilder.rs @@ -1,71 +1,71 @@ -use crate::block::{ColorTable, IndexedImage, ImageDescriptor}; +use crate::block::{ColorTable, ImageDescriptor, IndexedImage}; pub struct ImageBuilder { - left_offset: u16, - top_offset: u16, - width: u16, - height: u16, - color_table: Option<ColorTable>, - indicies: Vec<u8> + left_offset: u16, + top_offset: u16, + width: u16, + height: u16, + color_table: Option<ColorTable>, + indicies: Vec<u8>, } impl ImageBuilder { - pub fn new(width: u16, height: u16) -> Self { - Self { - left_offset: 0, - top_offset: 0, - width, - height, - color_table: None, - indicies: vec![] - } - } + pub fn new(width: u16, height: u16) -> Self { + Self { + left_offset: 0, + top_offset: 0, + width, + height, + color_table: None, + indicies: vec![], + } + } - pub fn offsets(mut self, left_offset: u16, top_offset: u16) -> Self { - self.left_offset = left_offset; - self.top_offset = top_offset; - self - } + pub fn offsets(mut self, left_offset: u16, top_offset: u16) -> Self { + self.left_offset = left_offset; + self.top_offset = top_offset; + self + } - pub fn left_offset(mut self, offset: u16) -> Self { - self.left_offset = offset; - self - } + pub fn left_offset(mut self, offset: u16) -> Self { + self.left_offset = offset; + self + } - pub fn top_offset(mut self, offset: u16) -> Self { - self.top_offset = offset; - self - } + pub fn top_offset(mut self, offset: u16) -> Self { + self.top_offset = offset; + self + } - pub fn color_table(mut self, table: ColorTable) -> Self { - self.color_table = Some(table); + pub fn color_table(mut self, table: ColorTable) -> Self { + self.color_table = Some(table); - self - } + self + } - pub fn indicies(mut self, vec: Vec<u8>) -> Self { - self.indicies = vec; - self - } + pub fn indicies(mut self, vec: Vec<u8>) -> Self { + self.indicies = vec; + self + } - pub fn build(self) -> IndexedImage { - let mut imgdesc = ImageDescriptor { - left: self.left_offset, - top: self.top_offset, - width: self.width, - height: self.height, - packed: 0 // Set later - }; + pub fn build(self) -> IndexedImage { + let mut imgdesc = ImageDescriptor { + left: self.left_offset, + top: self.top_offset, + width: self.width, + height: self.height, + packed: 0, // Set later + }; - if let Some(lct) = &self.color_table { - imgdesc.color_table_present(true); - imgdesc.color_table_size(lct.packed_len()); - } + if let Some(lct) = &self.color_table { + imgdesc.set_color_table_present(true); + imgdesc.set_color_table_size(lct.packed_len()); + } - IndexedImage { - image_descriptor: imgdesc, - local_color_table: self.color_table, - indicies: self.indicies - } - } + IndexedImage { + image_descriptor: imgdesc, + local_color_table: self.color_table, + indicies: self.indicies, + } + } } |