|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DrawEllipse gives inaccurate results for some radiiI am trying to draw circles using GDI+ 's DrawEllipse method. I need the circles to be the same on all sides, because I will be writing code that detects what pixels are what color. I tested the DrawEllipse method for values of up to about 10 (I didn't bother with values above that, since I already found an inaccuracy at width/height of 5). Here is the code I used and the result I got:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim mybitmap As New Bitmap(10, 10) Dim mygraphic As Graphics = Graphics.FromImage(mybitmap) mygraphic.DrawEllipse(New Pen(Color.HotPink, 1), 1, 1, 5, 5) mybitmap.Save(Server.MapPath("images/ellipse6.gif"), Imaging.ImageFormat.Gif) Image1.ImageUrl = "images/ellipse6.gif?timemade=" & Server.UrlEncode(Date.Now.ToShortDateString() & Date.Now.ToLongTimeString()) End Sub You will probably notice that the circle I am showing here has somewhat of a discrepancy on the lower right side. This makes it very hard to write procedures based on existing pixels, and probably very frustrating for people writing graphics-oriented applications. I cannot use any SmoothingMode based solutions, because all the pixels must be the same color (I need to know what color to try to detect when writing procedures based on existing pixels). Does anyone have any suggestions? this is a side effect of translating analog coordinates to a digital bitmap. normally you would perform aliasing to get the circle to look nicer. generally in bitmap graphics, you either keep an object model you modifiy render to a bitmap, or you just use the bit directly. just access the pixel and check the color - this is how a fill is done.
-- bruce (sqlwork.com) "Nathan Sokalski" <njsokal***@hotmail.com> wrote in message news:%23NZNByeHGHA.240@TK2MSFTNGP11.phx.gbl... I am trying to draw circles using GDI+ 's DrawEllipse method. I need the circles to be the same on all sides, because I will be writing code that detects what pixels are what color. I tested the DrawEllipse method for values of up to about 10 (I didn't bother with values above that, since I already found an inaccuracy at width/height of 5). Here is the code I used and the result I got:Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim mybitmap As New Bitmap(10, 10) Dim mygraphic As Graphics = Graphics.FromImage(mybitmap) mygraphic.DrawEllipse(New Pen(Color.HotPink, 1), 1, 1, 5, 5) mybitmap.Save(Server.MapPath("images/ellipse6.gif"), Imaging.ImageFormat.Gif) Image1.ImageUrl = "images/ellipse6.gif?timemade=" & Server.UrlEncode(Date.Now.ToShortDateString() & Date.Now.ToLongTimeString()) End Sub You will probably notice that the circle I am showing here has somewhat of a discrepancy on the lower right side. This makes it very hard to write procedures based on existing pixels, and probably very frustrating for people writing graphics-oriented applications. I cannot use any SmoothingMode based solutions, because all the pixels must be the same color (I need to know what color to try to detect when writing procedures based on existing pixels). Does anyone have any suggestions? -- Nathan Sokalski njsokal***@hotmail.com http://www.nathansokalski.com/ I don't think I understood a word you said, but I think you misunderstood what I am looking for. I am looking for a simple way to draw circles that are the same on all sides.
"Bruce Barker" <brubar_nospamplease_@safeco.com> wrote in message news:eASPW$eHGHA.1028@TK2MSFTNGP11.phx.gbl... this is a side effect of translating analog coordinates to a digital bitmap. normally you would perform aliasing to get the circle to look nicer. generally in bitmap graphics, you either keep an object model you modifiy render to a bitmap, or you just use the bit directly. just access the pixel and check the color - this is how a fill is done.-- bruce (sqlwork.com) "Nathan Sokalski" <njsokal***@hotmail.com> wrote in message news:%23NZNByeHGHA.240@TK2MSFTNGP11.phx.gbl... I am trying to draw circles using GDI+ 's DrawEllipse method. I need the circles to be the same on all sides, because I will be writing code that detects what pixels are what color. I tested the DrawEllipse method for values of up to about 10 (I didn't bother with values above that, since I already found an inaccuracy at width/height of 5). Here is the code I used and the result I got:Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim mybitmap As New Bitmap(10, 10) Dim mygraphic As Graphics = Graphics.FromImage(mybitmap) mygraphic.DrawEllipse(New Pen(Color.HotPink, 1), 1, 1, 5, 5) mybitmap.Save(Server.MapPath("images/ellipse6.gif"), Imaging.ImageFormat.Gif) Image1.ImageUrl = "images/ellipse6.gif?timemade=" & Server.UrlEncode(Date.Now.ToShortDateString() & Date.Now.ToLongTimeString()) End Sub You will probably notice that the circle I am showing here has somewhat of a discrepancy on the lower right side. This makes it very hard to write procedures based on existing pixels, and probably very frustrating for people writing graphics-oriented applications. I cannot use any SmoothingMode based solutions, because all the pixels must be the same color (I need to know what color to try to detect when writing procedures based on existing pixels). Does anyone have any suggestions? -- Nathan Sokalski njsokal***@hotmail.com http://www.nathansokalski.com/ |
|||||||||||||||||||||||