All AB4D libraries improved with new licensing code and many new features

by abenedik 26. April 2016 21:39

I would like to inform you that today new versions of all the AB4D products have been published.

The main reason for this release is that the evaluation and commercial licensing code that is included in all the products have been greatly improved. What is more, the deployment script that I use to prepare all release version have been improved.

Also, all the products got some additional functionality or fixed bugs. For example, the following image shows new ViewCubeCameraController from Ab3d.PowerToys library:

3D ViewCube in Ab3d.PowerToys library

The main benefits of the new licensing and deployment are:

  • All products are now also compiled for .Net 4.5 target framework. This means that all products are available for .Net 3.5, .Net 4.0 and also .Net 4.5 (an exception is Ab3d.DXEngine that does not support .Net 3.5). This will allow using new language features in the libraries – especially async and await support.
  • New evaluation and commercial licensing code is now faster and required less resources.
  • New evaluation code allows starting ad-hock evaluation on a computer that do not have the evaluation version installed. This means that you will be able to create a sample project with an evaluation version and then just copy your application to another computer. At the first start of your application you will get a dialog to start a new evaluation and then be able to continue running your application. In the previous version you needed to install evaluation version on the other computer too.
  • Improved commercial licensing code that brings new options to embed license key into your project and allows using special license key for application. This simplifies compiling projects on cloud base build servers and allows some other non-standard distributions. More details about that can be found in the new “Using commercial version” help file.

The new version also introduces new directory structure that is created after the libraries are installed. In the previous version the libraries for .Net 3.5 framework were installed into “bin” folder and libraries for .Net 4.0 framework were installed into “bin\.Net 4” folder. Now the organization is much more standard: the .Net 3.5 assemblies are in “bin\net35” folder, .Net 4.0 assemblies are in “bin\net40” folder and .Net 4.5 assemblies are in “bin\net45” folder.

This means that you might need to update your references.

The new .Net 4.5 versions of the libraries will allow using async keywords. Currently this has not yet been added to any of the libraries. But in the near future I plan to add support for async to all of the libraries. For example, async loading of 3D models or svg files. Another possibility is to create async methods to animate camera or ZoomPanel.

 

As mentioned before, this release also brings other improvements and fixes.

Ab3d.PowerToys got some great new features. The most highly anticipated feature is the ability to control the camera with 3D cube. The image with three possible cubes was shown before.

Another great addition to the library are new TubePathVisual3D and TubePathMesh3D that allows creating various tube based objects:

3D tube path in Ab3d.PowerToys library

The following is a full list of new features in Ab3d.PowerToys library

  • Added ViewCubeCameraController.
  • Added TubePathVisual3D and TubePathMesh3D.
  • Added support to create extruded MeshGeometry3D that has custom orientation (not only in the direction of Y axis). This can be achieved with using a new override of CreateExtrudedMeshGeometry that also takes shapeYVector parameter.
  • Added IsStartPositionClosed and IsEndPositionClosed properties to TubeLineVisual3D. Also added additional isStartPositionClosed and isEndPositionClosed constructor parameters to the TubeLineMesh3D.
  • Added FreezeMeshGeometry3D to BoxVisual3D and SphereVisual3D to control if the MeshGeometry3D is frozen.
  • Improved TubeVisual3D that now allows setting Height to 0 - this creates an optimized TubeVisual3D without creating both bottom and top ring - in this case only bottom ring is created.
  • Fixed using adjustmentFactor in FitIntoView method.
  • Fixed using FitIntoView when it is called in Loaded method and the Viewport3D is shown in Ab3d.DXEngine.
  • Fixed type used by ShowMovablePlanes property.
  • Improved MouseCameraController to capture the mouse only when the mouse rotation / movement is bigger than a few pixels. This prevents "swallowing" MouseUp event for processing mouse click in EventManager3D.
  • Added UsePreviewEvents property to EventManager3D – when set to true the EventManager3D subscribes to Preview mouse and touch events instead of standard events - for example PreviewMouseUp event instead of MouseUp event. This can be used to use left mouse button for camera rotation and also for click events.
  • Added TurnTo method to FirstPersonCamera - this turns the camera towards the specified position or to the specified direction vector.
  • CameraControlPanel now moves the FirstPersonCamera forward or backwards when ZoomIn or ZoomOut buttons are clicked.
  • When MouseCameraController is used for FirstPersonCamera the mouse wheel now moves camera forward and backwards.

