API referenceRendering & Viewer

rasRenderTile

Render one tile of a page directly into the cache's "main

C
BOOL32 __stdcall rasRenderTile(IPGC CachePtr, uint32_t PageNum, uint32_t PageW, uint32_t PageH, uint32_t NRows, uint32_t NCols, TPDFTile* Tile);
Delphi
function rasRenderTile(CachePtr: IPGC; PageNum, PageW, PageH, NRows, NCols: Cardinal; var Tile: TPDFTile): LongBool; stdcall;

Purpose. Render one tile of a page directly into the cache's "main buffer" (attached via rasInitMainTile, Rasterizer and Page-Cache Lifecycle) — the real, on-demand tile-rendering primitive underlying the whole tiled-viewer model.

Description. Supports two independent tile-addressing schemes, selected by whether Tile.Scale > 0: (1) an arbitrary zoom+pan mode where Tile.Scale is device pixels per page unit and Tile.SrcX/SrcY is the page-space bottom-left origin of the shown region (so the tile source rect is [SrcX, SrcY, TileW/Scale, TileH/Scale]); or (2) a fixed NRows×NCols grid mode where the page is divided evenly and Tile.IndexX/IndexY select a cell (IndexY counted from the bottom, per the NRows - 1 - IndexY flip). Genuinely honors OCG (layer) visibility: it collects the cache's HiddenOCG handle list and calls D.GetPageContentFiltered to strip hidden-layer content before rendering — a tile rendered after rasSetOCGState hides a layer will not show that layer's content. Renders via the general RenderPageToRGB (the same engine RenderPageBMP/E01 uses), then blits pixel-by-pixel into C.MainBuf at the tile's destination rect, converting to BGR order if C.MainPixFmt = pxfBGR (an explicit per-pixel channel swap, not a format flag passed through). Caches the rendered tile's metadata as C.LastTile/HasLastTile := True, consumed by rasGetCurrTile (Rasterizer and Page-Cache Lifecycle).

Parameters.

ParameterDescription
CachePtrTarget page cache; requires a main tile buffer already attached via rasInitMainTile.
PageNum1-based page to render.
PageW, PageHAccepted; not observed to be read (page size comes from D.GetPageSize instead).
NRows, NColsGrid dimensions for the fixed-grid addressing mode (Tile.Scale ≤ 0); ignored in arbitrary-scale mode.
TileIn: DstRect, TileW/TileH, Scale/SrcX/SrcY (arbitrary mode) or IndexX/IndexY (grid mode). Out: PageW, TileW/TileH (possibly clamped), and it becomes the new C.LastTile.

Return value. True on successful render and blit; False if CachePtr/document/main buffer/page size doesn't resolve, or the computed tile dimensions are non-positive.

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
[return: MarshalAs(UnmanagedType.Bool)]
Area
Rendering & Viewer
Category

Rasterizer/Rendering

Exported names

rasRenderTile

String variants

The …A form takes UTF-8, …W takes UTF-16; a bare name aliases the ANSI form.

See working code

Worked examples — complete programs in ten languages.