Create Metafile
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Windows.Forms;
class CreateMetafile: Form
{
Metafile mf;
public static void Main()
{
Application.Run(new CreateMetafile());
}
public CreateMetafile()
{
ResizeRedraw = true;
Graphics grfx = CreateGraphics();
IntPtr ipHdc = grfx.GetHdc();
mf = new Metafile("CreateMetafile.emf", ipHdc);
grfx.ReleaseHdc(ipHdc);
grfx.Dispose();
grfx = Graphics.FromImage(mf);
grfx.FillEllipse(Brushes.Blue, 60, 20, 20, 20);
grfx.Dispose();
}
protected override void OnPaint(PaintEventArgs pea)
{
DoPage(pea.Graphics, ForeColor,ClientSize.Width, ClientSize.Height);
}
protected void DoPage(Graphics grfx, Color clr, int cx, int cy)
{
for (int y = 0; y < cy; y += mf.Height)
for (int x = 0; x < cx; x += mf.Width)
grfx.DrawImage(mf, x, y, mf.Width, mf.Height);
}
}
Related examples in the same category