PtiTom

EMF File Drawing

Jan 14th, 2021
420
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Drawing;
  2. using System.Drawing.Imaging;
  3.  
  4. namespace WriteEMF
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             using (var img = new Bitmap(200, 200))
  11.             using (var g = Graphics.FromImage(img))
  12.             {
  13.                 Pen penBlue = new Pen(Color.CadetBlue, 2);
  14.                 Brush brushRed = new SolidBrush(Color.IndianRed);
  15.                 Font fontMessage = new Font(SystemFonts.DefaultFont.FontFamily, 14);
  16.                 g.DrawBezier(penBlue, new Point(0, 0), new Point(50, 100), new Point(100, 50), new Point(0, 0));
  17.                 g.DrawString("Salut les moches !", fontMessage, brushRed, new Point((int)(200 - g.MeasureString("Salut les moches !", fontMessage).Width) / 2, 80));
  18.                
  19.                 g.Flush();
  20.                 img.Save("Test.emf", ImageFormat.Emf);
  21.             }
  22.         }
  23.     }
  24. }
  25.  
RAW Paste Data