日期:2014-05-17 浏览次数:21074 次
Bitmap bmp; private void Form1_Load(object sender, EventArgs e) { bmp = new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height); Graphics graphics = Graphics.FromImage(bmp); int i, j; int w = bmp.Width; int h = bmp.Height; int interval = 5; // //每隔5个像素点画设置一个黑颜色点,生成图片。 // // for (i = 0; i < w; i += interval) // { // for (j = 0; j < h; j += interval) // { // //使用SetPixel()来设置像素点。 // bmp.SetPixel(i, j, Color.Black); // } // } bmp.SetPixel(33, 55, Color.Black); bmp.SetPixel(5, 3, Color.Black); bmp.SetPixel(44, 35, Color.Black); } private void OnPaint(object sender, PaintEventArgs e) { Graphics graphics = e.Graphics; //显示图片 graphics.DrawImage(bmp, new Rectangle(0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height)); }