+ ofile.write_all(&vline[..w2]).unwrap();
+ ofile.write_all(pad.as_slice()).unwrap();
+ }
+ }
+ } else if has_chroma {
+ if !is_flipped {
+ for uline in u.chunks(stride1) {
+ ofile.write_all(&uline[..w2]).unwrap();
+ ofile.write_all(pad.as_slice()).unwrap();
+ }
+ for vline in v.chunks(stride2) {
+ ofile.write_all(&vline[..w2]).unwrap();
+ ofile.write_all(pad.as_slice()).unwrap();
+ }
+ } else {
+ for uline in u.chunks(stride1).rev() {
+ ofile.write_all(&uline[..w2]).unwrap();
+ ofile.write_all(pad.as_slice()).unwrap();
+ }
+ for vline in v.chunks(stride2).rev() {
+ ofile.write_all(&vline[..w2]).unwrap();
+ ofile.write_all(pad.as_slice()).unwrap();
+ }