diff options
-rw-r--r-- | src/bin/textures.rs | 8 | ||||
-rw-r--r-- | src/classes/streaminginfo.rs | 4 | ||||
-rw-r--r-- | src/object.rs | 7 |
3 files changed, 14 insertions, 5 deletions
diff --git a/src/bin/textures.rs b/src/bin/textures.rs index 4a35de7..5db888e 100644 --- a/src/bin/textures.rs +++ b/src/bin/textures.rs @@ -51,7 +51,7 @@ fn main() -> anyhow::Result<()> { let mut texture = Texture2D::from_value(value).unwrap(); if texture.image_data.len() == 0 { let ress = ress.as_mut().unwrap(); - ress.seek(SeekFrom::Start(texture.stream_data.offset as u64))?; + ress.seek(SeekFrom::Start(texture.stream_data.offset))?; ress.by_ref() .take(texture.stream_data.size as u64) .read_to_end(&mut texture.image_data)?; @@ -62,8 +62,10 @@ fn main() -> anyhow::Result<()> { ); match texture.to_image() { Ok(im) => { - im.save(&path).unwrap(); - println!("{path}"); + if !im.as_rgba32f().is_some() { + im.save(&path).unwrap(); + println!("{path}"); + } } Err(e) => warn!("{e}"), } diff --git a/src/classes/streaminginfo.rs b/src/classes/streaminginfo.rs index 3ab271d..1f8cadb 100644 --- a/src/classes/streaminginfo.rs +++ b/src/classes/streaminginfo.rs @@ -6,7 +6,7 @@ use super::FromValue; #[derive(Debug, Serialize)] pub struct StreamingInfo { - pub offset: u32, + pub offset: u64, pub path: String, pub size: u32, } @@ -14,7 +14,7 @@ impl FromValue for StreamingInfo { fn from_value(v: Value) -> Result<Self> { let fields = v.as_class("StreamingInfo").unwrap(); Ok(StreamingInfo { - offset: fields["offset"].as_u32().unwrap(), + offset: fields["offset"].as_u64().unwrap(), size: fields["size"].as_u32().unwrap(), path: fields["path"].to_owned().as_string().unwrap(), }) diff --git a/src/object.rs b/src/object.rs index ef677d1..92415e1 100644 --- a/src/object.rs +++ b/src/object.rs @@ -164,6 +164,13 @@ impl Value { None } } + pub fn as_u64(&self) -> Option<u64> { + match self { + Self::U64(x) => Some(*x), + Self::U32(x) => Some(*x as u64), + _ => None, + } + } pub fn as_f32(&self) -> Option<f32> { if let Value::F32(s) = self { Some(*s) |