The library also got a few new samples. Two are to demonstrate the ViewCubeCameraController and TubePathVisual3D. There is also a greatly improved FirstPersonCamera sample that also shows how to turn the camera toward the clicked object. Another new sample shows how to create an application where user can draw to a 3D texture – for example to write annotation to a 3D height map.

 

Ab2d.ReaderSvg library that can read svg files also got many new features. 

The new version now supports textPath element that can render text on a path:

Support for svg textPath element in Ab2d.ReaderSvg

Another very interesting new feature is the new GetElementSvgText method that returns the outer xml text of the specified element. This can be very useful when you add some special attributes or elements to the svg elements. If those elements are not standard svg elements, then ReaderSvg cannot read them. But with using GetElementSvgText you can get the xml text from the specified element and then parse the data out of the xml.

The following is a list of all new features:

  • Added support for textPath elements (positioning text on a path).
  • Added GetElementSvgText to get the svg text of the element with the specified id (can be used to read some additional svg properties that are not read by ReaderSvg).
  • Added support for dx and dy properties on the text element.
  • Fixed writing new line characters in XAML.
  • Added support for vertical text (glyph-orientation-vertical svg property).
  • Improved writing images in XAML that are now written in more clear XAML. Also fixed setting Source for images that are created from foreign objects.
  • Added support for reading number lists that end with comma - for example "12, 34, 56," - this prevented reading svg file in the previous version.
  • Improved support for rounder corners on rectangles in case when only rx or only ry is specified - in this case the other value is set to the same value.

 

Other libraries got only a few updates.

For example, the Ab3d.DXEngine library does not have any new feature in the core libraries but there are three new samples that show how to use standard DirectX rendering code inside DXEngine. The samples show how to render 3D cube with SharpDX code, use the camera and camera controller from Ab3d.PowerToys and mix the rendered 3D cube with other 3D objects from Ab3d.PowerToys library.

Ab2d.ReaderWmf got the following new features:

  • Improved reading images with negative scale transformations.
  • Improved positioning text for some special use cases (correctly position text based on the TextAlign mode).
  • Fixed ResourceDictionaryWriter so that the ResolveResourceKeyCallback is called also for root keys.

 

ZoomPanel library was only slightly improved – the number of history items was increased to 100.

Also Ab3d.Reader3ds got only one improvement. The support for reading broken 3ds files has been improved so that some invalid positions that are not used in TriangleIndices are fixed. This prevents creating too big bounds value that is usually used to position the camera after the model is loaded. 

 

I am really excited about this release. It improves many aspects of the libraries that are not related to the core functionality but are needed because of licensing. It also enables many new features that are possible with .Net 4.5 and allows creating more user friendly APIs with async methods.

Tags: , , , , ,

Ab3d.PowerToys | DXEngine | Reader3ds | ReaderSvg | ReaderWmf | ZoomPanel

Updated version of Ab2d.ReaderSvg published

by abenedik 21. July 2015 23:26

I am happy to inform you that I have just published a new version of Ab2d.ReaderSvg.

This version brings the following new features and improvements:

  • Added support for using polygon as clip-path.
  • Improved transforming shapes and brushes.
  • Prevented applying opacity twice - to alpha value in color and to Opacity property on element.
  • Added support for "fill-opacity" and "stroke-opacity" attributes.
  • Fixed ResourceDictionaryWriter so that the ResolveResourceKeyCallback is called also for root keys.
  • Used black as default fill color (when fill is not specified).
  • Prevented stretching geometry under some circumstances when svg file was read as geometry.

Tags: ,

ReaderSvg

Improved creating ResourceDictionaries from svg files in new version of Ab2d.ReaderSvg

by abenedik 28. January 2015 20:31

I am happy to announce that the best svg reader for .Net has been improved.

I am also happy that I have not received any svg file that would not be read correctly for very long time. This means that the reader very accurately converts the files to WPF object. So this part of the ReaderSvg did not get any upgrade.

