jp2k_encode function

  1. @Native<Pointer<Jp2kEncodeResult> Function(Pointer<Uint8>, Int32, Int32, Int32, Float)>(ffi.Pointer<ffi.Uint8>, ffi.Int32, ffi.Int32, ffi.Int32, ffi.Float)>()
Pointer<Jp2kEncodeResult> jp2k_encode(
  1. Pointer<Uint8> pixels,
  2. int width,
  3. int height,
  4. int num_components,
  5. double compression_ratio,
)

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,
);