diff --git a/cz/Cargo.toml b/cz/Cargo.toml index 51b9de4..52c666e 100644 --- a/cz/Cargo.toml +++ b/cz/Cargo.toml @@ -10,8 +10,10 @@ A encoder/decoder for CZ# image files used in the LUCA System Engine. png = ["dep:image"] [dependencies] -byteorder = "1.5.0" -thiserror = "1.0.59" -imagequant = "4.3.1" +byteorder = "1.5" +thiserror = "1.0" +imagequant = "4.3" +rgb = "0.8" + +# Only active on feature "png" image = { version = "0.25", default-features = false, features = ["png"], optional = true } -rgb = "0.8.40" diff --git a/cz/src/dynamic.rs b/cz/src/dynamic.rs index 1dda8d5..87f13b1 100644 --- a/cz/src/dynamic.rs +++ b/cz/src/dynamic.rs @@ -112,12 +112,19 @@ impl DynamicCz { ) -> Result<(), CzError> { let mut out_file = BufWriter::new(File::create(path.as_ref())?); - self.write(&mut out_file)?; + self.encode(&mut out_file)?; Ok(()) } - pub fn write(&self, mut output: &mut T) -> Result<(), CzError> { + /// Encode the CZ file into a byte stream. + /// This encodes everything based on options the header which have been + /// set by the user. For example, to change the version of file to be + /// saved, use [`CommonHeader::set_version()`] + pub fn encode( + &self, + mut output: &mut T + ) -> Result<(), CzError> { let mut header = *self.header(); if header.version() == CzVersion::CZ2 { @@ -126,7 +133,7 @@ impl DynamicCz { header.write_into(&mut output)?; if header.version() == CzVersion::CZ2 { - // CZ2 files have this odd section instead of an extended header...? + // TODO: CZ2 files have this odd section instead of an extended header...? output.write_all(&[0, 0, 0])?; } else if let Some(ext) = self.header_extended { ext.write_into(&mut output)?;