The improvements in this update are focused on what you can do when you have the svg file in WPF objects tree. 

The main new improvement is better support for creating ResourceDictionaries from multiple svg files. ResourceDictionaries can be created with using ResourceDictionaryWriter application. The application is available with full source code and therefore it can be fully customized. The following is a screenshot of the new version of the application:

That screenshot was created after we have added two svg files for ResourceDictionary – one was home6.svg and the second was birthday_cake.svg. This can be seen from the left panel where images of both read files are seen. On the right side you can see the ResourceDictionary XAML.

As you see the SolidColorBrushes and Pens have been also specified as resources. This means that you can simple change the brush or pen with changing the resource value.

With the new version of ResourceDictionaryWriter application it is possible to specify when the SolidColorBrushe or Pen are written to resources and when they are defined as attributed for the elements. The screenshot shows an option that specifies that SolidColorBrushes and Pens are written to resources when they are used 2 times or more. So for example in the pre-last line of the XAML you can see that the GeometryDrawing is using a White brush. Because this brush is still defined as attribute, this means that this brush is used only once. If it would be used 2 times, it would be specified as resource. The application allows you to specify to always use resource, to never use resources and also allows you to specify a few options in between (with changing the source code you can use any possible option).

An improvement of the new version is that when importing objects as Shapes it is also possible to write Brushes are resources (before this was possible only for Geometries).

It is also possible to specify whether the objects will be written as Shapes (Canvas, Path, Rectangle, Ellipse, etc.) or as Geometry objects (as shown in the screenshot). Advantage of Shapes is that they are simpler to use and manipulate. The Geometry objects on the other hand are much lower lever objects and are harder to manipulate but have better performance and use less memory.

ResourceDictionaries are a very useful concept in WPF and I hope that with the improvements in this version it will be easier to create them.

 

Another improvement of the new version is with using RenderToBitmap method. Now it is possible to also specify custom dpi settings for the created bitmap. I have also fixed an issue where all objects were scaled to the border of the image the svg file was read with AutoSize set to false and we specified a custom sized bitmap.

After adding dpi support to RenderToBitmap method I have also improved SvgToPngConverter (sample console application) and added dpi and some other settings to it.

Also the main ReaderSvg samples have been improved. They now use custom control (TextBlockEx) to show information about each section of samples. The TextBlockEx allows you to very quickly define the text with new lines, bold regions, bullets and some other special formatting (for example hyperlinks). It replaced the clumsy DocumentViewer that require a lot of XAML for simple text and also produces annoying handled exceptions. Also the Frame element was replaced by custom DynamicContentControl that can be bind to UserControl type name to show the correct UserControl. Both new classes are part of the sample and can be freely used for your projects also.

 

In the following days I will also update the ResourceDictionaryWriter that comes with ReaderWmf library. It will provide similar improvements as the one that comes with ReaderSvg.

 

I hope you are satisfied with improvements. As always, if you find a svg file that is not correctly read, please send it to me. Also if you are missing a special functionality and think that it could be also beneficial to others, please let know and maybe I will implement it for you – usually after a day or two you can already get a pre-released version with new functionality.

Tags: ,

ReaderSvg

Improved version of Ab2d.ReaderSvg and Ab2d.ReaderWmf available

by abenedik 23. May 2014 21:43

I am happy to announce that a new version of Ab2d.ReaderSvg and Ab2d.ReaderWmf have been published.

I am particularly proud of adding some very interesting hierarchy optimizations to ReaderSvg. Drawings in svg files are many times defined in many groups and with using transformations. In case you do want to simply show your vector assets, than it is much more convenient to have the drawing objects compact and without the complex hierarchies. With the new version of ReaderSvg this is not very easy task. More about that later in this post.

First let me show what is new for Ab2d.ReaderWmf – metafile reader for WPF:

  • Improved reading geometries when rectangle or ellipse have both Canvas position (Canvas.Left or Canvas.Top) and transformation set.
  • Improved xaml writer to prevent writing Canvas.Left = "0" and Canvas.Top = "0" (zero values can be skipped).
  • Prevented writing "Canvas.Left" and "Canvas.Top" properties in XAML two times.
  • Added IgnoreRootElementSize property to GeometrySetting - added possibility to remove the transformations or RectangleGeometry based on the size or root element.
  • Fixed not showing some texts under some circumstances.

