65 lines
1.5 KiB
Rust
65 lines
1.5 KiB
Rust
use crate::*;
|
|
|
|
pub fn rle_diff_horizontal(prev_frame: &Frame, encoded: &[u8], reader: &mut usize) -> Frame {
|
|
let (runs, decoded) = rle_255_decode_until(encoded, FRAME_SIZE);
|
|
*reader += runs;
|
|
let mut frame = prev_frame.clone();
|
|
let mut i = 0;
|
|
for y in 0..HEIGHT {
|
|
for x in 0..WIDTH {
|
|
frame[x][y] ^= decoded[i];
|
|
i += 1;
|
|
}
|
|
}
|
|
frame
|
|
}
|
|
|
|
pub fn rle_diff_vertical(prev_frame: &Frame, encoded: &[u8], reader: &mut usize) -> Frame {
|
|
let (runs, decoded) = rle_255_decode_until(encoded, FRAME_SIZE);
|
|
*reader += runs;
|
|
let mut frame = prev_frame.clone();
|
|
let mut i = 0;
|
|
for x in 0..WIDTH {
|
|
for y in 0..HEIGHT {
|
|
frame[x][y] ^= decoded[i];
|
|
i += 1;
|
|
}
|
|
}
|
|
frame
|
|
}
|
|
|
|
pub fn rle_horizontal(_prev_frame: &Frame, encoded: &[u8], reader: &mut usize) -> Frame {
|
|
let (runs, pixels) = rle_255_decode_until(encoded, FRAME_SIZE);
|
|
*reader += runs;
|
|
let mut frame = FRAME_0;
|
|
let mut i = 0;
|
|
for y in 0..HEIGHT {
|
|
for x in 0..WIDTH {
|
|
frame[x][y] = pixels[i];
|
|
i += 1;
|
|
}
|
|
}
|
|
frame
|
|
}
|
|
|
|
pub fn rle_vertical(_prev_frame: &Frame, encoded: &[u8], reader: &mut usize) -> Frame {
|
|
let (runs, pixels) = rle_255_decode_until(encoded, FRAME_SIZE);
|
|
*reader += runs;
|
|
let mut frame = FRAME_0;
|
|
let mut i = 0;
|
|
for x in 0..WIDTH {
|
|
for y in 0..HEIGHT {
|
|
frame[x][y] = pixels[i];
|
|
i += 1;
|
|
}
|
|
}
|
|
frame
|
|
}
|
|
|
|
pub fn fill_white(_prev_frame: &Frame, _encoded: &[u8], _reader: &mut usize) -> Frame {
|
|
FRAME_1
|
|
}
|
|
|
|
pub fn fill_black(_prev_frame: &Frame, _encoded: &[u8], _reader: &mut usize) -> Frame {
|
|
FRAME_0
|
|
}
|