Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / January 2006

Tip: Looking for answers? Try searching our database.

Why so much trouble with ellipses?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nathan Sokalski - 13 Jan 2006 05:22 GMT
In a recent post of mine I mentioned the inaccurate shapes drawn by
FillEllipse. In the response that I recieved I was told that DrawArc had
less problems, which I found to be true (I have been using DrawEllipse, but
they seem to have the same results when drawing a complete 360). However,
even with these methods, there are situations where the results are not even
symmetric along both axes (my best example of this is with a width and
height of 6). I know enough about math and computers to be able to figure
out how to write a simple method to create a basic circle or ellipse, so I'm
not going to ask anyone to tell me how to fix it (even though that would be
nice), but I am going to ask why couldn't Microsoft make this simple method
themselves? It's not like this is the first time they ever had to do it.
Heck, they could have just borrowed some code from Paint, I know that that
makes correct circles/ellipses. Do they plan to fix this in a future
version, or is GDI+ such a small part of .NET that they don't care? (I will
admit that I am guilty of still using .NET 1.1, but I still think it should
have been a simple enough task that they could have done it right by now).
What do all of you think?
Signature

Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

Cor Ligthert [MVP] - 13 Jan 2006 07:24 GMT
Nathan,

You make me curious I see a lot of crossposting adresses. Feel free to do
that.

The in my idea real newsgroup for this question

microsoft.public.dotnet.framework.drawing

is not in it.

What is the reason for that?

Cor
Nathan Sokalski - 13 Jan 2006 19:54 GMT
I am not currently subscribed to that newsgroup, so I guess I forgot to post
to it. But now that I know about it, I guess it would be one of, if not the,
best group for my question. Thanks.
Signature

Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

> Nathan,
>
[quoted text clipped - 10 lines]
>
> Cor
Peter Proost - 16 Jan 2006 09:39 GMT
Hi Nathan

these two thing should help you, you don't need to use them both, it seems
to me that setting the g.SmoothingMode gives better results.

g.PixelOffsetMode = Drawing2D.PixelOffsetMode.Half

g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

> I am not currently subscribed to that newsgroup, so I guess I forgot to post
> to it. But now that I know about it, I guess it would be one of, if not the,
[quoted text clipped - 18 lines]
> >
> > Cor
Nathan Sokalski - 17 Jan 2006 01:19 GMT
I tried all of the settings for each of these, but none of them made
ellipses with a radius of 6 the same on all sides, the closest ones were the
same as not setting the settings at all. I am assuming that this would be
true for other radii as well, but since DrawEllipse already gave me good
ellipses for all the radii I tried, I didn't bother testing anything other
than 6. In other words, back to the System.Drawing board.
Signature

Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

> Hi Nathan
>
[quoted text clipped - 37 lines]
>> >
>> > Cor
Peter Proost - 17 Jan 2006 07:24 GMT
Hi Nathan,

if I add g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality to the sample
I posted a couple of days ago, I get nice ellipses with drawellipse and
fillellipse for all radii from 4 to 14 (haven't tested any further)

Grtz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

> I tried all of the settings for each of these, but none of them made
> ellipses with a radius of 6 the same on all sides, the closest ones were the
[quoted text clipped - 48 lines]
> >> >
> >> > Cor
Peter Proost - 17 Jan 2006 07:28 GMT
Here's the example again because it wasn't origanly posted in this thread

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
       Dim myBmp As New Bitmap(450, 450)
       Dim g As Graphics
       g = Graphics.FromImage(myBmp)
       g.Clear(Color.Black)
       g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
       Dim posX As Integer = 10
       Dim myWidth, myHeight As Integer
       myWidth = 4
       myHeight = 4
       For i As Integer = 0 To 21
           If i <= 10 Then
               drawCircles(g, 0, posX, myWidth, myHeight)
           Else
               drawCircles(g, 1, posX, myWidth, myHeight)
           End If
           posX += 20
           myWidth += 1
           myHeight += 1
           If i = 10 Then
               myWidth = 4
               myHeight = 4
           End If
       Next
       g.Dispose()
       PictureBox1.Image = myBmp
       myBmp.Save("c:\testEllipse.bmp", Drawing.Imaging.ImageFormat.Bmp)
 MsgBox("c:\testEllipse.bmp Saved", MsgBoxStyle.Information, "Saved")

End Sub

Private Sub drawCircles(ByVal g As Graphics, ByVal drawType As Integer,
ByVal x As Integer, ByVal width As Integer, _ ByVal _ height As Integer)
       Dim intY As Integer = 5
       For i As Integer = 0 To 20
           Select Case drawType
               Case 0
                   g.FillEllipse(Brushes.LawnGreen, x, intY, width, height)
               Case 1
                   g.DrawEllipse(Pens.LawnGreen, x, intY, width, height)
           End Select
           intY += 18
   Next
End Sub

Greetz Peter
--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

> I tried all of the settings for each of these, but none of them made
> ellipses with a radius of 6 the same on all sides, the closest ones were the
[quoted text clipped - 48 lines]
> >> >
> >> > Cor

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.