Graphic in C#
-
Hello, I am writing a visual C# program to read GPS coordinates (x,y) and will like to plot the points on a form as a bitmap, can someone advise me on the most effective way in doing that? Thanks, Ron
-
Hello, I am writing a visual C# program to read GPS coordinates (x,y) and will like to plot the points on a form as a bitmap, can someone advise me on the most effective way in doing that? Thanks, Ron
You just need to scale the points to the coordinate system that you use in your bitmap. For example, if your bitmap is 100 x 100, and your latitude and longitude cover a range of 20 degrees each. Then each degree covers a range of 5 pixels, or alternatively each pixel is equivalent to 12 minutes. So to convert a latitude of 10'30" to pixel point, convert to minutes 10 * 60 + 30 = 630, divide by 12 = 52.5, rounded = 53. So that point lies at Y coordinate 53.
-
Hello, I am writing a visual C# program to read GPS coordinates (x,y) and will like to plot the points on a form as a bitmap, can someone advise me on the most effective way in doing that? Thanks, Ron
In addition to what Richard said if I need to draw I usually use GDI+ for simple things. You can add a panel to your form and make the background white. Then you can get a Graphics [^]object from that. You use the FromHwnd[^] method and pass the panel's handle to it. Now you can use the Graphics object to draw. Note that this also uses coordinates with 0,0 on the top left corner. The width and height of the panel are your maximum lengths to draw within the boundaries. Note that the x-axis is going to the right and the y-axis is going down! Hope this helps. (PS: there's probably a charting library available on Codeproject, you could search for that)
V.
(MQOTD rules and previous solutions) -
Hello, I am writing a visual C# program to read GPS coordinates (x,y) and will like to plot the points on a form as a bitmap, can someone advise me on the most effective way in doing that? Thanks, Ron
You may also take a look at my article Bernie’s Trackviewer[^]. There, the corrdinates are loaded from gpx files.
-
You just need to scale the points to the coordinate system that you use in your bitmap. For example, if your bitmap is 100 x 100, and your latitude and longitude cover a range of 20 degrees each. Then each degree covers a range of 5 pixels, or alternatively each pixel is equivalent to 12 minutes. So to convert a latitude of 10'30" to pixel point, convert to minutes 10 * 60 + 30 = 630, divide by 12 = 52.5, rounded = 53. So that point lies at Y coordinate 53.
Thanks for the ideas, I'll see how this works out Ron