Class SkiaSvgRasterizer
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
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
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
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
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
processedSvgstringSVG content with CSS classes already resolved to inline attributes.
areaFillAreaFillArea fill definition containing tiling vectors.
tileRectSKRectOn 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
nullif 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
processedSvgstringSVG content with CSS classes already resolved to inline attributes.
areaFillAreaFillArea fill definition containing tiling vectors.
pixelsPerMmdoublePixels-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
nullif the SVG cannot be rasterized.