mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-01 08:16:43 +00:00
jpeg: read the reference PPM with as_chunks
This commit is contained in:
1 parent
3acc132ff0
commit
b636dad56e
1 file changed
+1
-1
@@ -73,7 +73,7 @@ fn ppm16(bytes: &[u8]) -> (u32, u32, u32, Vec<u16>) {
|
||||
let num = |s: &str| s.parse::<u32>().unwrap_or_else(|e| panic!("PPM header {s}: {e}"));
|
||||
let (w, h, maxval) = (num(&fields[1]), num(&fields[2]), num(&fields[3]));
|
||||
let data = &bytes[at + 1..];
|
||||
let px: Vec<u16> = data.chunks_exact(2).map(|c| u16::from_be_bytes([c[0], c[1]])).collect();
|
||||
let px: Vec<u16> = data.as_chunks::<2>().0.iter().map(|&c| u16::from_be_bytes(c)).collect();
|
||||
assert_eq!(px.len(), (w * h * 3) as usize);
|
||||
(w, h, maxval, px)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user