在C#winform中,在一张图片上 根据数据库里面的 X值和Y值 在图片上面画点并且连成直线, 有20个点左右

解决方案 »

  1.   

    Graphics gr = Graphics.FromImage(yourImage);
    gr.DrawXXX
      

  2.   

    Graphics g = Graphics.FromImage(要画线的图片);
    g.DrawLine(new Pen(颜色值), 第一个点X, 第一个点Y, 第二个点X, 第二个点Y);
    ……
      

  3.   

    http://www.cnblogs.com/stg609/archive/2008/03/16/1108407.html
      

  4.   

    思路是:
    画点,你可以画一个直径很小的圆圆心是这个点的位置.
    画直线.就是graphics.drawline啊..
    经常这样画..
      

  5.   

    http://blog.csdn.net/chenpeng0118/article/details/6975649private void button1_Click(object sender, EventArgs e)
            {
                int height = 400, width = 600;
                System.Drawing.Bitmap image = new System.Drawing.Bitmap(height, width);
                Graphics g = Graphics.FromImage(image);//创建一个对象            Font font = new System.Drawing.Font("Arial", 9, FontStyle.Regular);           
                g.Clear(Color.White);            System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, image.Width, image.Height), Color.Blue, Color.Blue, 1.2f, true);
                g.FillRectangle(Brushes.WhiteSmoke, 0, 0, width, height);                        Brush brush1 = new SolidBrush(Color.Blue);
                g.DrawRectangle(new Pen(Color.Blue), 0, 0, image.Width - 4, image.Height - 4);
                Pen mypen = new Pen(brush, 1);            int x = 100;
                for (int i = 0; i < 11; i++)
                {
                    g.DrawLine(mypen, x, 80, x, 340);
                    x = x + 40;
                }
                Pen mypen1 = new Pen(Color.Blue, 2);
                g.DrawLine(mypen1, x - 480, 80, x - 480, 340);
                
                int y = 106;
                for (int i = 0; i < 9; i++)
                {
                    g.DrawLine(mypen, 60, y, 540, y);
                    y = y + 26;
                }
                g.DrawLine(mypen1, 60, y, 540, y);            //x
                String[] month = {"  一月", "  二月", "  三月", "  四月", "  五月", "  六月", "  七月",
                         "  八月", "  九月", "  十月", "十一月", "十二月"};
                x = 62;
                for (int i = 0; i < 12; i++)
                {
                    g.DrawString(month[i].ToString(), font, Brushes.Green, x, 348);  
                    x = x + 40;
                }            //y
                String[] m = {"100%", " 90%", " 80%", " 70%", " 60%", " 50%", " 40%", " 30%",
                         " 20%", " 10%", "  0%"};
                y = 85;
                for (int i = 0; i < 11; i++)
                {
                    g.DrawString(m[i].ToString(), font, Brushes.Green, 25, y);  
                    y = y + 26;
                }            //实际的数据可以从数据库读取出来保存在一个数组里面即可。
                int[] Count = new int[12];            Count[0] = 50;
                Count[1] = 100;
                Count[2] = 200;
                Count[3] = 120;
                Count[4] = 90;
                Count[5] = 400;
                Count[6] = 160;
                Count[7] = 420;
                Count[8] = 300;
                Count[9] = 280;
                Count[10] = 350;
                Count[11] = 15;            x = 70;
                for (int i = 0; i < 12; i++)
                {
                    SolidBrush mybrush = new SolidBrush(Color.Red);
                    g.FillRectangle(mybrush, x, 339 - Count[i] * 5 / 10, 20, Count[i] * 5 / 10);
                    x = x + 40;
                }            //将图片设置为Panel的背景颜色,然后呈现出来。
                this.panel1.BackgroundImage = image;
            }
      

  6.   

    c#里边有很多GDI的画图函数,如果只是两个点的话,就Graphic g=this.createGraphic().
    g.drawLine(new pen(color.black,2),point1,point2)。这样重复N次把要连接的点依次画出来就可以了。不过如果你想要的结果是
    将这些点连接成为封闭的图形的画。还可以用这个画图函数:g.drawlines()、它会将你传入的点的数组按点顺序画成封闭的图形。具体细节就点击g右键 goto defination,看它们的具体用法吧!或者F1查找Graphic
      

  7.   

    14楼正解
     
    此消息通过 【CSDN论坛 Winform正式版】 回复!有关此工具