Click or drag to resize
AB4D logo

ReaderSvgTransformFromPixelsToMM Method

TransformFromPixelsToMM method transforms all the coordinates, sizes and other values in the last read Viewbox in such a way that it converts all units in pixels into millimeters with using specified dpi setting.

Namespace:  Ab2d
Assembly:  Ab2d.ReaderSvg (in Ab2d.ReaderSvg.dll) Version: 7.1.7295.1040
Syntax
C#
public Viewbox TransformFromPixelsToMM(
	int dpi,
	bool updateLastReadViewbox
)

Parameters

dpi
Type: SystemInt32
Dots per inch setting (for Inkscape use 90)
updateLastReadViewbox
Type: SystemBoolean
if true than LastReadViewbox is also changed. This allows calling GetXaml method and get the xaml with the transformed objects.

Return Value

Type: Viewbox
transformed Viewbox
Remarks

Some drawing applications (for example Inkscape) allows user to draw with using real units (for example mm). But when the drawing is saved into svg file, it is converted into pixel units. The TransformFromPixelsToMM method can convert the units used in svg file back to the unints that were used when creating the drawing.

The method needs a dpi (dots per inch) parameter. For files created with Inkscape 90 should be used. Note that it is possible to get the application that was used to create the svg file with SvgCreator property.

This method is using Transform(Transform, Boolean) method. It creates the ScaleTransform with specifying the scale as:
scale = 25.4 / (double)dpi; // 25.4 mm in one inch

If the method is called with setting updateLastReadViewbox parameter to true, than the LastReadViewbox is also changed. This allows calling GetXaml method and get the xaml with the transformed objects.

See Also