Search code examples
delphiregion

Confusion with CreatePolygonRgn


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

alt text

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

Solution

  • 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.