用 C# 代码实现了该功能,但有点不足,图片的边缘不是平滑的,
附代码:
public static Bitmap GetRoundPic(Bitmap sourceBitmap, int size)
{
//要截图的图片
Image img = ResizeImg(sourceBitmap,size,size);
//截图画板
Bitmap bm = new Bitmap(size, size);
Graphics g = Graphics.FromImage(bm);
//创建截图路径(类似Ps里的路径)
GraphicsPath gpath = new GraphicsPath();
gpath.AddEllipse(0, 0, size, size);//圆形
//设置画板的截图路径
g.SetClip(gpath);
//对图片进行截图
g.DrawImage(img, 0, 0);
//保存截好的图
return bm;
}
求大神帮忙看看怎么让边缘变得平滑,还有怎么给圆形外面的背景加颜色?
消除锯齿
g.SmoothingMode = SmoothingMode.AntiAlias; //使绘图质量最高,即消除锯齿
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.CompositingQuality = CompositingQuality.HighQuality;
求 ResizeImg的函数内容?