Bitmap imageT1 = new Bitmap(86, 25);现在要将变量 imageT1 保存到文件.
以前用的方法是 imageT1.Save("\\template\\tempPict\\temp2.png");我现在要在点击一个按钮,然后弹出保存对话框之类的....默认保存到"我的文档",保存类型为图片类型,文件名默认为"imageT1"谢谢

解决方案 »

  1.   


    用 saveFileDialog 控件            this._saveFileDialog.FileName = "imageT1";
                this._saveFileDialog.Filter = "PNG Format (*.png)|*.png|Gif Format (*.gif)|*.gif|Jpeg Format (*.jpg)|*.jpg|Tiff Format (*.tif)|*.tif|Bmp Format (*.bmp)|*.bmp";
                if (this._saveFileDialog.ShowDialog() == DialogResult.OK)
                {
        Stream stream = this._saveFileDialog.OpenFile();
                    if (stream != null)
                    {                    ImageFormat png = ImageFormat.Png;
                        if (this._saveFileDialog.FilterIndex == 3)
                        {
                            png = ImageFormat.Gif;
                        }
                        else if (this._saveFileDialog.FilterIndex == 4)
                        {
                            png = ImageFormat.Jpeg;
                        }
                        else if (this._saveFileDialog.FilterIndex == 5)
                        {
                            png = ImageFormat.Tiff;
                        }
                        else if (this._saveFileDialog.FilterIndex == 6)
                        {
                            png = ImageFormat.Bmp;
                        }                    //           Bitmap bitmap = new Bitmap(this.pictureBox1.Image);                    //            gall.DrawImage(this.pictureBox1.Image,0,0);                    //       this.panel1
                        imageT1.Save(stream, png);                    stream.Close();
                    }            }
      

  2.   

    基本思路是这样,其它的自己扩展Bitmap imageT1 = new Bitmap(86, 25);SaveFileDialog sPath = new SaveFileDialog();
    sPath.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
    sPath.Filter = "PNG(*.png)|*.png";
    sPath.FileName = "imageT1";
    if (sPath.ShowDialog() == DialogResult.OK)
    {
        imageT1.Save(sPath.FileName); 
    }
      

  3.   

    谢谢两位.....2楼代码我在MSDN上看到过......