I\'d like to create image (from another one) with rounded corners with GDI+. What\'s the best way to do this?
PS: it\'s not for web, so I cannot make use of client C
Using the Graphics.SetClip() method is the best way. For example:
public static Image OvalImage(Image img) {
Bitmap bmp = new Bitmap(img.Width, img.Height);
using (GraphicsPath gp = new GraphicsPath()) {
gp.AddEllipse(0, 0, img.Width, img.Height);
using (Graphics gr = Graphics.FromImage(bmp)) {
gr.SetClip(gp);
gr.DrawImage(img, Point.Empty);
}
}
return bmp;
}