与 CreatePolygonRgn 的混淆
我正在与德尔福合作。我有一个点数组,这些点连续,如图所示。
然后我将此数组提供给 CreatePolygonRgn 并创建区域(例如 rgn1)。
rgn1 := CreatePolygonRgn(tmpary1[0],Count,WINDING);
然后我填充该区域并将其显示在我的 TImage 控件上,如图所示。问题是从左侧看,点也被覆盖在区域中,但从右侧看,数组的点没有被覆盖。从图像中可以看出,从左侧看,绿色边框没有显示,但从右侧看,绿色边框是可见的。我是不是哪里搞错了???如果您不清楚我的问题,请询问。
谢谢。
编辑:
for cnt := 0 to Count - 1 do begin
p1 := imgmain.Picture.Bitmap.ScanLine[tmpary[cnt].Y];
p1[tmpary[cnt].X].rgbtBlue := 0;
p1[tmpary[cnt].X].rgbtGreen := 255;
p1[tmpary[cnt].X].rgbtRed := 0;
end;
rgn1 := CreatePolygonRgn(tmpary1[0],tmpseq1.Count,WINDING);
imgmain.Picture.Bitmap.Canvas.Brush.Color := clRed;
FillRgn(imgmain.Picture.Bitmap.Canvas.Handle,rgn1,imgmain.Picture.Bitmap.Canvas.Brush.Handle);
I am working with delphi. I have an array of points which are continues as shown in image.
Then I give this array to CreatePolygonRgn and create the region say rgn1.
rgn1 := CreatePolygonRgn(tmpary1[0],Count,WINDING);
Then I fill the region and show it on my TImage control as shown in image. The problem is from the left side, the points are also covered in region but from right side the points of array are not covered. This can be seen in image that from left side green border is not shown but from right side border is visible. Am I mistaking somewhere??? If my question is not clear to you then please ask.
Thank You.
Edit:
for cnt := 0 to Count - 1 do begin
p1 := imgmain.Picture.Bitmap.ScanLine[tmpary[cnt].Y];
p1[tmpary[cnt].X].rgbtBlue := 0;
p1[tmpary[cnt].X].rgbtGreen := 255;
p1[tmpary[cnt].X].rgbtRed := 0;
end;
rgn1 := CreatePolygonRgn(tmpary1[0],tmpseq1.Count,WINDING);
imgmain.Picture.Bitmap.Canvas.Brush.Color := clRed;
FillRgn(imgmain.Picture.Bitmap.Canvas.Handle,rgn1,imgmain.Picture.Bitmap.Canvas.Brush.Handle);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这可能就是它的运作方式。
FillRect
,例如,包括矩形的左边框和上边框,但不包括右边框和下边框。我认为同样的情况可能也适用于
FillRgn
。编辑:已确认
It may just be the way it works.
FillRect
, for example, includes the left and top borders, but excludes the right and bottom borders of the rectangle.I think the same probably applies to
FillRgn
.Edit: Confirmed here, too.
最后我找到了解决我的问题的可行解决方案,也找到了 this 问题的解决方案作为两个问题彼此相关。
我正在填充该区域,然后尝试获取该区域的边界。我得到原始数组的一些点作为边界,一些点是实际的边界点。我想要实际边界的所有点。
所以,现在我用红色填充该区域,然后用红色填充数组的像素,然后运行洪水填充算法。它会给出我需要的所有积分。
At last I found the feasible solution to my problem and also the solution of this problem as both question are related to each other.
I was filling the region and then tried to get boundary of that region. I was getting some points of original array as boundary and some points were actual boundary points. I wanted all points of actual boundary.
So, now I fill the region with red color then fill the pixels of array with red color and then I run floodfill algorithm. It will give all points I needed.