ljpeg 0.1.2

Fast, no dependency lossless JPEG decoder and encoder
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use ljpeg::Decoder;

#[test]
fn decode_image() {
    let decoder = Decoder::new(include_bytes!("../tests/2comp.jpg")).unwrap();
    let output = decoder.decode().unwrap();
    let out: Vec<u8> = output
        .into_iter()
        .flat_map(|u| u.to_be_bytes().into_iter())
        .collect();
    let reference = include_bytes!("../tests/2comp.pgm");
    // 19 is the length of the PGM header in the reference file
    assert_eq!(out.len(), reference.len() - 19);
    for i in 0..out.len() {
        assert_eq!(out[i], reference[19 + i]);
    }
}