T.800-2015 JPEG 2000 decoder for MoonBit
Dependencies
moon add trkbt10/jpeg2000import {
"trkbt10/jpeg2000" @j2k,
}
///|
fn main {
let data : Bytes = ... // JPEG 2000 codestream bytes
let image = try { @j2k.decode(data) } catch { e => abort(e.to_string()) }
println("w=\{image.width} h=\{image.height} comps=\{image.num_components}")
}pub fn decode(Bytes) -> ImageData raise DecodeErrorpub fn parse(Bytes) -> Codestream raise DecodeErrorpub(all) struct ImageData {
width : Int
height : Int
num_components : Int
bits_per_component : Int
is_signed : Bool
data : Bytes
}
pub(all) suberror DecodeError {
InvalidCodestream(String)
UnsupportedFeature(String)
DecodeFailed(String)
}trkbt10/jpeg2000 — public API (decode, parse)
src/internal/core — codestream parsing internals
src/internal/decoder — decode pipeline (MQ, T1, DWT, MCT)
src/cmd/main — native CLI
src/cmd/wasm — wasm CLImoon build --target wasmpub(all) suberror DecodeError {
InvalidCodestream(String)
UnsupportedFeature(String)
DecodeFailed(String)
}impl Show for DecodeErrorpub(all) struct ImageData {
width : Int
height : Int
num_components : Int
bits_per_component : Int
is_signed : Bool
data : Bytes
}T.800-2015 JPEG 2000 decoder for MoonBit
Dependencies