Click or drag to resize
AB4D logo

ReaderSvgReadGeometry Method (Stream)

Reads svg or svgz file and returns System.Windows.Controls.Image with elements as Drawings (DrawingGeometry, EllipseGeometry, GlyphRunDrawing etc.) with no optimization.

Namespace:  Ab2d
Assembly:  Ab2d.ReaderSvg (in Ab2d.ReaderSvg.dll) Version: 7.1.7295.1040
Syntax
C#
public Image ReadGeometry(
	Stream stream
)

Parameters

stream
Type: System.IOStream
stream

Return Value

Type: Image
Image
Remarks

Drawing objects do not derive from the FrameworkElement class and provide a lighter-weight implementation for rendering shapes, images, and text. Because of this Drawing objects on one side lack support for Layout System, input, and focus, but on the other side have much better performance and lower memory consumption.

Returned Drawing has much better performance as Shapes that are returned with Read method.

If better layout support, input, focus and other functionality is needed use Read method instead that returns elements as Shapes.

It is also possible to optimize the read Drawing objects with the GeometrySettings objects that is passed to the ReadGeometry(String, GeometrySettings) method.

Examples
The following sample shows how to read svg file from Application's Resource (mySample.svg file is included into the project under cliparts folder and its build action is set to Resource):
Uri uri = new Uri("/cliparts/mySample.svg", UriKind.Relative);
using (Stream svgStream = Application.GetResourceStream(uri).Stream)
{
    clipartFromResource = Ab2d.ReaderSvg.Instance.ReadGeometry(svgStream);
}

myStackPanel.Children.Add(clipartFromResource);
See Also