我正在创建一个圆角矩形 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):
发布评论
评论(1)
我最终将形状绘制为位图,然后将其转换为区域。
I ended up drawing the shape into a bitmap and then converting this into a region.
Here is an example of this.