JerryD Posted November 3, 2003 Posted November 3, 2003 (edited) I'm new to gdi+ and I'm trying to plot 6x6 pixel ellipses on a map to show positioning. The problem is that I am not able to plot the ellipse precisely to my expected x,y coordinates. It it plotting high and to the left. Any suggestions? here is my code: Dim firstPoint As Boolean = True Dim mapName As String myRead = myCom.ExecuteReader Dim oCanvas As Bitmap Dim g As Graphics Do While myRead.Read If firstPoint = True Then firstPoint = False mapName = myRead.Item("map_name") 'We load an existing bitmap oCanvas = CType(Image.FromFile(Server.MapPath("library/images/maps/" + mapName)), Bitmap) g = Graphics.FromImage(oCanvas) g.ResetTransform() '***********Draw points on map *************************************** g.FillEllipse(Brushes.Red, myRead.Item("x_coor"), myRead.Item("y_coor"), 6, 6) g.ResetTransform() Else If mapName = myRead.Item("map_name") Then g.FillEllipse(Brushes.Black, myRead.Item("x_coor"), myRead.Item("y_coor"), 6, 6) g.ResetTransform() Else Exit Do End If End If Loop '******************************************************************** 'resize the image Dim mapWidth = oCanvas.Width * 0.75 Dim mapHeight = oCanvas.Height * 0.75 'output new image with different size Dim outputBitMap As Bitmap = New Bitmap(oCanvas, mapWidth, mapHeight) Response.ContentType = "image/jpeg" outputBitMap.Save(Response.OutputStream, ImageFormat.Jpeg) Response.End() 'Cleanup g.Dispose() oCanvas.Dispose() f1.Dispose() f3.Dispose() Thanks! Edited February 10, 2007 by PlausiblyDamp Quote
GeoManiac Posted February 10, 2007 Posted February 10, 2007 Hi - this seems like an issue around needing to add or subtract half the height and half the width of the ellipse before plotting it to position it properly on the 'Pixel of Interest' Quote
Leaders snarfblam Posted February 11, 2007 Leaders Posted February 11, 2007 With the Draw/FillElipse methods, you specify a bounding rectangle as opposed to a center and a size. So, like GeoManiac said, you need to subtract the radius from the X and Y values. Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.