aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-03-26 19:16:01 +0100
committermetamuffin <metamuffin@disroot.org>2025-03-26 19:16:01 +0100
commitab8ecf890fc51fcaf8b85ae594bf41db8aa6bc8a (patch)
tree863aef760d6a347b11811d2fb06edeaf43a63562 /src
parent11f492a942b3a052017be5d4fe2c76f9e7685ee6 (diff)
downloadunity-tools-ab8ecf890fc51fcaf8b85ae594bf41db8aa6bc8a.tar
unity-tools-ab8ecf890fc51fcaf8b85ae594bf41db8aa6bc8a.tar.bz2
unity-tools-ab8ecf890fc51fcaf8b85ae594bf41db8aa6bc8a.tar.zst
dxt1 decompression failure
Diffstat (limited to 'src')
-rw-r--r--src/classes/texture2d.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/classes/texture2d.rs b/src/classes/texture2d.rs
index 6b96b17..d1e6e30 100644
--- a/src/classes/texture2d.rs
+++ b/src/classes/texture2d.rs
@@ -133,20 +133,24 @@ impl Texture2D {
_ => unreachable!(),
}
);
- let mut buf = vec![0u32; w * h];
- texture2ddecoder::decode_unity_crunch(&self.image_data, w, h, &mut buf).unwrap();
+ let mut buf = vec![0u32; w * h * self.image_count as usize];
+ // TODO decode multi-face textures
+ texture2ddecoder::decode_unity_crunch(&self.image_data, w, h, &mut buf)
+ .map_err(|e| anyhow!("{e}"))?;
Ok(u32_argb_buf_to_images(buf))
}
BC7 => {
info!("decompressing {w}x{h} BC7 texture",);
let mut buf = vec![0u32; w * h];
- texture2ddecoder::decode_bc7(&self.image_data, w, h, &mut buf).unwrap();
+ texture2ddecoder::decode_bc7(&self.image_data, w, h, &mut buf)
+ .map_err(|e| anyhow!("{e}"))?;
Ok(u32_argb_buf_to_images(buf))
}
BC6H => {
info!("decompressing {w}x{h} BC6H texture",);
let mut buf = vec![0u32; w * h];
- texture2ddecoder::decode_bc6(&self.image_data, w, h, &mut buf, false).unwrap();
+ texture2ddecoder::decode_bc6(&self.image_data, w, h, &mut buf, false)
+ .map_err(|e| anyhow!("{e}"))?;
Ok(u32_argb_buf_to_images(buf))
}
RGB24 => {