如何从包含“轮廓”的路径创建剪辑区域?

发布于 2024-09-05 01:53:26 字数 523 浏览 4 评论 0 原文

我正在创建一个圆角矩形 GraphicsPath(请参见下面的红色轮廓图),然后在绘制图形时将其用作剪辑区域,并用作表单的区域。

不幸的是,虽然路径看起来不错,但它作为一个区域效果不佳(请参见下面的纯黑色图像)

有没有一种方法可以从包含路径的所有“轮廓”像素的路径生成剪切区域?我是否需要生成位图,然后对其进行处理以创建区域?

圆角矩形路径:

圆角矩形

何时用作剪辑区域:

clipregion

差异 (红色像素位于路径轮廓中,但蓝色像素位于两者中):

I am creating a rounded rectangle GraphicsPath (see red outline image below), and then using this as a clip region both when drawing graphics, and as the Region of a Form.

Unfortunately, although the path looks good, it doesn't work well as a region (see solid black image below)

Is there a way that I can generate a clipping region from the path that includes all the 'outline' pixels of the path? Do I need to generate a bitmap and then process this to create a region?

The rounded rectangle path:

rounded rectangle

When used as a clip region:

clip region

The discrepancy (red pixels are in the path outline, but outside the region. blue pixels are in both):

overlap

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

睡美人的小仙女 2024-09-12 01:53:26

我最终将形状绘制为位图,然后将其转换为区域。

I ended up drawing the shape into a bitmap and then converting this into a region.

Here is an example of this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文