Most of the improvements in ReaderWmf are also available in ReaderSvg. Here is the full list:

  • Clip path now works on all elements and not just on Canvas.
  • Improved size measurement when AutoSize is set to true and some objects are hidden.
  • Added objects grouping optimizations to ReaderSvg - they can be controlled by new properties in ReaderSvg: OptimizeObjectGroups, FlattenHierarchies, TransformShapes
  • Improved transforming read objects with calling Transform method.
  • Updated SvgBounds after calling Transform method with updateLastReadViewbox set to true.
  • Prevented throwing exception in GetObjectsWithCustomProperties when svg file does not have any custom properties.
  • Added IgnoreRootElementSize property to GeometrySetting - added possibility to remove the transformations or RectangleGeometry based on the size or root element. This can produce nicer XAML.
  • Fixed using transformations on EllipseGeometry and RectGeometry when reading svg file as geometry.
  • Prevented writing "Canvas.Left" and "Canvas.Top" properties in XAML two times.
  • Improved reading geometries when rectangle or ellipse have both Canvas position (Canvas.Left or Canvas.Top) and transformation set.
  • Improved XAML writer to prevent writing Canvas.Left = "0" and Canvas.Top = "0" (zero values can be skipped).

As mentioned before ReaderSvg now support optimizing groups. The best way to describe this new functionality is to show it in action. Let’s start with the following XAML that can be get when using no optimization:

<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="200" Height="100">
    <Canvas>
        <Canvas Name="g1">
            <Rectangle Fill="Yellow" Width="200" Height="100"/>
            <Canvas Name="g2">
                <Canvas Name="g3">
                    <Ellipse Name="e1" Fill="Red" Width="20" Height="20"/>
                    <Canvas Name="g4">
                        <Canvas Name="g6" RenderTransform="2,0,0,1,-60,-10">
                            <Canvas Name="g5" Canvas.Left="50" Canvas.Top="10">
                                <Ellipse Name="e2" Fill="Green" Width="20" Height="20" Canvas.Left="10" Canvas.Top="10"/>
                                <Canvas Name="g7" RenderTransform="0.5,0,0,1,20,20">
                                    <Canvas Name="g8">
                                        <Canvas Name="e3" RenderTransform="1,0,0,2,20,0">
                                            <Ellipse Fill="Blue" Width="20" Height="20" Canvas.Left="20"/>
                                        </Canvas>
                                    </Canvas>
                                </Canvas>
                                <Canvas Name="g9" RenderTransform="5,0,0,5,0,0">
                                    <Canvas Name="g10">
                                        <Ellipse Name="e4" Fill="Orange" Width="4" Height="4" Canvas.Left="11" Canvas.Top="3"/>
                                    </Canvas>
                                </Canvas>
                                <Canvas Name="g11" Canvas.Left="-10" Canvas.Top="30">
                                    <Polygon Name="p1" Points="10,10 30,10 20,20" Fill="Lime" StrokeThickness="1"/>
                                    <Canvas Name="g12" RenderTransform="1.5,0,0,1,0,10">
                                        <Polygon Name="p2" Points="10,10 30,10 20,20" Fill="Aqua" StrokeThickness="1"/>
                                        <Canvas Name="g13" RenderTransform="0.866025388240814,0.5,-0.5,0.866025388240814,0,0">
                                            <Polygon Name="p3" Points="10,10 30,10 20,20" Fill="Purple" StrokeThickness="1"/>
                                        </Canvas>
                                    </Canvas>
                                </Canvas>
                            </Canvas>
                        </Canvas>
                    </Canvas>
                </Canvas>
            </Canvas>
        </Canvas>
    </Canvas>
</Canvas>

The XAML shows that there are many Canvases that contains only other Canvases. In the first step we can set OptimizeObjectGroups to true. This reduces the size of XAML to:

