diff options
author | Genny <gen@nyble.dev> | 2021-10-11 03:36:38 -0500 |
---|---|---|
committer | Genny <gen@nyble.dev> | 2021-10-11 03:36:38 -0500 |
commit | 757eab88d67a425728b87286c763387f52367196 (patch) | |
tree | f1d61edb0a838787f6984accdd92df68a69d567a /src/block/indexedimage.rs | |
parent | 9b7bd5696a21496fa0c38a17e69c5c0658acfe73 (diff) | |
download | gifed-757eab88d67a425728b87286c763387f52367196.tar.gz gifed-757eab88d67a425728b87286c763387f52367196.zip |
Run rustfmt
Diffstat (limited to 'src/block/indexedimage.rs')
-rw-r--r-- | src/block/indexedimage.rs | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/src/block/indexedimage.rs b/src/block/indexedimage.rs index 0be066f..8ed0319 100644 --- a/src/block/indexedimage.rs +++ b/src/block/indexedimage.rs @@ -4,67 +4,67 @@ use super::{ColorTable, ImageDescriptor}; use crate::LZW; pub struct IndexedImage { - pub image_descriptor: ImageDescriptor, - pub local_color_table: Option<ColorTable>, - pub indicies: Vec<u8>, + pub image_descriptor: ImageDescriptor, + pub local_color_table: Option<ColorTable>, + pub indicies: Vec<u8>, } impl IndexedImage { - pub fn left(&self) -> u16 { - self.image_descriptor.left - } + pub fn left(&self) -> u16 { + self.image_descriptor.left + } - pub fn top(&self) -> u16 { - self.image_descriptor.left - } + pub fn top(&self) -> u16 { + self.image_descriptor.left + } - pub fn width(&self) -> u16 { - self.image_descriptor.width - } + pub fn width(&self) -> u16 { + self.image_descriptor.width + } - pub fn height(&self) -> u16 { - self.image_descriptor.height - } + pub fn height(&self) -> u16 { + self.image_descriptor.height + } - pub fn as_boxed_slice(&self, minimum_code_size: u8) -> Box<[u8]> { - let mut out = vec![]; + pub fn as_boxed_slice(&self, minimum_code_size: u8) -> Box<[u8]> { + let mut out = vec![]; - let mut boxed: Box<[u8]> = (&self.image_descriptor).into(); - out.extend_from_slice(&*boxed); + let mut boxed: Box<[u8]> = (&self.image_descriptor).into(); + out.extend_from_slice(&*boxed); - // Get the mcs while we write out the color table - let mut mcs = if let Some(lct) = &self.local_color_table { - boxed = lct.into(); - out.extend_from_slice(&*boxed); + // Get the mcs while we write out the color table + let mut mcs = if let Some(lct) = &self.local_color_table { + boxed = lct.into(); + out.extend_from_slice(&*boxed); - lct.packed_len() - } else { - minimum_code_size + 1 - }; + lct.packed_len() + } else { + minimum_code_size + 1 + }; - if mcs < 2 { - mcs = 2; // Must be true: 0 <= mcs <= 8 - } + if mcs < 2 { + mcs = 2; // Must be true: 0 <= mcs <= 8 + } - // First write out the MCS - out.push(mcs); + // First write out the MCS + out.push(mcs); - let compressed = LZW::encode(mcs, &self.indicies); + let compressed = LZW::encode(mcs, &self.indicies); - for chunk in compressed.chunks(255) { - out.push(chunk.len() as u8); - out.extend_from_slice(chunk); - } - // Data block length 0 to indicate an end - out.push(0x00); + for chunk in compressed.chunks(255) { + out.push(chunk.len() as u8); + out.extend_from_slice(chunk); + } + // Data block length 0 to indicate an end + out.push(0x00); - out.into_boxed_slice() - } + out.into_boxed_slice() + } } pub struct CompressedImage { - pub image_descriptor: ImageDescriptor, - pub local_color_table: Option<ColorTable>, - pub lzw_minimum_code_size: u8, - pub blocks: Vec<Vec<u8>>, + pub image_descriptor: ImageDescriptor, + pub local_color_table: Option<ColorTable>, + pub lzw_minimum_code_size: u8, + pub blocks: Vec<Vec<u8>>, } |