我想写一个,想画图板那样的程序,是那样的?到底,怎么保存Grapics ,这都是些问题,不知到该如何解决?

解决方案 »

  1.   


    Bitmap bmp=new Bitmap(800,600);//相当于画布
    Graphics g=Graphics.FromImage(bmp);
    g.DrawImage(……)//在这画东西
    ……
    ……
    bmp.Save("abc.jpg");//保存
      

  2.   

    这样是不是相当于保存的是bmp?而不是保存Graphics,哦。我明白了,谢谢了,画图的话,要在bmp 上作图,然后保存是不是?
      

  3.   

    http://blog.csdn.net/dunao/archive/2008/10/21/3120015.aspx
    看看这个
      

  4.   

                //这段程序,老是有异常,不知道什么原因,求解?
                Bitmap bitmap = new Bitmap(400,400);
                ImageFormat imFor = bitmap.RawFormat;
                Graphics grfx = Graphics.FromImage(bitmap);
                grfx.DrawLine(new Pen(Brushes.Red), 0, 0, 200, 200);
                bitmap.Save(GetPicturePath() + @"CopyTo\1.bmp",imFor);
                grfx.Dispose();
      

  5.   

     Bitmap bmp = new Bitmap(400, 400);
                Graphics p = Graphics.FromImage(bmp);
                p.DrawLine(new Pen(Color.Red), new Point(10, 10), new Point(20, 20));
                bmp.Save("d:\\aa.bmp");
                p.Dispose();
    楼主,你的代码我试验了,可以啊,没出错。
      

  6.   


    呵呵,你保存图片的路径不正确。不信你调试一下,那个路径不存在。。
                //这段程序,老是有异常,不知道什么原因,求解? 
                Bitmap bitmap = new Bitmap(400,400); 
                ImageFormat imFor = bitmap.RawFormat; 
                Graphics grfx = Graphics.FromImage(bitmap); 
                grfx.DrawLine(new Pen(Brushes.Red), 0, 0, 200, 200); 
                bitmap.Save("1.bmp",imFor);//这样肯定一点问题都没有。 
                grfx.Dispose();