about summary refs log tree commit diff
path: root/gifed/src/block
diff options
context:
space:
mode:
Diffstat (limited to 'gifed/src/block')
-rw-r--r--gifed/src/block/mod.rs18
-rw-r--r--gifed/src/block/palette.rs9
2 files changed, 19 insertions, 8 deletions
diff --git a/gifed/src/block/mod.rs b/gifed/src/block/mod.rs
index 3a18a07..46738ed 100644
--- a/gifed/src/block/mod.rs
+++ b/gifed/src/block/mod.rs
@@ -102,3 +102,21 @@ fn encode_extension(block: &Block) -> Vec<u8> {
 
 	vec
 }
+
+impl From<GraphicControl> for Block {
+	fn from(gce: GraphicControl) -> Self {
+		Block::GraphicControlExtension(gce)
+	}
+}
+
+impl From<Application> for Block {
+	fn from(app: Application) -> Self {
+		Block::ApplicationExtension(app)
+	}
+}
+
+impl From<LoopCount> for Block {
+	fn from(count: LoopCount) -> Self {
+		Block::LoopingExtension(count)
+	}
+}
diff --git a/gifed/src/block/palette.rs b/gifed/src/block/palette.rs
index 8a06883..3cbcaaa 100644
--- a/gifed/src/block/palette.rs
+++ b/gifed/src/block/palette.rs
@@ -15,15 +15,8 @@ impl Palette {
 		Self { table: vec![] }
 	}
 
-	//FIXME: gen- Second paragraph is incorrect
-	/// Returns the number of colors in the color table as used by the packed
-	/// fields in the Logical Screen Descriptor and Image Descriptor. You can
-	/// get the actual size with the [`len`](struct.ColorTable.html#method.len) method.
-	///
-	/// This value is equal to `log2([Palette::len]) - 1`. In other words, 2^(n + 1) will
-	/// give you the same value as [Palette::len]. (where `n` is the value returned)
 	pub fn packed_len(&self) -> u8 {
-		((self.table.len() as f32).log2().ceil() - 1f32) as u8
+		crate::color_table_len_to_packed(self.len())
 	}
 
 	pub fn lzw_code_size(&self) -> u8 {