当前位置:编程学习 > C#/ASP.NET >>

怎样在C#中画图

现在有一个数组a[3000,2]
前一列的数与后一列一一对应
一对数表示一个点
要求由这3000对数用C#画出图像

问:用什么控件,调用什么函数?
谢谢 --------------------编程问答-------------------- Graphics --------------------编程问答-------------------- Graphics用这很卡啊 每次都重绘一遍 --------------------编程问答-------------------- 方法太多啦!搜一下就有。
可以参考:
http://lixinsmiles.blog.163.com/blog/static/12103313520104103455674/ --------------------编程问答-------------------- Graphics。。 --------------------编程问答-------------------- http://msdn.microsoft.com/zh-cn/library/system.drawing.graphics.aspx --------------------编程问答--------------------
            int[,] a=new int[4,2]{{200,300},{400,500},{600,700},{800,900}};
            Graphics gr = this.CreateGraphics();
            Point[] pos=new Point[a.Length];
            for(int i=0;i<a.GetLength(0);i++)
            {
                for(int j=0;j<a.GetLength(1);j++)
                {
                  pos[j]=new Point(a[i,j],a[i,0]);
                }
            }
            
            gr.FillPolygon( new SolidBrush(Color.Blue), pos,System.Drawing.Drawing2D.FillMode.Alternate);


这个事花填充的多边形,GDI+可以画很多东西,只是有的要仔细的按计划来,也可以画出很帅的图片,这里是个简单示例。 --------------------编程问答-------------------- --------------------编程问答--------------------
引用 6 楼 tsapi 的回复:
C# code
            int[,] a=new int[4,2]{{200,300},{400,500},{600,700},{800,900}};
            Graphics gr = this.CreateGraphics();
            Point[] pos=new Point[a.Length];
            for(in……



要怎么生成对应的坐标轴呢? --------------------编程问答--------------------
            int[,] a = new int[5, 2] { { 120, 180 }, { 160, 150 }, { 360, 170 }, { 140, 390 }, { 390, 300 } };
            Graphics gr = this.CreateGraphics();
            Point[] pos = new Point[a.Length];
            for (int n = 0; n < a.GetLength(0); n++)
            {   
                for (int k = 0; k < a.GetLength(1); k++)
                {
                    pos[n] = new Point(a[n,0], a[n, k]);
                }
            }
            gr.DrawLine(new Pen(new SolidBrush(Color.Black), 3), new Point(-1000, 300), new Point(1000,300));//x
            gr.DrawLine(new Pen(new SolidBrush(Color.Black), 3), new Point(100, -500), new Point(100, 500));//y
            gr.DrawLines(new Pen(new SolidBrush(Color.Blue), 1), pos);

这样来,不过画图涉及的算法也有,要看具体应用! --------------------编程问答-------------------- 坐标轴自己画,

Graphics gr = this.CreateGraphics();   
System.Drawing.Font myfont = new Font("Arial", 6);//字体
            Color b = Color.Black;      //颜色
            SolidBrush sb = new SolidBrush(b);  //画刷
gr.DrawString(str,myfont,sb,x,y);   //在x,y处画刻度,自己画时用循环画即可
//
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,