SceneImageRenderer Class
Draws the scenes of Meziantou.Framework.VectorGraphics (charts, diagrams) as images, or on a DrawingCanvas.
public static class SceneImageRendererRemarks
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
| Name | Description |
|---|---|
| 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.csCreates 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
optionsSceneImageOptions?- The options, or
nullfor the defaults.
Returns
ImageTextMeasurer The measurer.
DrawScene overloads
DrawScene(DrawingCanvas, ISceneSource, PointD, SceneImageOptions?)
SceneImageRenderer.csLays 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
canvasDrawingCanvas- The canvas.
sourceISceneSource- The chart or the diagram.
positionPointD- The top-left corner of the drawing.
optionsSceneImageOptions?- The options, or
nullfor 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.csDraws 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
canvasDrawingCanvas- The canvas.
sceneScene- The scene, laid out with
SceneImageRenderer.CreateMeasurerso its texts fit. positionPointD- The top-left corner of the drawing.
optionsSceneImageOptions?- The options, or
nullfor 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.csLays 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
sourceISceneSource- The chart or the diagram.
optionsSceneImageOptions?- The options, or
nullfor 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.csMeasures the rectangle that SceneImageRenderer.DrawScene covers.
public static RectangleD MeasureScene(Scene scene, SceneImageOptions? options = null)Parameters
sceneScene- The scene.
optionsSceneImageOptions?- The options, or
nullfor the defaults.
Returns
RectangleD The size of the drawing, as a rectangle located at the origin.
ToImage overloads
ToImage(ISceneSource, SceneImageOptions?)
SceneImageRenderer.csLays 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
sourceISceneSource- The chart or the diagram.
optionsSceneImageOptions?- The options, or
nullfor 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.csRenders 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
sceneScene- The scene, laid out with
SceneImageRenderer.CreateMeasurerso its texts fit. optionsSceneImageOptions?- The options, or
nullfor the defaults.
Returns
Image<Rgba32> A single-frame image. The caller owns it and must dispose it.
Exceptions
ArgumentOutOfRangeException- The image is too large.