在PictureBox中渲染地理坐标点失败,请求协助排查问题
在PictureBox中渲染地理坐标点失败,请求协助排查问题
我现在尝试在PictureBox上绘制地理坐标点,但怎么都没效果,实在搞不清楚问题出在哪。我写了代码来计算图像尺寸和实际地理坐标对应的绘制点,但就是不生效,有没有大佬能帮我找找问题?
我的代码如下:
private void renderMap(Points p) { SizeF dimensions = pictureBox1.Image.PhysicalDimension; float width = dimensions.Width; float height = dimensions.Height; PictureBox image = this.pictureBox1; Graphics g = Graphics.FromImage(image.Image); while (p is not null) { float x, y; x = float.Parse(p.lon) * width / (width - height); y = float.Parse(p.lat) * height / (0 - height); //Pen p = new Pen(Color.Blue); //int c_radius = 200; //int first_point1 = (int)(Math.Cos(0) * c_radius + x); //int first_point2 = (int)(Math.Sin(0) * c_radius + y); //Point point = new Point(first_point1, first_point2); Brush aBrush = (Brush)Brushes.Red; g.FillRectangle(aBrush, x, y, 300, 300); pictureBox1.Image = image.Image; p = p.next; } }
我试过各种修改代码的方式,但最后还是改回了我觉得最直接的写法,可问题依然存在。
备注:内容来源于stack exchange,提问作者bitcoinluvr6969
相关产品推荐
相关产品推荐

