Skip to main content

render_png

Function render_png 

Source
pub fn render_png(
    scene: &Scene,
    fonts: &dyn FontProvider,
    assets: &dyn AssetProvider,
) -> Result<Vec<u8>, RenderError>
Expand description

Rasterize scene and encode the result as PNG bytes.

Uses the TinySkiaBackend internally. The output is deterministic: the same scene always produces identical bytes.

The fonts parameter is used to resolve font bytes for any zenith_scene::SceneCommand::DrawGlyphRun commands in the scene; the assets parameter resolves raster image bytes for any zenith_scene::SceneCommand::DrawImage commands. Runs/images whose id cannot be resolved are silently skipped.

ยงErrors

Returns RenderError when the scene dimensions are invalid or PNG encoding fails.