ReaderWmf Class |
Namespace: Ab2d
public class ReaderWmf : IDisposable
The ReaderWmf type exposes the following members.
Name | Description | |
---|---|---|
AutoSize |
If true (default) the size of main canvas is set from the bounds defined in metafile header. Bounds define the size that is just as big as its containing objects.
If false the size is set from Frame size that is defined in metafile header. This is useful for example if you were working on a Letter area and would like to preserve the position of objects inside the Letter.
| |
CombineGradientPolygons |
Gets or sets a Boolean that specifies if the polygons that are used to create a gradient are combined into one polygon with gradient brush. Default value is true.
| |
ConvertPatternBrushesToColor |
Gets or sets a Boolean that specifies if monocrome pattern brushes are converted into color.
| |
CustomContentHeight |
Gets or sets the height that is used to set the custom width of the read objects. Default value is 0 that means that the height defined in metafile is used.
| |
CustomContentWidth |
Gets or sets the width that is used to set the custom width of the read objects. Default value is 0 that means that the width defined in metafile is used.
| |
DisableTextScaling |
Gets or sets a Boolean that specifies if text scaling is disabled. Default value is false.
| |
EmbeddedBitmapImages |
Gets list of all bitmap images that are defined in Metafile and cannot be converted to vector elements
| |
EmbeddedImagesData |
Gets list of images raw data and their image formats.
| |
Height |
Gets or sets the Height of the returned Viewbox or Image element.
| |
Instance |
Gets static instance of ReaderWmf so you do not need to create your own instance of it.
| |
LastReadImage |
Gets the lastly read wmf or emf as WPF's Image element (used when ReadGeometry is used, when using Read method see LastReadViewbox)
| |
LastReadViewbox |
Gets the lastly read wmf or emf as WPF's Viewbox element (used when Read method is used, when using ReadGeometry method see LastReadImage)
| |
LicenseInfo |
License information
| |
LimitToScaleCustomTextWidth |
Gets or sets a double that specifies at which ratio of custom sized text and its normal size a ScaleTransform is used on TextBlock.
This value is only used when ProcessCharacterSpacing is set to true. Default value is 0.03;
| |
MetafileImages | Obsolete.
Gets list of all bitmap images that are defined in Metafile and cannot be converted to vector elements
| |
MetafileUnits |
Gets or sets the units in which the matafile objects will be read. The default value is Pixel.
| |
MinLineWidthFactor |
Advanced users can set this property to control minimal StrokeThickness of lines.
| |
ProcessCharacterSpacing |
Gets or sets a Boolean that specifies if character spacing data from metafile is used to resize text when needed. Default value is true.
| |
ReadEmfPlusRecords |
Gets of sets a Boolean that specifies if emf plus records are read. Default value is true.
| |
ReadPatternBrushes |
Gets or sets a Boolean that specifies if pattern brushes are read. Default value is true.
| |
RemoveEmptyTextBlocks |
Gets or sets a Boolean that specifies if empty texts are not imported (default value is false).
| |
ShowDemoTextInEvaluation | Obsolete.
ShowDemoTextInEvaluation is not used any more.
| |
UsedMinLineWidthFactor |
Gets the MinLineWidthFactor that was used when reading metafile.
| |
Width |
Gets or sets the Width of the returned Viewbox or Image element.
|
Name | Description | |
---|---|---|
Dispose |
Dispose
| |
GetFromClipboard |
Creates metafile from clipboard (if available) and converts it into Image with elements as Drawings (DrawingGeometry, EllipseGeometry, GlyphRunDrawing etc.).
| |
GetFromHemf |
Creates metafile from hemf (handle to metafile) and converts it into Viewbox.
| |
GetGeometryFromClipboard |
Creates metafile from clipboard (if available) and converts it into Viewbox with elements as Shapes (Path, Ellipse, Polyline, etc.) and TextBlocks (for texts).
| |
GetGeometryFromClipboard(GeometrySettings) |
Creates metafile from clipboard (if available) and converts it into Viewbox with elements as Shapes (Path, Ellipse, Polyline, etc.) and TextBlocks (for texts).
| |
GetGeometryFromHemf |
Creates metafile from hemf (handle to metafile) and converts it into Drawing.
| |
GetSize |
Returns the size of the read metafile in the currently used metafile units.
| |
GetSize(MetafileUnits) |
Returns the size of the read metafile in the units specified as the method parameter.
| |
GetXaml |
Gets xaml of the last read metafile with the default setting for WPF.
| |
GetXaml(BaseXamlWriterSettings) |
Gets xaml of the last read metafile.
| |
IsClipboardMetafileAvailable |
Checks if there is a metafile data available on the clipboard and returns true in this case. Otherwise returns false.
| |
Read(Stream) |
Reads metafile (emf or wmf) from stream and returns System.Windows.Controls.Viewbox with elements as Shapes (Path, Ellipse, Polyline, etc.) and TextBlocks (for texts).
| |
Read(String) |
Reads metafile (emf or wmf) and returns System.Windows.Controls.Viewbox with elements as Shapes (Path, Ellipse, Polyline, etc.) and TextBlocks (for texts).
| |
ReadGeometry(Stream) |
Reads metafile (emf or wmf) from fileName and returns System.Windows.Controls.Image with elements as Drawings (DrawingGeometry, EllipseGeometry, GlyphRunDrawing etc.) with no geometry optimization.
| |
ReadGeometry(String) |
Reads metafile (emf or wmf) from fileName and returns System.Windows.Controls.Image with elements as Drawings (DrawingGeometry, EllipseGeometry, GlyphRunDrawing etc.) with no geometry optimization.
| |
ReadGeometry(Stream, GeometrySettings) |
Reads metafile (emf or wmf) from fileName and returns System.Windows.Controls.Image with elements as Drawings (DrawingGeometry, EllipseGeometry, GlyphRunDrawing etc.).
| |
ReadGeometry(String, GeometrySettings) |
Reads metafile (emf or wmf) from fileName and returns System.Windows.Controls.Image with elements as Drawings (DrawingGeometry, EllipseGeometry, GlyphRunDrawing etc.).
| |
Transform |
Transform method transforms all the coordinates, sizes and other values in the last read Viewbox with using transformation.
|
Name | Description | |
---|---|---|
ProgressChanged |
ProgressChanged event can be used to get notifications of how much the metafile has been read.
|
Name | Description | |
---|---|---|
ResolveBitmapOperation |
ResolveBitmapOperation is called when a bitmap should be rendered by an operation that is not supported in WPF (defined in second parameter).
The Func can be used to convert the bitmap so it will support the oparation - for example for alpha blending we can convert black to transparent.
The second parameter defines the dwRop or blendoperation function defined by metadata - see GDI+ documentation for more info.
| |
ResolveRasterOperation |
ResolveRasterOperation can be used to set a delegate that is called when an unsupported raster operation is used in metafile.
ResolveRasterOperation delegate returns a Brush that is used for the unsupported raster operation. If null is returned than the Rectangle will not be created.
|
Ab2d.ReaderWmf class can be used to read Windows metafiles (wmf) and also Enhanced Metafiles (emf).
They can be read as Shapes with Read(String) method or as Drawing objects with ReadGeometry(String, GeometrySettings).
After the file has been read, it is possible to get the xaml of the read Viewbox or Image with GetXaml(BaseXamlWriterSettings) method.
If your application needs images and shapes from many metafiles, it is recommended that they are stored in a ResourceDictionary. To simplify creating ResourceDictionaries a ResourceDictionaryWriter class can be used.
Ab2d.ReaderWmf can be used from code. If you would like to add metafile directly into the xaml you can use WmfViewbox to add metafile as shapes or WmfDrawing to add it as geometry.
The following example shows the most simple use of ReaderWmf. It loads the mySample metafile and adds it to the myStackPanel.
Viewbox sampleViewbox = Ab2d.ReaderWmf.Instance.Read(@"c:\mySample.wmf");
myStackPanel.Children.Add(sampleViewbox);
The following sample shows how to read metafile from Application's Resource. The ReadGeometry(String, GeometrySettings) reads metafile into Drawing objects and fully optimizes it for best performance.
Image clipartFromResource; Ab2d.Common.ReaderWmf.GeometrySettings settings; // gets Drawing objects optimized for best performance // NOTE: Because of heavy optimization it is possible that some anomalies appear on the image settings = Ab2d.Common.ReaderWmf.GeometrySettings.FullOptimization; Uri uri = new Uri("/cliparts/mySample.emf", UriKind.Relative); using (Stream metafileStream = Application.GetResourceStream(uri).Stream) { clipartFromResource = Ab2d.ReaderWmf.Instance.ReadGeometry(metafileStream, settings); } myStackPanel.Children.Add(clipartFromResource);
The following sample reads the mySample.wmf file, gets its xaml for Silverlight and saves it into a file.
string xaml; Viewbox sampleViewbox; sampleViewbox = myReader.Read(@"c:\mySample.wmf"); xaml = myReader.GetXaml(new Ab2d.Common.ReaderWmf.SilverlightXamlWriterSettings()); System.IO.File.WriteAllText(@"c:\mySample_for_Silverlight.xaml", xaml);