Graphics g  = this.pictureBox1.CreateGraphics();
Font font1   = new System.Drawing.Font("Arial", 18);
SolidBrush  brush2=  new System.Drawing.SolidBrush(Color.Red );
g.Clear(pictureBox1.BackColor); 
g.DrawString("中国", font1, brush2,1,1);
pictureBox1.Image.Save("aa.bmp"); //error

解决方案 »

  1.   

    不能保存的原因大概是pictureBox的image是为空的,你可以先建立一个Bitmap,然后在Bitmap中写入字"中国",然后贴在pictureBox 中,这样picturebox的image才有内容.参考代码如下:
    Bitmap memBitmap = new Bitmap(100, 200);
    Graphics g = Graphics.FromImage(memBitmap);
                SolidBrush brush = new System.Drawing.SolidBrush(Color.Red);
                Font drawFont = new Font("Arial", 18);
                g.DrawString("中国", drawFont, brush, 0, 0);贴图   pictureBox1.Image = memBitmap ;
      

  2.   

    tmpBMP = new Bitmap(pictureBox1.Width, pictureBox1.Height);
    pictureBox1.DrawToBitmap(tmpBMP, new Rectangle(0, 0, pictureBox1.Width, pictureBox1.Height));
    pictureBox2.Image = tmpBMP;