Tutorial :Confusion with CreatePolygonRgn


I am working with delphi. I have an array of points which are continues as shown in image.

alt text http://i50.tinypic.com/4zylxl.jpg

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.


  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);  


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.


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.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »