From: Kostya Shishkov Date: Sun, 24 May 2020 13:23:37 +0000 (+0200) Subject: frmwriter: fix handling of flipped paletted images X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=17d1bf82a978619921c691a1ee951ba262c27730;p=nihav-tool.git frmwriter: fix handling of flipped paletted images --- 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 = 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; } } }