首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将GaussianBlur或像素应用于多边形

将GaussianBlur或像素应用于多边形
EN

Stack Overflow用户
提问于 2020-05-12 19:28:56
回答 1查看 371关注 0票数 2

我能够将GaussianBlur或像素应用于矩形区域。

代码语言:javascript
复制
image.Mutate(x => x.GaussianBlur(5, new CoreRectangle(o.BoundingBox.X - 10, o.BoundingBox.Y - 10, o.BoundingBox.Width + 20, o.BoundingBox.Height + 20)));

有没有办法用n点多边形代替?有什么想法吗?

谢谢!约尔格

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-05-14 17:39:37

这应该适用于您,它克隆原始图像,将效果应用于克隆,然后使用图像灌木填充一个形状,正好是突变图像的正确部分。

代码语言:javascript
复制
using (Image image = Image.Load("fb.jpg"))
{
    var outerRadii = Math.Min(image.Width, image.Height) / 2;
    var star = new Star(new PointF(image.Width / 2, image.Height / 2), 5, outerRadii / 2, outerRadii);

    // we want to clone our source image so we can apply 
    // various effects to it without mutating the original.
    using (var clone = image.Clone(p => {
        p.GaussianBlur(15); // apply the effect here you and inside the shape
    }))
    {
        // crop the cloned down to just the size of the shape (this is due to the way ImageBrush works)
        clone.Mutate(x => x.Crop((Rectangle)star.Bounds));

        // use an image brush to apply the section of cloned image as the source for filling the shape
        var brush = new ImageBrush(clone);

        // now fill the shape with the image brush containing the portion of 
        // cloned image with the effects applied
        image.Mutate(c => c.Fill(brush, star));
    }

    image.Save("output/fb.png");
}

这是最后结果的一个例子:

这是和其他示例都可以在ImageSharp示例存储库中获得。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61760332

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档