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

FileNameThe bitmap file to encode
InterpolateWrites the image interpolation flag when nonzero
SymbolExtractRequests symbol dictionary extraction when the active encoder backend supports it
UseExternalEncoderPrefers the external JBIG2 encoder backend when available
SkipBlackDotsEnables isolated black-dot cleanup before encoding when nonzero
BlackDotSizeMaximum isolated black-pixel cluster size removed during cleanup
LossyLevelCleanup 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:

RegisterJBIG2EncoderBackendInstalls 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
RegisterJBIG2DecoderBackendInstalls the primary TJBIG2DecodeCallback, which receives the image and global data bytes and fills a TJBIG2DecodeResult record
RegisterJBIG2ExternalDecoderBackendRegisters 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
ClearJBIG2BackendsRemoves every registered encoder and decoder callback
IsJBIG2EncoderBackendAvailable / IsJBIG2DecoderBackendAvailable / IsJBIG2ExternalDecoderBackendAvailableReport whether the corresponding callback is currently registered
SetPreferExternalJBIG2Decoder / GetPreferExternalJBIG2DecoderGlobal 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
DefaultJBIG2EncodeOptionsReturns a TJBIG2EncodeOptions record initialised to the defaults the AddImageJBIG2* calls start from (lossless, symbol dictionary on, global segments off, external encoder preferred)
ClearJBIG2DecodeResultReleases the scanline memory owned by a TJBIG2DecodeResult record and resets its fields