Mega Code Archive

 
Categories / C# by API / System Drawing
 

Graphics SetClip

using System; using System.Drawing; using System.Drawing.Drawing2D; using System.Windows.Forms;     class KeyholeClip: Form {      protected Image        image;      protected GraphicsPath path;          public static void Main()      {           Application.Run(new KeyholeClip());      }      public KeyholeClip()      {           ResizeRedraw = true;           image = Image.FromFile("Color.jpg");               path = new GraphicsPath();           path.AddArc(80, 0, 80, 80, 45, -270);           path.AddLine(70, 180, 170, 180);      }      protected override void OnPaint(PaintEventArgs pea)      {           pea.Graphics.SetClip(path);           pea.Graphics.DrawImage(image, 0, 0, image.Width, image.Height);      }       }