mirror of
https://github.com/G2-Games/lbee-utils.git
synced 2025-04-19 15:22:53 -05:00
Made CZ0 offset optional
This commit is contained in:
parent
c93419439f
commit
7391f3797f
3 changed files with 12 additions and 5 deletions
|
@ -18,10 +18,10 @@ pub struct Cz0Header {
|
|||
bounds_height: u16,
|
||||
|
||||
/// Offset width
|
||||
offset_width: u16,
|
||||
offset_width: Option<u16>,
|
||||
|
||||
/// Offset height
|
||||
offset_height: u16,
|
||||
offset_height: Option<u16>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -38,6 +38,13 @@ impl CzHeader for Cz0Header {
|
|||
return Err(CzError::VersionMismatch)
|
||||
}
|
||||
|
||||
let mut offset_width = None;
|
||||
let mut offset_height = None;
|
||||
if common.length < 28 {
|
||||
offset_width = Some(u16::from_le_bytes(bytes[28..30].try_into().unwrap()));
|
||||
offset_height = Some(u16::from_le_bytes(bytes[30..32].try_into().unwrap()));
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
common,
|
||||
|
||||
|
@ -47,8 +54,8 @@ impl CzHeader for Cz0Header {
|
|||
bounds_width: u16::from_le_bytes(bytes[24..26].try_into().unwrap()),
|
||||
bounds_height: u16::from_le_bytes(bytes[26..28].try_into().unwrap()),
|
||||
|
||||
offset_width: u16::from_le_bytes(bytes[28..30].try_into().unwrap()),
|
||||
offset_height: u16::from_le_bytes(bytes[30..32].try_into().unwrap()),
|
||||
offset_width,
|
||||
offset_height,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ use std::fs;
|
|||
use crate::{cz_common::CzImage, formats::cz0::Cz0Image};
|
||||
|
||||
fn main() {
|
||||
let input = fs::read("../test_files/Old_TestFiles/LOGO0.CZ0").expect("Error, could not open image");
|
||||
let input = fs::read("../test_files/Old_TestFiles/EX_PT.CZ0").expect("Error, could not open image");
|
||||
let cz0_file = Cz0Image::decode(&input).unwrap();
|
||||
println!("{:#?}", cz0_file.header());
|
||||
|
||||
|
|
BIN
src/test.png
BIN
src/test.png
Binary file not shown.
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 54 KiB |
Loading…
Reference in a new issue