JpxDecoder

object JpxDecoder

A pure-Kotlin JPEG 2000 decoder (ITU-T T.800), taking either JP2 container boxes or a raw codestream, part 1 baseline. Produces an 8-bpc Gray or RGB raster plus an optional alpha plane from a cdef opacity channel.

Handled: SIZ/COD/QCD with COC/QCC overrides, multiple tiles and tile-parts, LRCP/RLCP/RPCL/PCRL/CPRL progressions, general precincts, tag trees, multi-layer tier-2 packet headers (with SOP/EPH), EBCOT tier-1 at the baseline code-block style, reversible 5/3 and irreversible 9/7 inverse DWT, RCT and ICT multiple-component transforms, DC level shift, component subsampling by nearest upsample, and bit depths up to 16.

Not handled, each of which makes decode return null: RGN regions of interest, POC progression changes, PPM/PPT packed headers, and non-baseline code-block styles (bypass, reset, termall, vsc, segsym). KiteImage.probe names the ones that sit in the main header, so a caller can find out without attempting a decode.

Types

Link copied to clipboard
class Result(val width: Int, val height: Int, val colorSpace: String, val pixelBytes: ByteArray, val alpha: ByteArray?)

Functions

Link copied to clipboard
Link copied to clipboard
fun isJpx(data: ByteArray): Boolean

True when data looks like a JP2 container or a raw J2K codestream.