diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2020-05-24 15:23:37 +0200 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2020-05-24 15:23:37 +0200 |
commit | 17d1bf82a978619921c691a1ee951ba262c27730 (patch) | |
tree | c6b50c574d1d0eda9aa55ef3abea8039b5ee676d | |
parent | 70183711cc0dd3e740817a9d26f5c89cff5cb442 (diff) | |
download | nihav-tool-17d1bf82a978619921c691a1ee951ba262c27730.tar.gz |
frmwriter: fix handling of flipped paletted images
-rw-r--r-- | src/frmwriter.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/frmwriter.rs b/src/frmwriter.rs index 71ad491..f882a7f 100644 --- a/src/frmwriter.rs +++ b/src/frmwriter.rs @@ -112,9 +112,12 @@ pub fn write_palppm(pfx: &str, strno: usize, num: u64, frm: NAFrameRef) { buf.get_info().get_format().get_chromaton(2).unwrap().get_offset() as usize ]; let flipped = buf.get_info().is_flipped(); - let mut idx = if !flipped { 0 } else { ls * (h - 1) }; + let mut idx = if !flipped { 0 } else { ls * h }; let mut line: Vec<u8> = vec![0; w * 3]; for _ in 0..h { + if flipped { + idx -= ls; + } let src = &dta[idx..(idx+w)]; for x in 0..w { let pix = src[x] as usize; @@ -125,8 +128,6 @@ pub fn write_palppm(pfx: &str, strno: usize, num: u64, frm: NAFrameRef) { ofile.write_all(line.as_slice()).unwrap(); if !flipped { idx += ls; - } else { - idx -= ls; } } } |