[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.drawing

Help please, up against a brick wall with GetBounds function!

DotNetJunkies User

11/19/2004 2:35:00 PM

Hi, Iâ??m having trouble with the GetBounds function of a GraphicsPath. See code below.
The first Arcâ??s Bounding rectangle is just plain wrong, itâ??s 106.0523 wide, it canâ??t be any wider than 100, because thats the size of the rectangle used to draw it!

The second Arc is correct and is there just for reference.

I would really appreciate it if anyone can shed some light on what I am doing wrong

Cheers


Talyrond

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint

Dim myPath As New GraphicsPath
Dim myAnotherPath As New GraphicsPath
Dim myRect As RectangleF
Dim myAnotherRect As RectangleF

myPath.StartFigure()
myPath.AddArc(New RectangleF(0.0F, 0.0F, 100.0F, 100.0F), 320.0F, 220.0F)
myAnotherPath.StartFigure()
myAnotherPath.AddArc(New RectangleF(0, 150, 100, 100), 270.0F, 270.0F)

'Get the bounding rectangles
myRect = myPath.GetBounds()
myAnotherRect = myAnotherPath.GetBounds()

'Print the bounding rectangles
e.Graphics.DrawPath(Pens.Black, myPath)
e.Graphics.DrawString(myRect.ToString, Me.Font, Brushes.Black, 120, 50)

e.Graphics.DrawPath(Pens.Black, myAnotherPath)
e.Graphics.DrawString(myAnotherRect.ToString, Me.Font, Brushes.Black, 120, 200)

'Draw the bounding rectangles
e.Graphics.DrawRectangle(Pens.Red, myAnotherRect.X, myAnotherRect.Y, myAnotherRect.Width, _
myAnotherRect.Height)
e.Graphics.DrawRectangle(Pens.Red, myRect.X, myRect.Y, myRect.Width, myRect.Height)

End Sub


---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/... Our newsgroup engine supports Post Alerts, Ratings, and Searching.
3 Answers

Frank Hileman

11/19/2004 3:30:00 PM

0

I did not debug your code, but remember that AddArc generates control
points, and they are included in the GetBounds calculations.

Regards,
Frank Hileman

check out VG.net: www.vgdotnet.com
Animated vector graphics system
Integrated Visual Studio .NET graphics editor

"DotNetJunkies User" <User@-NOSPAM-DotNetJunkies.com> wrote in message
news:OMOV4TkzEHA.748@TK2MSFTNGP14.phx.gbl...
> Hi, Iâ??m having trouble with the GetBounds function of a GraphicsPath.
> See code below.
> The first Arcâ??s Bounding rectangle is just plain wrong, itâ??s 106.0523
> wide, it canâ??t be any wider than 100, because thats the size of the
> rectangle used to draw it!
>
> The second Arc is correct and is there just for reference.
>
> I would really appreciate it if anyone can shed some light on what I am
> doing wrong
>
> Cheers
>
>
> Talyrond
>
> Private Sub Form1_Paint(ByVal sender As Object, ByVal e As
> System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
>
> Dim myPath As New GraphicsPath
> Dim myAnotherPath As New GraphicsPath
> Dim myRect As RectangleF
> Dim myAnotherRect As RectangleF
>
> myPath.StartFigure()
> myPath.AddArc(New RectangleF(0.0F, 0.0F, 100.0F, 100.0F), 320.0F,
> 220.0F)
> myAnotherPath.StartFigure()
> myAnotherPath.AddArc(New RectangleF(0, 150, 100, 100), 270.0F,
> 270.0F)
>
> 'Get the bounding rectangles
> myRect = myPath.GetBounds()
> myAnotherRect = myAnotherPath.GetBounds()
>
> 'Print the bounding rectangles
> e.Graphics.DrawPath(Pens.Black, myPath)
> e.Graphics.DrawString(myRect.ToString, Me.Font, Brushes.Black, 120,
> 50)
>
> e.Graphics.DrawPath(Pens.Black, myAnotherPath)
> e.Graphics.DrawString(myAnotherRect.ToString, Me.Font,
> Brushes.Black, 120, 200)
>
> 'Draw the bounding rectangles
> e.Graphics.DrawRectangle(Pens.Red, myAnotherRect.X,
> myAnotherRect.Y, myAnotherRect.Width, _
> myAnotherRect.Height)
> e.Graphics.DrawRectangle(Pens.Red, myRect.X, myRect.Y,
> myRect.Width, myRect.Height)
>
> End Sub
>
>
> ---
> Posted using Wimdows.net NntpNews Component -
>
> Post Made from http://www.DotNetJunkies.com/... Our newsgroup
> engine supports Post Alerts, Ratings, and Searching.


Bob Powell

11/19/2004 6:16:00 PM

0

We should point out that to cure this the path could be flattened...

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tips...

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/f...

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





"Frank Hileman" <frankhil@no.spamming.prodigesoftware.com> wrote in message
news:u$xpzykzEHA.3972@TK2MSFTNGP12.phx.gbl...
> I did not debug your code, but remember that AddArc generates control
> points, and they are included in the GetBounds calculations.
>
> Regards,
> Frank Hileman
>
> check out VG.net: www.vgdotnet.com
> Animated vector graphics system
> Integrated Visual Studio .NET graphics editor
>
> "DotNetJunkies User" <User@-NOSPAM-DotNetJunkies.com> wrote in message
> news:OMOV4TkzEHA.748@TK2MSFTNGP14.phx.gbl...
> > Hi, Iâ?Tm having trouble with the GetBounds function of a GraphicsPath.
> > See code below.
> > The first Arcâ?Ts Bounding rectangle is just plain wrong, itâ?Ts
106.0523
> > wide, it canâ?Tt be any wider than 100, because thats the size of the
> > rectangle used to draw it!
> >
> > The second Arc is correct and is there just for reference.
> >
> > I would really appreciate it if anyone can shed some light on what I am
> > doing wrong
> >
> > Cheers
> >
> >
> > Talyrond
> >
> > Private Sub Form1_Paint(ByVal sender As Object, ByVal e As
> > System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
> >
> > Dim myPath As New GraphicsPath
> > Dim myAnotherPath As New GraphicsPath
> > Dim myRect As RectangleF
> > Dim myAnotherRect As RectangleF
> >
> > myPath.StartFigure()
> > myPath.AddArc(New RectangleF(0.0F, 0.0F, 100.0F, 100.0F), 320.0F,
> > 220.0F)
> > myAnotherPath.StartFigure()
> > myAnotherPath.AddArc(New RectangleF(0, 150, 100, 100), 270.0F,
> > 270.0F)
> >
> > 'Get the bounding rectangles
> > myRect = myPath.GetBounds()
> > myAnotherRect = myAnotherPath.GetBounds()
> >
> > 'Print the bounding rectangles
> > e.Graphics.DrawPath(Pens.Black, myPath)
> > e.Graphics.DrawString(myRect.ToString, Me.Font, Brushes.Black,
120,
> > 50)
> >
> > e.Graphics.DrawPath(Pens.Black, myAnotherPath)
> > e.Graphics.DrawString(myAnotherRect.ToString, Me.Font,
> > Brushes.Black, 120, 200)
> >
> > 'Draw the bounding rectangles
> > e.Graphics.DrawRectangle(Pens.Red, myAnotherRect.X,
> > myAnotherRect.Y, myAnotherRect.Width, _
> > myAnotherRect.Height)
> > e.Graphics.DrawRectangle(Pens.Red, myRect.X, myRect.Y,
> > myRect.Width, myRect.Height)
> >
> > End Sub
> >
> >
> > ---
> > Posted using Wimdows.net NntpNews Component -
> >
> > Post Made from http://www.DotNetJunkies.com/... Our newsgroup
> > engine supports Post Alerts, Ratings, and Searching.
>
>


Julian

11/19/2004 6:52:00 PM

0

Guys you are geniuses! I cant tell you how many forums I've been on with
this one.



Just flattened the path works a treat!





Thank you very much



Julian


"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:ucsgZPmzEHA.804@TK2MSFTNGP12.phx.gbl...
> We should point out that to cure this the path could be flattened...
>
> --
> Bob Powell [MVP]
> Visual C#, System.Drawing
>
> Find great Windows Forms articles in Windows Forms Tips and Tricks
> http://www.bobpowell.net/tips...
>
> Answer those GDI+ questions with the GDI+ FAQ
> http://www.bobpowell.net/f...
>
> All new articles provide code in C# and VB.NET.
> Subscribe to the RSS feeds provided and never miss a new article.
>
>
>
>
>
> "Frank Hileman" <frankhil@no.spamming.prodigesoftware.com> wrote in
> message
> news:u$xpzykzEHA.3972@TK2MSFTNGP12.phx.gbl...
>> I did not debug your code, but remember that AddArc generates control
>> points, and they are included in the GetBounds calculations.
>>
>> Regards,
>> Frank Hileman
>>
>> check out VG.net: www.vgdotnet.com
>> Animated vector graphics system
>> Integrated Visual Studio .NET graphics editor
>>
>> "DotNetJunkies User" <User@-NOSPAM-DotNetJunkies.com> wrote in message
>> news:OMOV4TkzEHA.748@TK2MSFTNGP14.phx.gbl...
>> > Hi, Iâ?Tm having trouble with the GetBounds function of a GraphicsPath.
>> > See code below.
>> > The first Arcâ?Ts Bounding rectangle is just plain wrong, itâ?Ts
> 106.0523
>> > wide, it canâ?Tt be any wider than 100, because thats the size of the
>> > rectangle used to draw it!
>> >
>> > The second Arc is correct and is there just for reference.
>> >
>> > I would really appreciate it if anyone can shed some light on what I am
>> > doing wrong
>> >
>> > Cheers
>> >
>> >
>> > Talyrond
>> >
>> > Private Sub Form1_Paint(ByVal sender As Object, ByVal e As
>> > System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
>> >
>> > Dim myPath As New GraphicsPath
>> > Dim myAnotherPath As New GraphicsPath
>> > Dim myRect As RectangleF
>> > Dim myAnotherRect As RectangleF
>> >
>> > myPath.StartFigure()
>> > myPath.AddArc(New RectangleF(0.0F, 0.0F, 100.0F, 100.0F),
>> > 320.0F,
>> > 220.0F)
>> > myAnotherPath.StartFigure()
>> > myAnotherPath.AddArc(New RectangleF(0, 150, 100, 100), 270.0F,
>> > 270.0F)
>> >
>> > 'Get the bounding rectangles
>> > myRect = myPath.GetBounds()
>> > myAnotherRect = myAnotherPath.GetBounds()
>> >
>> > 'Print the bounding rectangles
>> > e.Graphics.DrawPath(Pens.Black, myPath)
>> > e.Graphics.DrawString(myRect.ToString, Me.Font, Brushes.Black,
> 120,
>> > 50)
>> >
>> > e.Graphics.DrawPath(Pens.Black, myAnotherPath)
>> > e.Graphics.DrawString(myAnotherRect.ToString, Me.Font,
>> > Brushes.Black, 120, 200)
>> >
>> > 'Draw the bounding rectangles
>> > e.Graphics.DrawRectangle(Pens.Red, myAnotherRect.X,
>> > myAnotherRect.Y, myAnotherRect.Width, _
>> > myAnotherRect.Height)
>> > e.Graphics.DrawRectangle(Pens.Red, myRect.X, myRect.Y,
>> > myRect.Width, myRect.Height)
>> >
>> > End Sub
>> >
>> >
>> > ---
>> > Posted using Wimdows.net NntpNews Component -
>> >
>> > Post Made from http://www.DotNetJunkies.com/... Our newsgroup
>> > engine supports Post Alerts, Ratings, and Searching.
>>
>>
>
>