AddImageJBIG2FromFileEx
Images
Description
Loads a bitmap file, converts it to monochrome image data, and stores it as a JBIG2 image XObject using named option parameters
Syntax
Delphi
Function TPDFlib.AddImageJBIG2FromFileEx(Const FileName: WideString; Interpolate, SymbolExtract, UseExternalEncoder, SkipBlackDots, BlackDotSize, LossyLevel: Integer): Integer;
Parameters
| FileName | The bitmap file to encode |
|---|---|
| Interpolate | Writes the image interpolation flag when nonzero |
| SymbolExtract | Requests symbol dictionary extraction when the active encoder backend supports it |
| UseExternalEncoder | Prefers the external JBIG2 encoder backend when available |
| SkipBlackDots | Enables isolated black-dot cleanup before encoding when nonzero |
| BlackDotSize | Maximum isolated black-pixel cluster size removed during cleanup |
| LossyLevel | Cleanup aggressiveness hint from 0 to 9 for scanned monochrome input |
Return values
Returns the new ImageID, or 0 when the file cannot be read or encoded
Remarks
The function maps the named parameters to the same encoding path used by AddImageJBIG2FromFile, which preserves compatibility with existing option bitmasks
JBIG2 backend registration
The encoder behind the AddImageJBIG2* family and the decoder used for JBIG2 images in imported documents are pluggable. The PDFlibJBIG2Enc unit exposes the registration surface as standalone functions:
RegisterJBIG2EncoderBackend | Installs a TJBIG2EncodeCallback that receives the scanlines, width, height and a TJBIG2EncodeOptions record and returns the compressed image data and optional global segment data; it serves the UseExternalEncoder request made through the option below |
|---|---|
RegisterJBIG2DecoderBackend | Installs the primary TJBIG2DecodeCallback, which receives the image and global data bytes and fills a TJBIG2DecodeResult record |
RegisterJBIG2ExternalDecoderBackend | Registers the external decode backend (the jbig2dec C decoder on Win64). When registered and the prefer-external switch is on (the default), the /JBIG2Decode load path routes through it and the primary decoder stays the fallback |
ClearJBIG2Backends | Removes every registered encoder and decoder callback |
IsJBIG2EncoderBackendAvailable / IsJBIG2DecoderBackendAvailable / IsJBIG2ExternalDecoderBackendAvailable | Report whether the corresponding callback is currently registered |
SetPreferExternalJBIG2Decoder / GetPreferExternalJBIG2Decoder | Global switch selecting the external decoder over the built-in Pascal decoder when both are available; defaults to True, set False to force the native fallback |
DefaultJBIG2EncodeOptions | Returns a TJBIG2EncodeOptions record initialised to the defaults the AddImageJBIG2* calls start from (lossless, symbol dictionary on, global segments off, external encoder preferred) |
ClearJBIG2DecodeResult | Releases the scanline memory owned by a TJBIG2DecodeResult record and resets its fields |