use turbojpeg::{Decompressor, Image, PixelFormat};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let jpeg_data = std::fs::read("examples/parrots.jpg")?;
let mut decompressor = Decompressor::new()?;
let header = decompressor.read_header(&jpeg_data)?;
let (width, height) = (header.width, header.height);
let mut image = Image {
pixels: vec![0; 3 * width * height],
width: width,
pitch: 3 * width, height: height,
format: PixelFormat::RGB,
};
decompressor.decompress(&jpeg_data, image.as_deref_mut())?;
println!("{:?}", &image.pixels[0..9]);
Ok(())
}