tags:

views:

85

answers:

2

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);
+2  A: 

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.

TOndrej
@TOndrej Oh... right.. :-( I wanted the whole region... what should I do??? I am using flood fill for getting points as you already know from my previous question...
Himadri
@TOndrej But http://msdn.microsoft.com/en-us/library/dd183511%28v=VS.85%29.aspx It shows that createpolygonrgn will exclude whole outline.. while in my case it is excluding right and bottom outline ???
Himadri
You could for example go through the rectangles in your array and make them one pixel wider and higher, using InflateRect API.
TOndrej
It's not clear from your question(s) what you're doing. Where does your array of points come from?
TOndrej
Himadri
Sorry, but your comments don't make it clearer.CreatePolygonRgn doesn't draw anything.InflateRect can be used to increase or decrease size of a rectangle, depending on parameters.It would help if you could more clearly formulate steps to reproduce your problem (the best would be minimal compilable code to demonstrate the problem), what you expected to get, and how your results are different from what you expected.
TOndrej
@Tondrej OK.. I think I am unable to explain my problem by writing it. But at least with your help I am now knowing that why I am not getting expected result. I will try to solve it my self. Thanks for your efforts.
Himadri
A: 

Hello all, 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.

Himadri
@TOndrej Hi, This is just to inform you that I found solution with your help.
Himadri