The long awaited Ab2d.ReaderSvg update is available

by abenedik 9. April 2009 18:20

I am really excited to announce that the long awaited new version of ReaderSvg has been released.

The new version 3.0 is full of great new features and improvements. The most important is the support for Drawing objects (objects that derive from Geometry class - DrawingGeometry, StreamGeometry, etc.)

Previous versions of Ab2d.ReaderSvg returned the read svg files as Shapes (Path, Polyline, Ellipse, etc.). This was great when you needed to manipulate separate objects or add some mouse events to objects. The flexibility of Shapes has its cost when complex objects are shown - the performance could be very poor and memory consumption very high. WPF provides a much more efficient way to show more complex images - by using Drawing objects instead of Shapes.

With the new Ab2d.ReaderSvg it is possible to read the objects as Shapes (with the Read method) or as Drawings (with the new ReadGeometry method). And what is more, it is also possible to further optimize the drawing by using resources for similar Pens and Brushes and by combining geometries together (with passing the GeometrySettings to ReadGeometry method).

To make the usage of read svg objects simpler, there is also a ResourceDictionaryWriter sample applications that can produce complex ResourceDictionaries from svg files with just a few mouse clicks. The following screenshot shows SVG ResourceDictionaryWriter application with three svg files added to the ResourceDictionary (xaml of ResourceDictionary can be seen on the right):

Svg ResourceDictionaryWriter screenshot

The support for Drawing objects is just one of the improvements of the new version. Another very big improvement is much better performance of ReaderSvg - now reading svg files is almost as fast as parsing xaml with XamlReader.

