ReaderSvgTransformFromPixelsToMM Method |
Namespace: Ab2d
public Viewbox TransformFromPixelsToMM( int dpi, bool updateLastReadViewbox )
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.