SceneImageRenderer Class

Draws the scenes of Meziantou.Framework.VectorGraphics (charts, diagrams) as images, or on a DrawingCanvas.

public static class SceneImageRenderer

Remarks

A source is laid out with the fonts that draw it (ImageTextMeasurer), so its texts fit. Save the image in any format: image.Save("drawing.png").

Methods

NameDescription
CreateMeasurer(SceneImageOptions?)Creates the text measurer of the fonts of the options (SceneImageOptions.Fonts, or the fonts of each style), to lay a source out with ISceneSource.CreateScene.
DrawScene(DrawingCanvas, ISceneSource, PointD, SceneImageOptions?)Lays a source out with the fonts of the options and draws it on a canvas, as vector shapes and text.
DrawScene(DrawingCanvas, Scene, PointD, SceneImageOptions?)Draws a scene on a canvas, as vector shapes and text.
MeasureScene(ISceneSource, SceneImageOptions?)Lays a source out with the fonts of the options and measures the rectangle that SceneImageRenderer.DrawScene covers.
MeasureScene(Scene, SceneImageOptions?)Measures the rectangle that SceneImageRenderer.DrawScene covers.
ToImage(ISceneSource, SceneImageOptions?)Lays a source out with the fonts of the options and renders it as an image of its size times SceneImageOptions.Scale, rounded up.
ToImage(Scene, SceneImageOptions?)Renders a scene as an image of its size times SceneImageOptions.Scale, rounded up.

CreateMeasurer(SceneImageOptions?)

SceneImageRenderer.cs

Creates the text measurer of the fonts of the options (SceneImageOptions.Fonts, or the fonts of each style), to lay a source out with ISceneSource.CreateScene.

public static ImageTextMeasurer CreateMeasurer(SceneImageOptions? options = null)

Parameters

options SceneImageOptions?
The options, or null for the defaults.

Returns

ImageTextMeasurer The measurer.

DrawScene overloads

DrawScene(DrawingCanvas, ISceneSource, PointD, SceneImageOptions?)

SceneImageRenderer.cs

Lays a source out with the fonts of the options and draws it on a canvas, as vector shapes and text.

public static RectangleD DrawScene(this DrawingCanvas canvas, ISceneSource source, PointD position, SceneImageOptions? options = null)
Parameters
canvas DrawingCanvas
The canvas.
source ISceneSource
The chart or the diagram.
position PointD
The top-left corner of the drawing.
options SceneImageOptions?
The options, or null for the defaults.
Returns

RectangleD The rectangle the drawing covers.

Remarks

The drawing is drawn in the coordinates of the canvas, so the transform, clip and layers of the canvas apply.

DrawScene(DrawingCanvas, Scene, PointD, SceneImageOptions?)

SceneImageRenderer.cs

Draws a scene on a canvas, as vector shapes and text.

public static RectangleD DrawScene(this DrawingCanvas canvas, Scene scene, PointD position, SceneImageOptions? options = null)
Parameters
canvas DrawingCanvas
The canvas.
scene Scene
The scene, laid out with SceneImageRenderer.CreateMeasurer so its texts fit.
position PointD
The top-left corner of the drawing.
options SceneImageOptions?
The options, or null for the defaults.
Returns

RectangleD The rectangle the drawing covers.

Remarks

The scene is drawn in the coordinates of the canvas, so the transform, clip and layers of the canvas apply.

MeasureScene overloads

MeasureScene(ISceneSource, SceneImageOptions?)

SceneImageRenderer.cs

Lays a source out with the fonts of the options and measures the rectangle that SceneImageRenderer.DrawScene covers.

public static RectangleD MeasureScene(ISceneSource source, SceneImageOptions? options = null)
Parameters
source ISceneSource
The chart or the diagram.
options SceneImageOptions?
The options, or null for the defaults.
Returns

RectangleD The size of the drawing, as a rectangle located at the origin.

Remarks

The size of a diagram depends on its texts, so the source is laid out as for drawing it.

MeasureScene(Scene, SceneImageOptions?)

SceneImageRenderer.cs

Measures the rectangle that SceneImageRenderer.DrawScene covers.

public static RectangleD MeasureScene(Scene scene, SceneImageOptions? options = null)
Parameters
scene Scene
The scene.
options SceneImageOptions?
The options, or null for the defaults.
Returns

RectangleD The size of the drawing, as a rectangle located at the origin.

ToImage overloads

ToImage(ISceneSource, SceneImageOptions?)

SceneImageRenderer.cs

Lays a source out with the fonts of the options and renders it as an image of its size times SceneImageOptions.Scale, rounded up.

public static Image<Rgba32> ToImage(this ISceneSource source, SceneImageOptions? options = null)
Parameters
source ISceneSource
The chart or the diagram.
options SceneImageOptions?
The options, or null for the defaults.
Returns

Image<Rgba32> A single-frame image. The caller owns it and must dispose it.

Exceptions
ArgumentOutOfRangeException
The image is too large.

ToImage(Scene, SceneImageOptions?)

SceneImageRenderer.cs

Renders a scene as an image of its size times SceneImageOptions.Scale, rounded up.

public static Image<Rgba32> ToImage(this Scene scene, SceneImageOptions? options = null)
Parameters
scene Scene
The scene, laid out with SceneImageRenderer.CreateMeasurer so its texts fit.
options SceneImageOptions?
The options, or null for the defaults.
Returns

Image<Rgba32> A single-frame image. The caller owns it and must dispose it.

Exceptions
ArgumentOutOfRangeException
The image is too large.