Advanced Rendering Semantics

Loaded-page rendering preserves nested Form XObject state while applying transparency groups, soft masks, Type 3 glyph procedures, and resolution-aware visible image-region decoding

Transparency groups

Soft masks

Transfer and sampled functions

/TR2 takes precedence over /TR, a single function applies to every RGB output channel, and a four-function array applies its first three entries independently while preserving /Identity and /Default entries

Applying a new transfer state replaces every channel atomically, so identity entries cannot inherit lookup values from an earlier graphics state

Type 0 sampled functions support one to four input and output dimensions, /BitsPerSample values 1, 2, 4, 8, 12, 16, 24, and 32, reversed or forward /Encode mappings, independent /Decode ranges, multilinear interpolation, multidimensional cubic interpolation, and natural cubic splines for one-dimensional /Order 3 data

Decoded sample bytes, validated dimensions, mappings, and cubic derivatives share an eight-entry LRU capped at 64 MiB per rendering thread, while oversized or malformed functions fail without partially replacing the active transfer lookup table

Halftone screens

Type 6, Type 10, and Type 16 threshold arrays execute directly with exact decoded lengths, big-endian 16-bit thresholds, additive-component comparison, and compact periodic strips that avoid expanding angled or two-rectangle screens

Type 5 dictionaries select independent /Red, /Green, and /Blue screens with /Gray and required /Default fallbacks, while each selected screen can override the global transfer function

Validated threshold bytes and their normalized geometry share a 64-entry LRU capped at 64 MiB per renderer, and malformed dimensions, oversized allocations, nested Type 5 dictionaries, or payload-length mismatches leave the complete active screen state in continuous-tone mode

Type 3 glyphs

Type 3 CharProcs run through the complete content operator engine with the font dictionary's current resource scope, Form support, clipping, images, patterns, and bounded recursion

d0 and d1 provide glyph metrics while a d1 procedure keeps the caller-selected color as required by the PDF imaging model

Repeated CharProcs reuse decoded and tokenized display lists when font, glyph, linear device matrix, and color state match; translation remains dynamic so repeated characters at different positions share one entry

The per-renderer LRU retains at most 256 entries and 131,072 tokens, bypasses any CharProc above 16,384 tokens, and reports its behavior through GetLastType3GlyphCacheStats

Clipped and downscaled image regions

Axis-aligned image XObjects request only visible source bounds and pass the visible device-pixel size into the decode path

An image with a soft mask is decoded whole at the size it is drawn, and its mask at the same size, so the mask stays aligned with the image while clipping limits what is painted; JPEG masks use the reduced-size DCT decoder

When rendering, a decoded region at least twice the drawn size in both directions is shrunk to exactly the drawn size by area averaging before it is drawn or cached; a large image drawn small then fits the decode cache, so a group drawn twice or a repeated page reuses it, and its soft mask is applied pixel for pixel at that size. Stencil image masks keep their full resolution, and the public region-decoding methods return their documented sizes

JPEG 2000 combines the decoder's native region API with a power-of-two resolution level selected to meet both target dimensions before wavelet reconstruction and raster expansion

Tile-addressable JPEG 2000 codestreams can also decode one validated tile directly through THPDFJpeg2000Decoder.LoadTileFromByteArray, with tile-grid metadata and output-byte limits exposed by the decoder

When a native region intersects multiple independent tiles, LoadRegionFromByteArrayParallel assigns private OpenJPEG state per worker and composes completed rasters in deterministic row-major order; cancellation, output limits, and the effective peak-memory budget can stop scheduling or select the sequential fallback

Region := PDF.DecodeLoadedImageRegion(ImageStream, 128, 64, 640, 480);
try
  Canvas.Draw(0, 0, Region);
finally
  Region.Free;
end;

Related APIs