<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="200" Height="100">
    <Canvas Name="g1">
        <Rectangle Fill="Yellow" Width="200" Height="100"/>
        <Canvas Name="g3">
            <Ellipse Name="e1" Fill="Red" Width="20" Height="20"/>
            <Canvas Name="g5" RenderTransform="2,0,0,1,40,0">
                <Ellipse Name="e2" Fill="Green" Width="20" Height="20" Canvas.Left="10" Canvas.Top="10"/>
                <Canvas Name="e3" RenderTransform="0.5,0,0,2,30,20">
                    <Ellipse Fill="Blue" Width="20" Height="20" Canvas.Left="20"/>
                </Canvas>
                <Canvas Name="g10" RenderTransform="5,0,0,5,0,0">
                    <Ellipse Name="e4" Fill="Orange" Width="4" Height="4" Canvas.Left="11" Canvas.Top="3"/>
                </Canvas>
                <Canvas Name="g11" Canvas.Left="-10" Canvas.Top="30">
                    <Polygon Name="p1" Points="10,10 30,10 20,20" Fill="Lime" StrokeThickness="1"/>
                    <Canvas Name="g12" RenderTransform="1.5,0,0,1,0,10">
                        <Polygon Name="p2" Points="10,10 30,10 20,20" Fill="Aqua" StrokeThickness="1"/>
                        <Canvas Name="g13" RenderTransform="0.866025388240814,0.5,-0.5,0.866025388240814,0,0">
                            <Polygon Name="p3" Points="10,10 30,10 20,20" Fill="Purple" StrokeThickness="1"/>
                        </Canvas>
                    </Canvas>
                </Canvas>
            </Canvas>
        </Canvas>
    </Canvas>
</Canvas>

But there are still many Canvases. A more radical step is to remove the all the hierarchies. This can be simply done with setting FlattenHierarhy to true (OptimizeObjectGroups can be set to false). The results speak for themselves:

<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="200" Height="100">
    <Rectangle Fill="Yellow" Width="200" Height="100"/>
    <Ellipse Name="e1" Fill="Red" Width="20" Height="20"/>
    <Ellipse Name="e2" Fill="Green" Width="20" Height="20" RenderTransform="2,0,0,1,40,0" Canvas.Left="20" Canvas.Top="10"/>
    <Ellipse Fill="Blue" Width="20" Height="20" RenderTransform="1,0,0,2,100,20" Canvas.Left="20"/>
    <Ellipse Name="e4" Fill="Orange" Width="4" Height="4" RenderTransform="10,0,0,5,40,0" Canvas.Left="110" Canvas.Top="15"/>
    <Polygon Name="p1" Points="10,10 30,10 20,20" Fill="Lime" StrokeThickness="1" RenderTransform="2,0,0,1,20,30"/>
    <Polygon Name="p2" Points="10,10 30,10 20,20" Fill="Aqua" StrokeThickness="1" RenderTransform="3,0,0,1,20,40"/>
    <Polygon Name="p3" Points="10,10 30,10 20,20" Fill="Purple" StrokeThickness="1" RenderTransform="2.59807616472244,0.5,-1.5,0.866025388240814,20,40"/>
</Canvas>

With using just one simple property we have come from a complex hierarchy to one simple Canvas that contain all the objects. But we can go even one more step further. As seen in the last step, almost all the objects use RenderTransform to transform them. With setting TransformShapes to true we can eliminate almost all RenderTransforms from the objects. So after setting both FlattenHierarhy and TransformShapes to true, we are left with the following XAML:

<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="200" Height="100">
    <Rectangle Fill="Yellow" Width="200" Height="100"/>
    <Ellipse Name="e1" Fill="Red" Width="20" Height="20"/>
    <Ellipse Name="e2" Fill="Green" StrokeThickness="1.414" Width="40" Height="20" Canvas.Left="60" Canvas.Top="10"/>
    <Ellipse Fill="Blue" StrokeThickness="1.414" Width="20" Height="40" Canvas.Left="120" Canvas.Top="20"/>
    <Ellipse Name="e4" Fill="Orange" StrokeThickness="7.071" Width="40" Height="20" Canvas.Left="150" Canvas.Top="15"/>
    <Polygon Name="p1" Points="40,40 80,40 60,50" Fill="Lime" StrokeThickness="1.414"/>
    <Polygon Name="p2" Points="50,50 110,50 80,60" Fill="Aqua" StrokeThickness="1.732"/>
    <Polygon Name="p3" Points="30.981,53.66 82.942,63.66 41.962,67.321" Fill="Purple" StrokeThickness="1.732"/>
