Bitmap myImage = new Bitmap(500,400);
Graphics g = Graphics.FromImage(myImage); 
g.FillRectangle(……………………);//填入任意颜色
g.DrawLine(Pens.red,0,0,50,50);
pictureBox1.Image=myImage;        
pictureBox1.Image.Save("myPic",System.Drawing.Imaging.ImageFormat.Bmp);