THotPDF.FlattenLoadedPageComplexGraphics

Flattens mesh shadings and complex Pattern resources at the lowest resolution that satisfies a measured visual-error budget

Declaration

function FlattenLoadedPageComplexGraphics(PageIndex, MinimumDPI,
    MaximumDPI, DPIIncrement: Integer;
    MaximumPerceptualError: Double;
    MaxRasterPixels, MaxTilePixels: Int64;
    out Info: THPDFComplexGraphicsFlattenInfo): Boolean;

Selection model

The method detects type 4 to 7 mesh shadings, tiling patterns and mesh-backed shading patterns in the page resource dictionaries

It renders a deterministic four-by-four grid of bounded sample regions at MaximumDPI, then tests resolutions from MinimumDPI upward by DPIIncrement. Candidate samples are compared with the reference through luma-weighted RGB distance normalised to a zero-to-100 perceptual-error scale

The first candidate at or below MaximumPerceptualError is selected. MaximumDPI is always a lossless reference fallback

Output and bounds

The selected page render is emitted as seam-free Flate-compressed D65 CalRGB tiles. MaxRasterPixels limits total output resolution and MaxTilePixels bounds each live render, conversion and compression working set

Pages using Separation or DeviceN are preserved as vector content with cgfsSpotColorPreserved, because raster flattening would destroy process-separation semantics

THPDFComplexGraphicsFlattenInfo reports detected resource counts, selected and reference DPI, measured error, compared sample count, tile count, peak tile pixels, peak working bytes, output colour space and spot colourants

See also FlattenLoadedPageTransparency and Display Lists and Print Production