1 |
#Region "Microsoft.VisualBasic::fc835d3e5aac0f293ed406ae1813779d, Microsoft.VisualBasic.Core\Extensions\Image\Wmf.vb"
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
#End Region
|
45 |
|
46 |
Imports System.Drawing
|
47 |
Imports System.Drawing.Drawing2D
|
48 |
Imports System.Drawing.Imaging
|
49 |
|
50 |
Namespace Imaging
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
Essentially, a WMF file stores a list of function calls that have to be issued to the Windows Graphics
|
58 |
Device Interface (GDI) layer to display an image on screen. Since some GDI functions accept pointers
|
59 |
to callback functions for error handling, a WMF file may erroneously include executable code.
|
60 |
|
61 |
WMF Is a 16-bit format introduced in Windows 3.0. It Is the native vector format for Microsoft Office
|
62 |
applications such as Word, PowerPoint, And Publisher. As of 2015 revision 12 of the Windows Metafile
|
63 |
Format specification Is available for online reading Or download as PDF.
|
64 |
</summary>
|
65 |
<remarks>
|
66 |
The original 16 bit WMF file format was fully specified in volume 4 of the 1992 Windows 3.1 SDK documentation
|
67 |
(at least if combined with the descriptions of the individual functions and structures in the other volumes),
|
68 |
but that specification was vague about a few details. These manuals were published as printed books available
|
69 |
in bookstores with no click through EULA or other unusual licensing restrictions (just a general warning that
|
70 |
if purchased as part of a software bundle, the software would be subject to one).
|
71 |
|
72 |
Over time the existence Of that historic specification was largely forgotten And some alternative implementations
|
73 |
resorted To reverse engineering To figure out the file format from existing WMF files, which was difficult And
|
74 |
Error prone. In September 2006, Microsoft again published the WMF file format specification In the context Of
|
75 |
the Microsoft Open Specification Promise, promising To Not assert patent rights To file format implementors.
|
76 |
</remarks>
|
77 |
Public Class Wmf : Inherits GDICanvas
|
78 |
Implements IDisposable
|
79 |
|
80 |
ReadOnly curMetafile As Metafile
|
81 |
ReadOnly gSource As Graphics
|
82 |
ReadOnly hdc As IntPtr
|
83 |
|
84 |
|
85 |
The file path of the target wmf image file.
|
86 |
</summary>
|
87 |
<returns></returns>
|
88 |
Public ReadOnly Property FilePath As String
|
89 |
Public Overrides ReadOnly Property Size As Size
|
90 |
|
91 |
|
92 |
The WMF format was designed to be executed by the Windows GDI layer in order to restore the image, but as
|
93 |
the WMF binary files contain the definition of the GDI graphic primitives that constitute this image, it is
|
94 |
possible to design alternative libraries that render WMF binary files, like the Kyktir application does, or
|
95 |
convert them into other graphic formats. For example, the Batik library is able to render WMF files and
|
96 |
convert them to their Scalable Vector Graphics (SVG) equivalent. The Vector Graphics package of the FreeHEP
|
97 |
Java library allows the saving of Java2D drawings as Enhanced Metafiles (EMF). Inkscape and XnView can export
|
98 |
to WMF or EMF.
|
99 |
</summary>
|
100 |
<param name="size"></param>
|
101 |
<param name="save$"></param>
|
102 |
<param name="backgroundColor$"></param>
|
103 |
Sub New(size As Size, save$, Optional backgroundColor$ = NameOf(Color.Transparent))
|
104 |
Dim bitmap As New Bitmap(size.Width, size.Height)
|
105 |
|
106 |
gSource = Graphics.FromImage(bitmap)
|
107 |
gSource.Clear(backgroundColor.TranslateColor)
|
108 |
|
109 |
hdc = gSource.GetHdc()
|
110 |
size = bitmap.Size
|
111 |
curMetafile = New Metafile(save, hdc)
|
112 |
Graphics = Graphics.FromImage(curMetafile)
|
113 |
Graphics.SmoothingMode = SmoothingMode.HighQuality
|
114 |
|
115 |
FilePath = save
|
116 |
End Sub
|
117 |
|
118 |
Private Sub __release()
|
119 |
Call gSource.ReleaseHdc(hdc)
|
120 |
Call Graphics.Dispose()
|
121 |
Call gSource.Dispose()
|
122 |
End Sub
|
123 |
|
124 |
Public Overrides Sub Dispose()
|
125 |
Call __release()
|
126 |
MyBase.Dispose()
|
127 |
End Sub
|
128 |
|
129 |
Public Overrides Sub DrawCircle(center As PointF, fill As Color, stroke As Pen, radius As Single)
|
130 |
Throw New NotImplementedException()
|
131 |
End Sub
|
132 |
End Class
|
133 |
End Namespace
|