Improved docs, updated deps

This commit is contained in:
G2-Games 2024-07-04 23:57:40 -05:00
parent 4f2f192fa1
commit 976fffed1f
2 changed files with 16 additions and 7 deletions

View file

@ -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"

View file

@ -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<T: Write + Seek>(&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<T: Write + Seek>(
&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)?;