如何从包含“轮廓”的路径创建剪辑区域?
我正在创建一个圆角矩形 GraphicsPath(请参见下面的红色轮廓图),然后在绘制图形时将其用作剪辑区域,并用作表单的区域。
不幸的是,虽然路径看起来不错,但它作为一个区域效果不佳(请参见下面的纯黑色图像)
有没有一种方法可以从包含路径的所有“轮廓”像素的路径生成剪切区域?我是否需要生成位图,然后对其进行处理以创建区域?
圆角矩形路径:
何时用作剪辑区域:
差异 (红色像素位于路径轮廓中,但蓝色像素位于两者中):
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:
When used as a clip region:
The discrepancy (red pixels are in the path outline, but outside the region. blue pixels are in both):
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最终将形状绘制为位图,然后将其转换为区域。
I ended up drawing the shape into a bitmap and then converting this into a region.
Here is an example of this.