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
- Page
Header - Accessors into a slice containing a PWG page header
Enums§
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