C#将图像裁剪为边缘模糊的椭圆

时间:2018-03-23 15:08:37

标签: c#

我正在尝试将矩形图像裁剪为椭圆形,边缘模糊,如下所示:

resulting image has transparent edges (blended)

任何人都可以帮忙 此代码有效,但不提供边缘的透明度:

Image dstImage = new Bitmap(srcImage.Width, srcImage.Height, srcImage.PixelFormat);
Graphics g = Graphics.FromImage(dstImage);
using (Brush br = new SolidBrush(backGround))
{
    g.FillRectangle(br, 0, 0, dstImage.Width, dstImage.Height);
}
GraphicsPath path = new GraphicsPath();

path.AddEllipse(30, 30, dstImage.Width-60, dstImage.Height-60);
g.SetClip(path);
g.DrawImage(srcImage, 0, 0);

0 个答案:

没有答案