|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Strange Results From FillEllipseI am using ASP.NET to create a .gif file using the Bitmap and Graphics classes. My file will be made up of only ellipses of equal width and height, placed side by side (basically a grid of circles), created using the FillEllipse method of the Graphics class. However, my results created the following image (shown here in Windows Paint so you can see the individual pixels):
Notice that each so-called ellipse is not an ellipse. The method used to create each of these ellipses is as follows: ledgraphic.FillEllipse(New SolidBrush(Color.Green),x,y,4,4) 'x and y are always multiples of 4, such as 0,4,8,etc Why are my so-called ellipses not circles? Any help would be appreciated. Thanks. Hi Nathan,
it seems to me that it's just the way dot net handles the smaller ellipses, in the test (see the code below) the ellipses start looking the way you want when they are 7 by 7 but they only look like real elipses when then width and heigth are odd numbers, if the numbers are even you have that one extra colored pixel on the left. The draw Arc method seems to have less problems with this but it hasn't got a fill method. For my example to work you need a button and a picturebox(450x450) on a form: 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) 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.DrawArc(Pens.LawnGreen, x, intY, width, height, 0, 360) End Select intY += 18 Next End Sub Hth, 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) "Nathan Sokalski" <njsokal***@hotmail.com> schreef in bericht news:exik0eOFGHA.1180@TK2MSFTNGP09.phx.gbl... I am using ASP.NET to create a .gif file using the Bitmap and Graphics classes. My file will be made up of only ellipses of equal width and height, placed side by side (basically a grid of circles), created using the FillEllipse method of the Graphics class. However, my results created the following image (shown here in Windows Paint so you can see the individual pixels):Notice that each so-called ellipse is not an ellipse. The method used to create each of these ellipses is as follows: ledgraphic.FillEllipse(New SolidBrush(Color.Green),x,y,4,4) 'x and y are always multiples of 4, such as 0,4,8,etc Why are my so-called ellipses not circles? Any help would be appreciated. Thanks. -- Nathan Sokalski njsokal***@hotmail.com http://www.nathansokalski.com/
Disable Button after click it
Panel Syntax Hide Menu Items Based On Roles TypeConverter Question ASP.NET 2.0 sort DataList without query again Dynamically show different web controls ButtonColumn and EditCommandColumn don't work together as expected in DataGrid WebControl Click Event Not Firing multiple itemtemplates datalist Dynamically changing LinkButton properties |
|||||||||||||||||||||||