Skip to main content

Crate rusty_jpx

Crate rusty_jpx 

Source
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.
ComponentInfo
Header-level description of a component.
DecodeOptions
How to decode.
Info
What the headers say, without decoding.
Jpx
A decoded image.
Limits
Bounds on what a file may ask for.

Enums§

ChannelRole
What a channel is for (cdef box).
ColorSpace
Colour specification of the file (the first colr box 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
Result alias used throughout the crate.