Converts an SVG string into a pixel buffer suitable for uploading as an OpenGL texture.
Rasterization is performed by LunaSVG (MIT-licensed). The SVG is scaled uniformly to fit the requested DtBitmapData dimensions; the caller controls the output resolution by constructing DtBitmapData with the desired width and height before calling rasterize().
Output pixel format is straight RGBA (GL_RGBA / GL_UNSIGNED_BYTE), top-down row order. The class has no instance state; all methods are static.
| static bool makVrv::DtSvgRasterizer::rasterize |
( |
const std::vector< std::string > & |
svgLayers, |
|
|
DtBitmapData & |
bitmapData |
|
) |
| |
|
static |
Rasterize a stack of SVG documents into one pre-allocated RGBA pixel buffer.
Layer 0 is the base document; each subsequent document is composited over it in order using source-over alpha blending in premultiplied space. Each layer is scaled independently with a uniform fit-to-bitmap scale (the minimum of the width and height ratios) and rendered from the bitmap's top-left corner. The premultiplied-to-straight-RGBA conversion happens exactly once, after the final layer.
All documents are parsed before any pixel is written: on any failure (empty list, zero bitmap dimensions, or a layer that fails to parse) the method returns false and the bitmap content is untouched.
- Parameters
-
| svgLayers | SVG XML documents to rasterize, base (bottom) layer first. |
| bitmapData | Output bitmap; must be constructed with the desired width and height so that pixels is pre-allocated to width * height * 4 bytes before this call. On success the pixels are filled with straight RGBA data, top-down row order. |
- Returns
- true on success; false if svgLayers is empty, if bitmapData dimensions are zero, or if LunaSVG fails to parse any layer.