Question Get bounds of GraphicsPath

bufer24

Active member
Joined
Mar 27, 2008
Messages
35
Programming Experience
3-5
Hi, I wonder if there is a way I can get the REAL bounding rectangle for a graphicspath, for example a path consisting from one or more bezier curves. The bezier curves in the path have control points and the function .GetBounds takes these points in account. But I only want to get the bounds for the points on the path - without the control points.
 
Hi Bufer24,

I can't be sure and I don't have time to try it out, but I have an idea that may be what you are looking for: try the Path.Flatten method.

Path.Flatten has the effect of modifying the resolution of the path points. The name is a bit misleading, because you can use it to produce a smoother curve as well as a a curve flattened to a polygon. For example:
VB.NET:
MyPath.Flatten(New Drawing2D.Matrix, 0.01)
will give you a path with the PathPoints much closer to the drawn path than given by the default flattening value of 0.25.

My guess is that you could use this to get a GetBounds value much closer to the actual path. If you can try this out, I would be very interested to hear if it works.

regards, VicJ/BB
 
Last edited:
OK, I tried it and it seems to be working perfectly. You can see the original path drawn with black line and the flattened path drawn in red on the appended image from my application. I´ve increased the flattness value to 10 to verify if it really works. I also took the next step and used the GetBounds function on the flattened path to get the actual bounding rectangle. Now I only need to decrease the flatness value to a reasonable value and that´s it.
Thank you VicJ :)
 

Attachments

  • path2.jpg
    path2.jpg
    17.2 KB · Views: 39
Back
Top