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

DPIThe render resolution
PageThe one-based page number to render
FileNameThe destination BMP file
Threshold0 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
Despeckle0 disables cleanup; values from 1 to 8 remove black pixels with fewer neighbouring black pixels in the surrounding 3x3 area

Return values

0The page could not be rendered, the options were out of range, or the output file could not be written
1The 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