Expand description
Pure-Rust JPEG 2000 (ISO/IEC 15444-1) decoder: raw codestreams and JP2/JPX
files, as found on their own and in PDF JPXDecode streams.
let file = std::fs::read("image.jp2")?;
let image = rusty_jpx::decode_jpx(&file)?;
println!("{}x{}", image.width, image.height);
for c in &image.components {
println!("{} bits, {:?}, {} samples", c.bits, c.role, c.data.len());
}Samples come back as they were coded, component by component: no colour
conversion (Jpx::color and Jpx::icc say what the values mean) and
no chroma upsampling unless asked for (Jpx::upsampled).
Malformed input returns an error; it does not panic, and it does not
allocate or loop beyond Limits.
The API is safe. unsafe code is confined to one module, the sample
kernels (AVX2, SSE2 and NEON, with a scalar twin that the tests hold them
to).
Structs§
- Component
- One decoded component, or palette channel.
- Component
Info - Header-level description of a component.
- Decode
Options - How to decode.
- Info
- What the headers say, without decoding.
- Jpx
- A decoded image.
- Limits
- Bounds on what a file may ask for.
Enums§
- Channel
Role - What a channel is for (
cdefbox). - Color
Space - Colour specification of the file (the first
colrbox that is understood). - JpxError
- Everything that can go wrong decoding a JPEG 2000 image.
Functions§
- decode_
jpx - Decode a JPEG 2000 image (raw codestream, JP2 or JPX) with the default options.
- decode_
jpx_ with - Decode a JPEG 2000 image.
- info
- Read the headers only.
Type Aliases§
- JpxResult
Resultalias used throughout the crate.