Table of Contents

Class SkiaSvgRasterizer

Namespace
EncDotNet.S100.Renderers.Skia
Assembly
EncDotNet.S100.Renderers.Skia.dll

Rasterizes processed S-100 SVG symbols into tiled pattern bitmaps using SkiaSharp.

public static class SkiaSvgRasterizer
Inheritance
SkiaSvgRasterizer
Inherited Members

Fields

DefaultPixelsPerMm

Intended on-screen pixels-per-mm density of a pattern tile, i.e. the effective size at which a tile is drawn after the renderer applies PatternTileShaderScale. S-100 defines pattern dimensions in mm for paper charts (~3.78 px/mm at 96 DPI). For interactive display a lower density is used so patterns repeat more tightly relative to the on-screen polygon size.

public const double DefaultPixelsPerMm = 1.5

Field Value

double

PatternTileRenderPixelsPerMm

Density at which pattern tiles are actually rasterized (the on-screen density supersampled by PatternTileSupersample). This is the default for RasterizePatternTile(string, AreaFill, double).

public const double PatternTileRenderPixelsPerMm = 6

Field Value

double

PatternTileShaderScale

Scale a renderer must apply to a tile shader so a tile rasterized at PatternTileRenderPixelsPerMm is drawn at its intended on-screen size (DefaultPixelsPerMm). Equal to 1 / PatternTileSupersample.

public const double PatternTileShaderScale = 0.25

Field Value

double

PatternTileSupersample

Supersampling factor applied when rasterizing pattern tiles. Tiles are rendered at PatternTileRenderPixelsPerMm (this factor times DefaultPixelsPerMm) and then scaled back down to their on-screen size by the renderer via PatternTileShaderScale. Rendering above the on-screen density keeps tiles crisp when the shader is sampled at fractional offsets and on HiDPI/Retina surfaces, where a tile rasterized at the on-screen density alone would be upsampled and appear blurry.

public const double PatternTileSupersample = 4

Field Value

double

Methods

BuildPatternTilePicture(string, AreaFill, out SKRect)

Builds a pattern tile as a resolution-independent SKPicture recorded in millimetre units (1 unit = 1 mm) rather than a fixed-resolution bitmap. Tiling the picture via a picture shader (ToShader(SKShaderTileMode, SKShaderTileMode, SKFilterMode, SKMatrix, SKRect)) lets Skia re-rasterize the tile to match the canvas transform on every draw, so the pattern stays crisp at any zoom level and on HiDPI/Retina surfaces — unlike a pre-rasterized bitmap tile, which is upsampled and appears blurry. Used by the interactive renderer.

public static SKPicture? BuildPatternTilePicture(string processedSvg, AreaFill areaFill, out SKRect tileRect)

Parameters

processedSvg string

SVG content with CSS classes already resolved to inline attributes.

areaFill AreaFill

Area fill definition containing tiling vectors.

tileRect SKRect

On return, the tile's repeat rectangle in millimetres (origin at 0,0). The renderer tiles the shader over this rectangle and scales it to the desired on-screen pixels-per-mm density.

Returns

SKPicture

The recorded tile picture, or null if the SVG cannot be parsed.

RasterizePatternTile(string, AreaFill, double)

Rasterizes a processed SVG pattern into a repeating tile bitmap, encoded as a PNG byte array.

public static byte[]? RasterizePatternTile(string processedSvg, AreaFill areaFill, double pixelsPerMm = 6)

Parameters

processedSvg string

SVG content with CSS classes already resolved to inline attributes.

areaFill AreaFill

Area fill definition containing tiling vectors.

pixelsPerMm double

Pixels-per-mm density for the output tile. Defaults to PatternTileRenderPixelsPerMm (supersampled); the renderer is expected to compensate with PatternTileShaderScale.

Returns

byte[]

PNG-encoded tile bytes, or null if the SVG cannot be rasterized.