pnm decoding and encoding
Diffstat (limited to 'src/pam.rs')
-rw-r--r--src/pam.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/pam.rs b/src/pam.rs
index d8c1314..726562c 100644
--- a/src/pam.rs
+++ b/src/pam.rs
@@ -141,15 +141,15 @@ unsafe fn encode_into<const N: usize>(
o.put(*b"TUPLTYPE ");
o.put(*tupltype);
o.put(*b"\nENDHDR\n");
- for &x in buf {
- if &tupltype[..] == b"BLACKANDWHITE" {
+ if tupltype[..] == *b"BLACKANDWHITE" {
+ for &x in buf {
o.push(x ^ 1)
- } else {
- o.push(x)
}
+ o.sub_ptr(out)
+ } else {
+ o.copy_from(buf.as_ptr(), buf.len());
+ o.sub_ptr(out) + buf.len()
}
-
- o.sub_ptr(out)
}
#[derive(Copy, Clone, Debug)]