</Canvas>

Nice and clean!

No more transformations. Instead the values of the shapes were transformed to give us clean and simple object model.

Note that when the Canvas defines the clipping area, than even when FlattenHierarhy is set to true, this Canvas is preserved. This way the end results are still the same as with having the whole hierarchy. 

In the same fashion, the TransformShapes could preserve some RenderTransforms. This happens when it is not possible to preserve the object with only transform the object’s values – for example if Ellipse or Rectangle is rotated with RenderTransforms,  then we cannot preserve this rotation without using transformation (with Ellipse and Rectangle we can only change the position and size).

I am sure that those new features are great for anyone that wants to use vector assets instead of bitmap. I think that using vector assets is the future. They have many advantages over bitmaps. For example they are DPI independent and can be scaled up and down without any loss. They usually take less space on disk. They can be simply manipulated – for example if you want that one icon changes color when the mouse is over it, this can be done with simply changing the Stroke or Fill color. With bitmap you need to use provide the bitmaps in all possible colors.

Therefore I am already working on a new application that will allow users to simply create ResourceDictionaries with many vector objects created from svg or metafiles. The application will allow the user to optimize and transform the objects before they are added to ResourceDictionary. For example it will be possible to create vector assets that will all have the same size and the same padding regardless from which source they are created. And what is more, the application will be available with full source code.

At the end of this post I would like to remind you, that the XAML that is created with our converter applications (ViewerSvg and Paste2Xaml) are not meant only for WPF. They can be also used for Silverlight and also for Windows Phone and Windows Store apps.

Tags: ,

ReaderSvg | ReaderWmf

New maintenance release for almost all products published

by abenedik 15. October 2013 23:02

After quite a long time I am happy to announce that a maintenance release for the following products has been released:

  • Ab2d.ReaderSvg with ViewerSvg,
  • Ab2d.ReaderWmf with Paste2Xaml,
  • Ab2d.ZoomPanel,
  • Ab3d.Reader3ds with Viewer3ds.

 

New version mainily include some bug fixes and improvements that were created based on users feedback.

The following is the what's new list:

 

Ab2d.ReaderSvg

  • Fixed reading text with gradient fill or stroke brush.
  • Prevent throwing exception when incorrect number text was used for numbers.
  • Invisible objects (Visibility != Visible) are not exported to geometry any more.
  • Shapes with Opacity set (Opacity < 1.0) are now correctly exported as geometries.

 

Ab2d.ReaderWmf

  • Added reading images from EMR_ALPHABLEND records. Note that usually those images are not rendered correctly because the blend dwRop operations are not supported by WPF, but at least user can get the image and convert it manually to a transparent image that could be used to achieve correct results.
  • Added ResolveBitmapOperation that is called in processing EMR_ALPHABLEND record - here the user can change the bitmap to get correct results - for example convert black to transparent.
  • Invisible objects (Visibility != Visible) are not exported to geometry any more.
  • Shapes with Opacity set (Opacity < 1.0) are now correctly exported as geometries.

 

Ab2d.ZoomPanel

  • Fixed using ZoomPanel under some circumstances when viewbox limits is set.

 

Ab3d.Reader3ds

  • Small fix for a problem that can occure when one object has multiple materials assigned.
  • Improved reading broken files - no exception is thrown when the animation data for camera is broken.

 

You could say that this is not much for quite a long time since last update. And you would be right.

The reason for that is that I am preparing a new major release of Ab3d.PowerToys which will be hopefully ready until beginning of the next week. It will have much much more to show.

And that is not all. With the release of the new version of Ab3d.PowerToys I will also announce a brand new project that I have been working on for almost a year. I am very excited about that project and I am sure you will also like it.

Tags: , , ,

Reader3ds | ReaderSvg | ReaderWmf | ZoomPanel

TrueTransform added to ReaderSvg and ReaderWmf

by abenedik 21. June 2013 10:16

For quite some time it was possible to transform the read objects in ViewerSvg and Paste2Xaml. I am not talking about simply adding a transformation to read objects but to actually change all coordinates, sizes and other values with the specified transformation.

