RenderPageToMonochromeFileEx
Rendering and printing, Image handling, Optimisation
Description
Renders a page to a 1-bit BMP file with optional threshold conversion and isolated black-pixel cleanup
Use this function before CCITT or JBIG2 workflows when scanned or rendered content needs deterministic monochrome preparation
Syntax
Delphi
Function TPDFlib.RenderPageToMonochromeFileEx(DPI: Double; Page: Integer; Const FileName: WideString; Threshold, Despeckle: Integer): Integer;
Parameters
| DPI | The render resolution |
|---|---|
| Page | The one-based page number to render |
| FileName | The destination BMP file |
| Threshold | 0 keeps the legacy GDI halftone path when Despeckle is also 0; otherwise values from 1 to 255 select the grayscale cutoff used for black pixels |
| Despeckle | 0 disables cleanup; values from 1 to 8 remove black pixels with fewer neighbouring black pixels in the surrounding 3x3 area |
Return values
| 0 | The page could not be rendered, the options were out of range, or the output file could not be written |
|---|---|
| 1 | The 1-bit BMP file was written |
Remarks
RenderPageToMonochromeFile calls this function with Threshold and Despeckle set to 0, preserving the previous GDI halftone behaviour
When cleanup is requested with Threshold set to 0, the function uses a threshold of 128 before applying the cleanup pass