jp2k_encode function
Encodes an interleaved, tightly packed, 8-bit-per-sample raster
(width * height * num_components bytes, row-major, no padding) to a
raw J2K codestream (SOC marker FF4F — not the box-structured .jp2 file
format).
compression_ratio selects lossy compression targeting that
size-reduction ratio against the uncompressed raster (e.g. 20 means
roughly 20:1); pass 0 for mathematically lossless (reversible 5-3
wavelet) encoding.
Blocking/synchronous, no main-isolate restriction — call from a background isolate to keep encode work off the UI thread.
Implementation
@ffi.Native<
ffi.Pointer<Jp2kEncodeResult> Function(
ffi.Pointer<ffi.Uint8>,
ffi.Int32,
ffi.Int32,
ffi.Int32,
ffi.Float,
)
>()
external ffi.Pointer<Jp2kEncodeResult> jp2k_encode(
ffi.Pointer<ffi.Uint8> pixels,
int width,
int height,
int num_components,
double compression_ratio,
);