flic/codec/
codec013.rs

1//! Codec for chunk type 13 = FLI_BLACK.
2
3use ::{Raster,RasterMut};
4
5/// Magic for a FLI_BLACK chunk - No Data.
6///
7/// This chunk has no data following the header.  All pixels in the
8/// frame are set to color index 0.
9pub const FLI_BLACK: u16 = 13;
10
11/// Decode a FLI_BLACK chunk.
12pub fn decode_fli_black(dst: &mut RasterMut) {
13    let start = dst.stride * dst.y;
14    let end = dst.stride * (dst.y + dst.h);
15    for row in dst.buf[start..end].chunks_mut(dst.stride) {
16        let start = dst.x;
17        let end = start + dst.w;
18        for e in &mut row[start..end] {
19            *e = 0;
20        }
21    }
22}
23
24/// True if the frame can be encoded by FLI_BLACK.
25pub fn can_encode_fli_black(next: &Raster) -> bool {
26    let start = next.stride * next.y;
27    let end = next.stride * (next.y + next.h);
28    next.buf[start..end].chunks(next.stride)
29            .all(|row| row.iter().all(|&e| e == 0))
30}