Ab2d.ReaderSvg是一個類庫,可以用來讀取svg和svgz(壓縮的svg)文件和導入它們的元素到任何的WPF應用程序。
Ab2d.ReaderSvg is a class library that can be used to read svg and svgz (compressed svg) files and import its elements into any WPF application.
Ab2d.ReaderSvg能夠準確地讀取在svg文件中定義的形狀,它們的一筆一畫,填充顏色和其他屬性。它可以讀取所有的漸變的類型,圖案和標記(線條開始和結束形狀)。它使得設計人員在幾乎所有的矢量繪圖應用程序中不需要手工定義他們的繪圖,保存它們為svg文件并應用程序開發人員們能夠在他們的WPF應用程序中使用這些繪圖。
在SVG文件中的元素可以被轉換成形狀或幾何圖形對象。這些形狀(畫布,橢圓,路徑等)是非常不錯的,因為它們可以簡單地被修改和為他們分配鼠標事件。幾何對象(GeometryDrawing, PathGeometry等)是形狀的一個輕量級的版本,它們具有更好的性能和更低的內存使用率,但操縱它們變得更困難。因此,圖形對象對復雜的繪圖是一個主意。并且更多的讀取幾何對象能夠為更好的性能被更高的優化。
例如下面一行XAML在顯示birthday_cake.svg都是需要的:
<ab2d:SvgViewbox Source="samples/birthday_cake.svg"/>
需要注意的是Ab2d.ReaderSvg不能在Silverlight應用程序中使用— 但是能在XBAP Web Browser應用程序中使用。對于Sileverlight使用ViewerSvg,我們可以在導出選項中選擇導出作為Silverlight xaml選項。
特點:
-
讀取svg和svgz(壓縮的svg)文件。
-
報春對象層次結構。
-
從id屬性或從標題元素獲得對象的名稱。
-
讀取嵌入的位圖圖像。
-
讀取形狀及其它們的屬性。
-
讀取線性和徑向漸變。
-
讀取圖案并轉換它們到VisualBrush.
-
讀取標記元素—線條開始和結束形狀(箭頭,等)
-
讀取使用和符號元素(也可用于嵌入式字體)
-
讀取clipPath元素
-
讀取svg文件中的元素作為形狀或作為幾何對象圖形(更好的性能)。
-
為了更好的性能優化讀取幾何圖形。
-
可選的轉換文本為路徑。
-
自動調整讀取內容的大小。
-
GetXaml方法用于獲得格式化的并有效的該被讀取對象的XAML。
-
從在Mirosoft Visio中創建的svg文件中讀取自定義的屬性和層數據。
-
包含有SvgViewbox和SvgDrawing控件,這些控件能夠在XAML中被使用。
The Ab2d.ReaderSvg can accurately read shapes defined in svg file, their strokes, fills and other properties. It can read all types of gradients, patterns and markers (line starting and ending shapes). This gives the designers free hands to define their drawings in almost any vector drawing application, save them into svg file and the application developers can than use the drawings in their WPF applications.
The elements in svg file can be converted into shapes or geometry objects. The shapes (Canvas, Ellipse, Path, etc.) are great because they can be simply modified and mouse events can be assigned to them. Geometry objects (GeometryDrawing, PathGeometry, etc.) are a lightweight version of shapes that have much better performance and lower memory usage but are harder to manipulate. Thereforeg graphics objects are ideal for complex drawings. And what is more the read geometry can be furher optimized for even better performance.
For example the following line of XAML is all that is needed to show birthday_cake.svg:
<ab2d:SvgViewbox Source="samples/birthday_cake.svg"/>
Note that Ab2d.ReaderSvg cannot be used in Silverlight applications - but can be used in XBAP Web Browser application. For Silverlight use ViewerSvg and select export as Silverlight xaml in the export options.
Features:
-
Read svg and svgz (compresses svg) files.
-
Preserve objects hierarchy.
-
Get name of the objects from id attribute or from title element.
-
Read embedded bitmap images.
-
Read shapes with their properties.
-
Read linear and radial gradients.
-
Read patterns and convert them into VisualBrush.
-
Read marker elements - line starting and ending shapes (arrows, etc.)
-
Read use and symbol elements (also used for embedded fonts).
-
Read clipPath elements.
-
Read elements in svg file as Shapes or as Geometries (better performance).
-
Optimize read Geometry for better performance.
-
Optionally convert text into Path.
-
Automatically resize the read elements.
-
GetXaml method to get formated and valid XAML of the read objects.
-
Read custom properties and layers data from svg files created in Microsoft Visio.
-
Included SvgViewbox and SvgDrawing controls that can be used in XAML.