Metafile Page Units : wmf file : Graphics C# Source Code


Custom Search

C# Source Code » Graphics » wmf file »

 

Metafile Page Units








    
 
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Printing;
using System.Windows.Forms;
   
class MetafilePageUnits: Form
{
     Metafile mf;
   
     public static void Main()
     {
          Application.Run(new MetafilePageUnits());
     }
     public MetafilePageUnits()
     {
          ResizeRedraw = true; 
          Graphics grfx  = CreateGraphics();
          IntPtr ipHdc = grfx.GetHdc();
   
          mf = new Metafile("MetafilePageUnits.emf", ipHdc);
   
          grfx.ReleaseHdc(ipHdc);
          grfx.Dispose();
          grfx = Graphics.FromImage(mf);
          grfx.Clear(Color.White);
   
          grfx.PageUnit = GraphicsUnit.Pixel;
          Pen pen = new Pen(Color.Black, grfx.DpiX / 72);
          grfx.DrawRectangle(pen, 0, 0, grfx.DpiX, grfx.DpiY);
   
          grfx.PageUnit = GraphicsUnit.Inch;
          grfx.PageScale = 0.01f;
          pen = new Pen(Color.Black, 100f / 72);
          grfx.DrawRectangle(pen, 25, 25, 100, 100);
   
          grfx.Dispose();
     }
     protected void OnPaint(PaintEventArgs pea)
     {
          grfx.DrawImage(mf, 0, 0);
     }      
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Graphics
» wmf file