Here is the full list of changes:

  • Added Drawing objects support:
    new ReadGeometry method with support for advanced geometry optimization and use of resources (Burshes and Pens are defined in resources).
    new ResourceDictionaryWriter class and sample SampleResourceDictionary aplication to simplify creating resources from the svg files
  • Added SvgDrawing control to show svg file as geometries in xaml
  • Greatly improved performance on svg files where path elements have a lot of segments.
  • Added GetXaml method to get the xaml of the read objects (also used in ViewerSvg; it is much more accurate as System.Windows.Markup.XamlWriter.Save)
  • Added GetObjectName method - gets the name of the object. If object does not have a name defined returns null
  • Optimized the output xaml for Path element - now the properties with default values are no longer displayed. This in most cases removes the following properties: StrokeStartLineCap, StrokeEndLineCap, StrokeDashCap, StrokeLineJoin, StrokeMiterLimit, StrokeDashOffset
  • Added support for gradientTransform on radialGradient
  • Added support for known colors in xaml writter - known colors like Black, Yellow can now be written with its name instead of hex display (#FF000000). This feature is used by default but can be disabled with setting UseColorNames in XamlWriterSettings to false.
  • Fixed propagating text styles to child tspan elements (for example if text has underline decoration set, underline will be used also on the child tspan elements - if not overwritten by different text-decoraton)
  • The path is now automatically closed when the last segment ends on the same position as the start segment. Before if the paths were not manually closed, there could be some sharp edges on some parts of the path.
  • Improved setting the size of returned Viewbox.
    If AutoSize is false the returned Viewbox has the size that is defined in the svg file. The previous version did not set the size correctly.
    If the svg width and height are specified in cm, mm or inches the output size in xaml is set in cm.
  • Added AutoSize property to SvgViewbox and SvgDrawing
  • Added support for bitmap patterns - used as background textures
  • Added BitmapImages property that contains all the bitmaps read with ReaderSvg (also contains images embedded into the svg file)
  • Added ReadPathAsPathGeometry property - If false (default) the path is read as StreamGeometry (better performance). If true the path is read as PathGeometry (worse performance but path can be modified).

IMPORTANT NOTE:

Because of so many changes, it is possible that some of the applications that are using Ab2d.ReaderSvg need to be changed. Please consider the following two issues:

NamedObject dictionarty is changed from Dictionary<string, FrameworkElement> to Dictionary<string, object>. This change was added so the NamedObject property can be also used when svg file was read as Geometry. ReadGeometry method returns objects that are not derived from FrameworkElement. So the type change was needed. It would be also possible to define a new dictionary, but this would only postpone the change - in the future all the readers would implement the same interface and there will be room for only one named objects dictionary. This change could mean that the code that is using the NamedObject must be changed. If only the Read method is used (and not ReadGeometry), than the following code can be used:
FrameworkElement element = myReaderSvg.NamedObject["myObject"] as FrameworkElement;

Another change is that by default all paths are now read as StreamGeometry (before they were read as PathGeometry). This greatly improves the performance of reading svg file and drawing objects in WPF. But if your code expects the PathGeometry, the default behavior would throw a runtime exception. To avoid this, you can change your code to support StreamGeometry or set the new ReadPathAsPathGeometry property on ReaderSvg to true.

The ViewerSvg application has also been updated to support the new features of ReaderSvg. The following screenshot shows the new export dialog (notice the new geometries and new export images options):

ViewerSvg Export Dialog

The new version can be downloaded from my Downloads page.
After downloading just install the new version over the previous version (no need to uninstall).

Tags: , , ,

ReaderSvg

Updated ZoomPanel control

by abenedik 6. March 2009 23:56

I am happy to announce that the ZoomPanel control has been updated. The following is a list of new features:

  • Added support for WPF Browser applications. There is also a new sample that demonstrated this.
  • Added Viewbox property - Gets or sets the current viewbox as Rect used to determine which part of ZoomPanel's content is shown.
  • Fixed problems when the ZoomPanel content was empty and zoom buttons on ZoomControler were used.
  • Fixed some problems with licensing and evaluation.
  • Added TargetZoomPanelName property to ZoomController - the ZoomPanel that is controller with ZoomController can now be specified by its name (no need for DataBinding on TargetZoomPanel property any more)
  • Added automatic discovery of ZoomPanel on ZoomController. This means setting TargetZoomPanelName or TargetZoomPanel is not needed anymore. The ZoomController will automatically find the ZoomPanel. So everything you need to do is simply drag and drop ZoomPanel and ZoomController from the Toolbox on the Design Surface.

ZoomPanel control

More info about the best zoom and pan control for WPF can be found here.

The new version 1.2 can be downloaded from my Downloads page.

Tags: , , ,

ReaderWmf

A bunch of additional improvements available

by abenedik 31. January 2009 20:36

I have got some great test svg files and some very helpful user feedback. This lead to the following improvements in Ab2d.ReaderSvg:

  • Added AutoSize property. If its value is true (default - as previous version) the size of returned Canvas is calculated from the size of objects it contains. This is useful if you do not care whether the objects were drawn on the Letter or A4 page - you just need the returned object to be as big as its containg objects. If AutoSize is false the size defined in svg element is used for the size of returned Canvas. This is useful if you were working on a Letter page and would like to preserve the positions of objects inside the Letter area.
  • Improved measuring of objects when AutoSize is true (now transformed elements are correctly measured).
  • Improved ellipse - before svg ellipse was converted into Path WPF element - now it is converted into Ellipse WPF element
  • Added reading elements inside svg link element (before the whole element was skipped). Linking is not supported, but its content is now rendered.
  • Added support for underline and line-through text decorations.
  • Improved processing of text and tspan svg elements.
  • Added help file.

The ViewerSvg has been also improved to support new AutoSize property. Now it also has an automatic error reporting - when an exception occurs in ViewerSvg or Ab2d.ReaderSvg, user can now submit error information to help resolve the problems.

The new automatic error reporting is now part of new Paste2Xaml as well.

To install the new version, download the installer from my Downloads page and simply install it over the previous version (no need to uninstall).

Tags: , , , , ,

ReaderSvg | ReaderWmf

Ab2d.ReaderSvg library improved

by abenedik 4. January 2009 20:34

Ab2d.ReaderSvg library has been improved.

The list of changes is not long. I needed some new functionality for importing text. The previous version has also some problems with importing rectangles. This is a list of changes for version 2.2:

  • Added support for FontWeight and Italic FontStyle.
  • Added support for Rotate in Tspan (for Text on Path).
  • Fixed fill and stroke brush for Rectangle element.
  • Removed RunWithDeveloperLicense Dialog (shown when commercial license is installed, but the application did not have an embedded license.licx file).

The new version is available on https://www.ab4d.com/ReaderSvg.aspx.

Tags: , , ,

ReaderSvg

New version of ViewerSvg and Ab2d.ReaderSvg available

by abenedik 12. December 2008 19:30

I am happy to announce that the new version of ViewerSvg and Ab2d.ReaderSvg is available.

ViewerSvg

The new Ab2d.ReaderSvg library is now even better. The following is a list of new features and improvements:

  • Fixed resolving external references in svgz files.
  • Fixed positioning bitmap images.
  • Adjusted LinearGradientBrush to show correctly in WPF.
  • Added support for MappingMode in LinearGradientBrush.
  • Added reading elements inside switch element (before switch was skipped).
  • Improved evaluation mode.

ViewerSvg application has also been improved. Now it is using my ZoomPanel.

Most of the improvements are based on great user feedback. I am grateful for it. So if you find any file that is not read correctly you are most welcome to upload it on my Feedback page.

Unfortunately I did not have time to implement support for Geometry and its optimization as it is done in Ab2d.ReaderSvg. But this feature is very high on my priority list and will be surely implemented soon.

The new version is available from https://www.ab4d.com/ViewerSvg.aspx.

Tags: , , ,

ReaderSvg

New Ab2d.ReaderWmf support Drawing objects with advanced optimization

by abenedik 5. December 2008 00:45

I am really excited to inform you about new features of the new Ab2d.ReaderWmf v3.0 library.

Previous versions of Ab2d.ReaderWmf read metafiles and returned them as Shapes (Path, Polyline, Ellipse, etc.). This was great when you needed to manipulate separate objects or add some mouse events to objects. This flexibility with Shapes has its cost when complex objects are shown - the performance could be very poor and memory consumption very high.

WPF provides a much more efficient way to show more complex images with Drawing objects - objects that derive from Geometry class - DrawingGeometry, StreamGeometry, etc. The new version of Ab2d.ReaderWmf provides a ReadGeometry method that returns drawing objects (the Read method returns Shapes). And this is not all - it is possible to further optimize the drawing by using resources for similar Pens and Brushes and by combining geometries together..

The following two graphs show how the load time and the memory usage are decreased when optimized Drawing objects are used. Results are based on a complex dwg (AutoCAD) file that was converted to metafile and exported to xaml with Paste2Xaml with different export options.

geometry load time
geometry memory usage

The results show that it is possible that the load time decreases for more than 10 times and the memory usage for more than 5 times. This is especially true for metafile with lots of objects that have same pen or brush. The results are best on files created from AutoCAD or other CAD or vector drawing application. Cliparts and other types of metafiles also have significant performance improvement.

Heavy optimization of course has its side effects. If geometries are be combined, they cannot be manipulated individually. It is possible that with full optimization, some animalied appear on image. Because of this, it is possible to fine tune the optimization with lots of advanced options and find the right balance between usability and performance.

The following two screenshots show the new Paste2Xaml application and its new Export dialog:

Paste2Xaml
Paste2Xaml ExportDialog

And there is more new to show. The next new feature is support for building ResourceDictionaries from many metafiles. ResourceDictionaryWriter class can be used to simplify this job. And to make this even simpler there is also a sample application with full source code that on one side shows how to use the ResourceDictionaryWriter and on the other side provides really easy to use application to create ResourceDictionaries. The following image shows the ResourceDictionaryWriter application:

ResourceDictionaryWriter

The list of new features is not over. Here is also a GetXaml method that gets the xaml text of the last read metafile. This method is needed because the WPF's XamlWriter does not correctly write some elements and is also not useful for naming elements and writing ResourceDictionaries.

That is quite a bunch of new features, isn't it?

So to conclude. The new version of Ab2d.ReaderWmf library not only enables you to convert almost any image from almost any vector drawing application into xaml, but also enables you to choose between Shapes and optimized Drawing objects and also enables you to package all those objects into a ResourceDictionary.

The only thing left to say is to invite you to try the 60 days evaluation version. It is available from https://www.ab4d.com/Paste2Xaml.aspx.

Tags: , , ,

ReaderWmf

Commercial versions of Ab2d.ReaderSvg and Ab2d.ReaderWmf available

by abenedik 8. August 2008 10:40

I am happy to announce that the commercial versions of Ab2d.ReaderSvg and Ab2d.ReaderWmf are available.

The purchase can be done on https://www.ab4d.com/Purchase.aspx.

As rss subscriber I give you 10% launch discount.
For ReaderSvg enter "ReaderSvgRss" as a discount code on the Purchase page. For ReaderWmf enter "ReaderWmfRss"

The discount is valid only until the end of August 2008.

Tags: , , , , ,

ReaderSvg | ReaderWmf