Skip to content

Instantly share code, notes, and snippets.

@orhanveli
Last active December 11, 2015 02:28
Show Gist options
  • Save orhanveli/4530516 to your computer and use it in GitHub Desktop.
Save orhanveli/4530516 to your computer and use it in GitHub Desktop.
c# crop image as transparent ellipse
Bitmap bm=(Bitmap)Image.FromFile("Original.bmp");
Bitmap bt=new Bitmap(bm.Width,bm.Height);
Graphics g=Graphics.FromImage(bt);
GraphicsPath gp=new GraphicsPath();
gp.AddEllipse(10,10,bm.Width-20,bm.Height-20);
g.Clear(Color.Magenta);
g.SetClip(gp);
g.DrawImage(bm,new
Rectangle(0,0,bm.Width,bm.Height),0,0,bm.Width,bm.Height,GraphicsUnit.Pixel);
g.Dispose();
bt.MakeTransparent(Color.Magenta);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment