Create wmf file and draw to it
Imports System
Imports System.Windows.Forms
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Drawing.Imaging
Imports System.Drawing
Public Class MainClass
Shared Sub Main()
Const WID As Integer = 200
Dim file_name As String = "test.wmf"
Dim gr As Graphics
gr = Graphics.FromImage(new Bitmap(100,100))
' Make a Graphics object so we can use its hDC as a reference.
Dim hdc As IntPtr = gr.GetHdc
' Make the Metafile, using the reference hDC.
Dim bounds As New RectangleF(0, 0, WID, WID)
Dim mf As New Metafile(file_name, hdc, _
bounds, MetafileFrameUnit.Pixel)
gr.ReleaseHdc(hdc)
' Make a Graphics object and draw.
gr = Graphics.FromImage(mf)
gr.PageUnit = GraphicsUnit.Pixel
gr.Clear(Color.White)
gr.DrawEllipse(Pens.Red, bounds)
gr.DrawLine(Pens.Blue, 0, 0, WID, WID)
gr.DrawLine(Pens.Blue, WID, 0, 0, WID)
' Close the metafile and free resources.
gr.Dispose()
mf.Dispose()
End Sub
End Class
Related examples in the same category