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
- Form XObject
/Matrixvalues are composed with the current transformation matrix before group content runs - Isolated groups use a separate alpha plane so black content remains distinguishable from transparent pixels
- Knockout groups replace the previous group contribution in overlapping painted areas
- Group content starts from the Normal blend mode: the blend mode, constant alpha, and soft mask in force at
Doapply to the group as a whole - A group painted with another blend mode blends its own color and alpha with the backdrop; a non-isolated group whose own graphics states blend normally is drawn on black and on white to recover its alpha
- Groups are split into bounded 768-pixel tiles while GDI painting, halftone phase, nested groups, soft masks, and compositing retain absolute device coordinates
- Form bytes are decoded and tokenized once before tile execution, and temporary tile-local masks are released before the next tile
- Nested groups are supported with bounded recursion and complete graphics-state restoration after every Form invocation
Soft masks
/S /Alphaand/S /Luminositymasks are evaluated from the mask group- The mask group is drawn with Normal blending, whatever blend mode the graphics state that sets the mask carries
- Luminosity masks resolve the transparency group
/CSand weight the resolved color with the PDF DeviceGray approximation, as common viewers do; setRenderColorimetricLuminosityMasksto take colourimetric CIE Y for CIE-based spaces instead /BCis validated against the exact blending-space component count and supplies the converted luminosity outside painted mask content- Separation and DeviceN paint is converted through its alternate Lab or ICCBased space so spot components never leak into a soft mask
/TRtransfer functions support sampled, exponential, stitching, and PostScript calculator functions through the shared function evaluator/SMask /Noneclears the active mask andqorQpreserves mask state normally- Compiled masks are reused only when the source dictionary, current transformation matrix, and rendering intent all match
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;