GDI+ C# 绘图的基本过程以及问题
1.最近刚学GDI+,用GDI+绘图并保存图片的一些基本流程是什么?2.单击按钮,在picturebox上画图,我之前写的一些简单代码如下:Graphicsg;priva...
1.最近刚学GDI+ ,用GDI+绘图并保存图片的一些基本流程是什么?
2.单击按钮,在picturebox上画图,我之前写的一些简单代码如下:
Graphics g;
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
g=e.Graphics;
}
private void btnRandom_Click(object sender, EventArgs e)
{
TestCreatePoint createPoint = new TestCreatePoint(16, "time");
GDIShowData showData = new GDIShowData(); GDIDrawCoordinate showCoordinate = new GDIDrawCoordinate();
ArrayList randomList = createPoint.Randtimeseries(1, 10, this.pictureBox1.Height - 50);
showData.DrawPoint(g, randomList);
showData.DrawLine(new Pen(Color.Black, 1), g, randomList);
showCoordinate.GDIDrawAxis(g, new Pen(Color.Brown, 3));
showCoordinate.GDIDrawGrid(g, new Pen(Color.Gray, 1), new Point(30, this.pictureBox1.Height - 30), new Point(this.pictureBox1.Width - 10, 10), 20, 20);
...
}
目的是要在一个picturebox上画出一个坐标系和折线,如果将click事件处理函数里的语句放到picturebox的paint事件里,就可以成功的画出图片,但是如果放在click里,就不行了,是graphics对象的问题吗? 那应该如何获取picturebox的graphics 展开
2.单击按钮,在picturebox上画图,我之前写的一些简单代码如下:
Graphics g;
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
g=e.Graphics;
}
private void btnRandom_Click(object sender, EventArgs e)
{
TestCreatePoint createPoint = new TestCreatePoint(16, "time");
GDIShowData showData = new GDIShowData(); GDIDrawCoordinate showCoordinate = new GDIDrawCoordinate();
ArrayList randomList = createPoint.Randtimeseries(1, 10, this.pictureBox1.Height - 50);
showData.DrawPoint(g, randomList);
showData.DrawLine(new Pen(Color.Black, 1), g, randomList);
showCoordinate.GDIDrawAxis(g, new Pen(Color.Brown, 3));
showCoordinate.GDIDrawGrid(g, new Pen(Color.Gray, 1), new Point(30, this.pictureBox1.Height - 30), new Point(this.pictureBox1.Width - 10, 10), 20, 20);
...
}
目的是要在一个picturebox上画出一个坐标系和折线,如果将click事件处理函数里的语句放到picturebox的paint事件里,就可以成功的画出图片,但是如果放在click里,就不行了,是graphics对象的问题吗? 那应该如何获取picturebox的graphics 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询