Crate pwgraster

Source
Expand description

§PWG Raster

Decoding of Printer Working Group Candidate Standard 5102.4-2012 raster images.

§Decoding multiple pages

next_page() will call a closure with a page structure that allows access to the header and page data. It will return Ok(None) when there are no more pages.

use std::fs::File;
use std::io::BufReader;
use pwgraster::PWGReader;
let infile = File::open("./color.jpg-4x6-srgb-8-600dpi.pwg")
                 .expect("Failed to open input");
let mut pwg = PWGReader::new(BufReader::new(infile), true).unwrap();
while pwg.next_page(|page| {
        let width = page.header().Width().unwrap();
        let height = page.header().Height().unwrap();
        println!("Page dimensions {}x{}", width, height);
        let mut buf = Vec::with_capacity(page.header().image_size_bytes().unwrap());
        println!("Reading page");
        page.unpack(&mut buf).unwrap();
        println!("Page read");
        // Do something with image data
        Ok(())
    }).unwrap().is_some() {}

Modules§

types
Data types used in the PWG header

Structs§

Error
PWGPage
Returned by PWGReader::next_page(). Allows access to the page header and image data.
PWGReader
Top-level structure over a reader that returns decoded pages
PageHeader
Accessors into a slice containing a PWG page header

Enums§

ErrorKind
StreamError

Constants§

PWG_HEADER_SIZE
Size of the fixed-length PWG header for each page
PWG_SYNC_WORD
4 bytes found at the beginning of PWG data

Functions§

unpack_page
Stream PWG image data from a reader to a writer