HighTechTalks DotNet Forums  

GraphicsPath::GetBounds() returns too large a rectangle

Dotnet Framework (Drawing) microsoft.public.dotnet.framework.drawing


Discuss GraphicsPath::GetBounds() returns too large a rectangle in the Dotnet Framework (Drawing) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
nomad
 
Posts: n/a

Default GraphicsPath::GetBounds() returns too large a rectangle - 12-18-2009 , 02:20 AM






If I call GraphicsPath::GetBounds() with no transform matrix and a pen, as
follows

result = myPath.GetBounds(&myRect, NULL, &myPen);

I get a rectangle that's much larger (generally several pixels on each side)
than the path I defined. I've set the pen width to 0.5 and I have
PenAlignmentCenter set.

If I make the same call without the pen, i.e.

result = myPath.GetBounds(&myRect);

I get exactly what I expect, although the pen thickness is not taken into
account.

Is this a known problem, or am I missing something?

Reply With Quote
  #2  
Old   
Vic Joseph
 
Posts: n/a

Default Re: GraphicsPath::GetBounds() returns too large a rectangle - 01-19-2010 , 08:44 AM






On Dec 18 2009, 9:20*am, nomad <no... (AT) discussions (DOT) microsoft.com>
wrote:
Quote:
If I call GraphicsPath::GetBounds() with no transform matrix and a pen, as
follows

* * result = myPath.GetBounds(&myRect, NULL, &myPen);

I get a rectangle that's much larger (generally several pixels on each side)
than the path I defined. I've set the pen width to 0.5 and I have
PenAlignmentCenter set.

If I make the same call without the pen, i.e.

* * result = myPath.GetBounds(&myRect);

I get exactly what I expect, although the pen thickness is not taken into
account.

Is this a known problem, or am I missing something?
It is pretty wierd, isn't it? It seems to enlarge the path by 10x the
pen width. A look in msdn gives the answer: the pen width is
multiplied by the MiterLimit and the default for that is apparently
10. So the solution is to set your pen's MitreLimit property to 1
before measuring the bounds.

bye, BB

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.