encodeJbig2

Encode bitmap as a JBIG2 generic region with template 0 and typical prediction, in the embedded form a PDF takes, as Jbig2EncodeOptions gives by default. See the overload with options.


fun encodeJbig2(bitmap: KiteBitmap, options: Jbig2EncodeOptions, cancellationCheck: () -> Unit? = null): ByteArray(source)

Encode bitmap as JBIG2 (ITU-T T.88, #185): one page holding one generic region, coded with the MQ arithmetic coder or, with Jbig2EncodeOptions.mmr, with T.6. A pixel is black when its luma (BT.601 weights), laid over white by its alpha, is below half, so a transparent pixel is white; the coding of that bilevel page is lossless.

By default the result is the embedded stream of PDF's /JBIG2Decode: a page information segment and an immediate generic region segment, with no global stream. With Jbig2EncodeOptions.standalone it is a .jb2 file. Jbig2Decoder.decode reads the embedded form back. Symbol dictionaries and text regions, which pay only for text and which other encoders make lossy, are not written.

cancellationCheck, when given, runs every 64 rows and may throw to stop the encode; what it throws comes out of this call as it is.