Graphics 只是绘图时的 Device Context ,不是图片

解决方案 »

  1.   

    这样保存图像:
    private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
    {
    Bitmap b=new Bitmap(200,200);
    Graphics g=Graphics.FromImage(b);
    g.FillRectangle(Brushes.Red,0,0,b.Width,b.Height); Graphics g2=e.Graphics;
    g2.FillRectangle(Brushes.White,this.ClientRectangle);
    g2.DrawImage(b,new Rectangle(10,10,b.Width,b.Height));
    b.Save("aa.jpg",System.Drawing.Imaging.ImageFormat.Jpeg);//保存图像为aa.jpg b.Dispose();
    g2.Dispose();
    g.Dispose();
    }