For example after reading a svg file we get the following xaml (some common properties were removed to simplify the xaml):

<Canvas Width="422.425" Height="208.895">
    <TextBlock Text="text1" FontSize="10" Canvas.Left="68.571" Canvas.Top="103.145"/>
    <Path Stroke="Black" StrokeThickness="3" StrokeMiterLimit="2" 
          Data="M366.43,67.029C358.951,54.888 368.807,24.872 384.677,34.264 394.346,39.986 389.365,72.847 384.677,80.68 384.384,71.342 374.133,66.51 366.43,67.029z"/>

In Export dialog in ViewerSvg it was possible to transform this with specifying custom width (instead of 422.425) we could set the width to 100. After transformation the xaml is:

<Canvas Width="100" Height="49.5">
    <TextBlock Text="text1" FontSize="2.368" Canvas.Left="16.233" Canvas.Top="24.441"/>
    <Path Stroke="Black" StrokeThickness="0.711" StrokeMiterLimit="2" 
          Data="M86.744,15.883C84.974,13.006 87.307,5.894 91.064,8.119 93.353,9.475 92.174,17.262 91.064,19.118 90.995,16.905 88.568,15.76 86.744,15.883z"/>

 
As seen from xaml, the transformation changed the FontSize, position in canvas, StrokeThickness and also path data. ViewerSvg and Paste2Xaml used an internal TrueTransform class that performed the transformation.

This can be very useful in many cases:

  • When creating graphics for WPF, Silverlight or WinRT the graphics elements can be created in a drawing application and can have any possible dimension. But if your application needs graphics element that would have size 100 x 100, it is very convenient to transform the graphics into the required dimensions.
  • Some drawing applications (for example Inkscape) allow users to draw in real units (in mm), but when the drawing is saved into svg file, all the units are converted to pixels. With using TrueTransform it is possible to convert the coordinates and other data back to mm units.


Now this functionally is available in Ab2d.ReaderSvg and Ab2d.ReaderWmf libraries also. This means that you can now also use TrueTransform in your applications.

The simplest way to use TrueTransform is to use Transform or TransformFromPixelsToMM methods on ReaderSvg or ReaderWmf class. The Transform needs two parameters: the first one is a Transform object (can be ScaleTransform, TranslateTransform, TransformGroup, or any other Transform); the second is a Boolean that specifies if the LastReadViewbox (property of ReaderSvg and ReaderWmf) is also changed – if true this means that GetXaml method will return the xaml of the transformed objects. The TransformFromPixelsToMM method can be used to transform from pixel to real units.

It is not only possible to transform the objects that are read from svg or metafiles but also almost any other objects – this can be done with Ab2d.Common.ReaderSvg.TrueTransform (or Ab2d.Common.ReaderWmf.TrueTransform) class.
 

ReaderSvg also got a new property – SvgCreator. It is an enum that is set after reading svg file and specifies the application that was used to create svg file. Currently the following applications are recognized: Microsoft Visio, CorelDraw, Adobe Illustrator and Inkscape.

 

There is also a new sample that come with ReaderSvg that demonstrates the new transformations.


As always if you are new to our tools, you are most welcome to download a 60-day trial from the Download page. Existing customers can get the updated versions from their User Account page.

Tags: ,

ReaderSvg | ReaderWmf

Maintenance releases for Ab2d.ReaderSvg and Ab2d.ReaderWmf are now available

by abenedik 15. May 2013 21:05

I am happy to inform you that a new version of Ab2d.ReaderSvg (svg reader for WPF) and Ab2d.ReaderWmf (metafile reader for WPF) have been published.

Ab2d.ReaderSvg got the following improvements:

  • Fixed reading numbers defined with em unit (for example: "123.45em")
  • Fixed writing Image.Stretch into XAML
  • Added writing HorizontalAlignment and VerticalAlignment into XAML when exporting Image (when using preserveAspectRatio svg element)

Ab2d.ReaderWmf got the following improvement:

  • Improved positioning some elements (in case ViewPortExtentX or ViewPortExtentY is set)

 

All those fixes are based on the user's feedback. The small number of reported issues and fixes shows that both products are very mature and work very well for the customers.

Tags: ,

ReaderSvg | ReaderWmf